下面是该问题的一个工作示例。您按下第一个按钮,顶层会以非彩色按钮打开。谢谢!
import tkinter as tk
class MainGui:
def __init__(self,root):
self.root=root
self.main_frame=tk.Frame(root)
self.button1=tk.Button(self.main_frame,text='open top level',
highlightbackground='green',command=self.open_top,font=
('helvetica',24))
self.button1.grid(row=0,column=0)
self.main_frame.grid(row=1,column=1)
def open_top(self):
class TopLevel:
def __init__(self,root):
self.root = root
self.top_frame = tk.Frame(root)
self.button2 = tk.Button(self.top_frame, text='not
colored',highlightbackground='green', font=
('helvetica', 24))
self.button2.grid(row=1,column=1)
self.top_frame.grid(row=1,column=1)
root=tk.Toplevel()
app=TopLevel(root)
root=tk.Tk()
app=MainGui(root)
root.mainloop()