如何解决如何使用选项菜单选择功能的输入
我需要知道如何通过选项菜单选择功能Findindex
的输入,该功能可以通过按钮激活。我尝试过
opt1 = tk.OptionMenu(root,variable1,*OptionList)
button1 = tk.Button(master=root,text='Bestätige',command=Findindex4(variable1.get()))
但这不起作用
下面是整个代码。您无法运行它,因为您需要一个名为Ausgangsdaten.xlsx
非常感谢
from tkinter import *
import tkinter as tk
import pandas as pd
dp_ts_SpaltenIndex={}
SpaltenNumSort1={} # Spalte von Drehzahl n
SpaltenNumSort2={} # Spalte von Volumenstrom V_Dot
deta_ts_SpaltenIndex={}
df = pd.read_excel("Ausgangsdaten.xlsx")
SpaltenListe=df.columns.tolist()
def Findindex1(Suche):
global SpaltenListe
global SpaltenNumSort1
matched_indexes = []
i = 0
length = len(SpaltenListe)
while i < length:
if Suche == SpaltenListe[i]:
matched_indexes.append(i)
i += 1
SpaltenNumSort1= matched_indexes
def Findindex2(Suche):
global SpaltenListe
global SpaltenNumSort2
matched_indexes = []
i = 0
length = len(SpaltenListe)
while i < length:
if Suche == SpaltenListe[i]:
matched_indexes.append(i)
i += 1
SpaltenNumSort2= matched_indexes
def Findindex3(Suche):
global SpaltenListe
global dp_ts_SpaltenIndex
matched_indexes = []
i = 0
length = len(SpaltenListe)
while i < length:
if Suche == SpaltenListe[i]:
matched_indexes.append(i)
i += 1
dp_ts_SpaltenIndex= matched_indexes
def Findindex4(Suche):
global SpaltenListe
global deta_ts_SpaltenIndex
matched_indexes = []
i = 0
length = len(SpaltenListe)
while i < length:
if Suche == SpaltenListe[i]:
matched_indexes.append(i)
i += 1
deta_ts_SpaltenIndex= matched_indexes
root=Tk()
root.title('Spaltenauswahl')
OptionList = SpaltenListe
variable1 = tk.StringVar(root)
variable2 = tk.StringVar(root)
variable3 = tk.StringVar(root)
variable4 = tk.StringVar(root)
variable1.set('Wähle aus')
variable2.set('Wähle aus')
variable3.set('Wähle aus')
variable4.set('Wähle aus')
w1 = Label(root,text="Drehzahl:")
w2 = Label(root,text="Volumenstrom:")
w3 = Label(root,text="Druckänderung:")
w4 = Label(root,text="Wirkungsgradänderung:")
opt1 = tk.OptionMenu(root,*OptionList)
opt2 = tk.OptionMenu(root,variable2,*OptionList)
opt3 = tk.OptionMenu(root,variable3,*OptionList)
opt4 = tk.OptionMenu(root,variable4,command=Findindex1(variable1.get()))
button2 = tk.Button(master=root,command=Findindex2(variable2.get()))
button3 = tk.Button(master=root,command=Findindex3(variable3.get()))
button4 = tk.Button(master=root,command=Findindex4(variable4.get()))
w1.pack()
opt1.pack()
button1.pack()
w2.pack()
opt2.pack()
button2.pack()
w3.pack()
opt3.pack()
button3.pack()
w4.pack()
opt4.pack()
button4.pack()
root.geometry("500x600")
root.mainloop()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。