Python函数没有被调用我试过调试器和print语句

2024-09-28 23:19:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我认为这与自我客体有关。我试过print语句和调试器,但没有找到解决方案。这是一个简单的pythongui,很快就会启动一个计时器之类的东西,但我还没有完全实现。 下面是代码:https://pastebin.com/QcAe8bEN

未被调用的函数

 def beginDefault(self):
    initialTime = time.time()
    print("Hello World!")

创建按钮的行。请注意,应该在单击按钮时调用该函数。你知道吗

defaultButton = Button(createIntervalFrame, text="Default", command=self.beginDefault and createIntervalFrame.destroy)

在此处创建初始对象:

root = Tk()   # creating a blank window
interactive = WellRested(root) # Creates a Well Rested object

Tags: 函数代码selftimeroot语句解决方案按钮
1条回答
网友
1楼 · 发布于 2024-09-28 23:19:56

and是一个逻辑运算符,不能用来调用多个函数。要做您想做的事情,您需要第三个函数来调用前两个函数:

def button_clicked(self):
    self.beginDefault()
    self.createIntervalFrame.destroy()
...
defaultButton = Button(createIntervalFrame, text="Default", command=self.button_clicked)

相关问题 更多 >