主窗口打开后,我的辅助窗口上的按钮命令正在执行。我已经看到其他相关的答案,我只传递函数对象。即使我没有传递任何论据,我也尝试过Lambda。 GUI新手。感谢帮助。代码如下:
import tkinter
from src.accounting import runpayroll
class TopGUI:
def __init__(self):
self.main_window = tkinter.Tk()
self.main_window.geometry('300x250+500+200')
self.frame = tkinter.Frame(self.main_window)
self.labelspace = tkinter.Label(self.frame, text='')
self.label = tkinter.Label(self.frame, text='What would you like to do?')
self.labelspace2 = tkinter.Label(self.frame, text='')
self.process_payroll_button = tkinter.Button(self.frame, width='25', bg='white', text='Process payroll', command=self.process_payroll_gui)
self.frame.pack()
self.labelspace.pack()
self.label.pack()
self.labelspace2.pack()
self.process_payroll_button.pack()
tkinter.mainloop()
def process_payroll_gui(self):
self.additional_window = tkinter.Toplevel()
self.additional_window.geometry('300x250+500+200')
self.run_payroll_button = tkinter.Button(self.additional_window, width='25', bg='white', text='Run payroll', command=runpayroll.run_payroll)
self.run_payroll_button.pack()
self.run_payroll_button.place(x=60, y=80)
topgui = TopGUI()
答案 0 :(得分:0)
原来我在导入的文件底部有一个执行语句,用于调试该模块。它正在立即执行。我只是发现它,感谢那些说没有进口声明它工作正常的人。