当我打开文件对话框并在根目录中写其他内容时,我可以使用上下箭头更改spinbox值,但我无法单击并编写其中的内容。我做错了什么?这是一个已知的错误吗?
当我不调用
编辑:
当我点击组合框的下拉箭头一次时,我就可以在其中写入内容?!
当我不调用
filedialog.askopenfilename
并手动输入路径时,它可以正常工作。编辑:
当我点击组合框的下拉箭头一次时,我就可以在其中写入内容?!
from tkinter import filedialog, messagebox, Spinbox, Label, Frame, StringVar, Tk, Button, ttk
colors = ["magma", "inferno", "YlOrBr", "YlOrRd", "Wistia"]
# Pfad einlesen
def readPath():
sheetPath = filedialog.askopenfilename(title = "Choose File",filetypes = (("all files","*.*"),(".xls","*.xls"),(".xlsx","*.xlsx")))
# sheetPath = "C:/Users/leoch/trends.xls"
class Window(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.master = master
sensorData = readPath()
lb = Label(root, text="Settings") #, padx=20, pady=20
lb.pack()
root.title("Settings")
textStart = Label(root, text="From Row: ")
textStart.pack()
tvOffset = StringVar(root)
tvOffset.set=(18)
spinStart = Spinbox(root, from_=18, to=20, width=7, textvariable=tvOffset)
spinStart.pack()
labelFarben = Label(root, text="Colors")
labelFarben.pack()
comboFarben = ttk.Combobox(root, values=colors)
comboFarben.current(0)
comboFarben.pack()
def confirm():
root.withdraw()
# visualization(sensorData, rowStart, rowCount, fps, interpolation, farben)
confirm = Button(root, text="Bestätigen", command=confirm, font=20, padx=20, pady=10, border=2, fg="green")
confirm.pack(padx=20, pady=20)
root = Tk()
app = Window(root)
root.wm_title("Wäremstromvisualisierung")
root.mainloop()
sensorData = readPath()
的下一行添加self.master.focus_force()
。 - Henry