亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Tkinter 甚至不能調用一個簡單的“按鈕”

Tkinter 甚至不能調用一個簡單的“按鈕”

呼喚遠方 2021-10-12 15:47:11
從簡單的 Tkinter 課程開始,即使簡單的代碼不起作用,我也陷入了困境:import tkinter as tkroot = tk.Tk()b = tk.Button(root, text='button'); b.pack()...Traceback (most recent call last):  File "<stdin>", line 1, in <module>  File "/Users/../anaconda3/lib/python3.6/tkinter/__init__.py", line 2366, in __init__    Widget.__init__(self, master, 'button', cnf, kw)  File "/Users/../anaconda3/lib/python3.6/tkinter/__init__.py", line 2296, in __init__    (widgetName, self._w) + extra + self._options(cnf))_tkinter.TclError: can't invoke "button" command: application has been destroyed并且找不到原因,考慮到此代碼來自官方文檔。另一方面,另一個代碼有效:import tkinter as tkclass Application(tk.Frame):    def __init__(self, master=None):        super().__init__(master)        self.master = master        self.pack()        self.create_widgets()    def create_widgets(self):        self.hi_there = tk.Button(self)        self.hi_there["text"] = "Hello World\n(click me)"        self.hi_there["command"] = self.say_hi        self.hi_there.pack(side="top")        self.quit = tk.Button(self, text="QUIT", fg="red",                              command=self.master.destroy)        self.quit.pack(side="bottom")    def say_hi(self):        print("hi there, everyone!")root = tk.Tk()app = Application(master=root)app.mainloop()我試圖tk從 conda:更新conda install -c anaconda tk,但沒有任何變化。想不通為什么
查看完整描述

2 回答

  • 2 回答
  • 0 關注
  • 496 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號