问题描述
我需要知道如何通过选项菜单选择功能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 (将#修改为@)