我是'Tkinter‘库的新手,我想知道如何在打开新窗口时禁用按钮。例如,如果单击主窗口上的按钮,将打开一个新窗口,并禁用主窗口上的所有按钮。关闭窗口后,应再次重新启用按钮。
下面是我的代码示例:
from tkinter import *
root = Tk()
def z():
w = Toplevel()
bu = Button(w, text = "Click!", font = 'bold')
bu.pack()
b = Button(root, text = "Click!", command
在用户按下Login按钮后,我尝试用不同的GUI打开一个全新的文件,但当用户单击它时,我似乎无法销毁主要的Tk窗口。
def __init__(self, master=None): #This is how I initialized the TK window
tkinter.Tk.__init__(self,master)
m_login = tkinter.Button(text="Login",bg="#1e1e1e",foreground="#b4b4b4",width=10,command=s
当用户单击按钮(仍然需要创建)时,我将如何创建一个新窗口?我已经拿出了一些代码来缩短这段时间。我需要一个按钮创建,当他们点击那个按钮,一个新的窗口打开。我还没有创建按钮,因为该按钮必须链接到新窗口。请帮帮忙
My imports...
class App:
def __init__(self, master):
self.master = master
# call start to initialize to create the UI elemets
self.start()
def start(self):
我想做一个按钮,当点击打开一个新窗口(tk.toplevel),是否有办法使该按钮只工作一次,(它只在单击后生成一个新窗口,单击该按钮时不会做任何事情)。
从下面的代码,我可以作出无限的顶级水平点击按钮,但我只是希望它创建一个点击。
import tkinter as tk
class run: # pls ignore if there are any syntrax error/spelling because I typed this in stack overflow
def __init___(self, master)
button = tk.b