我已经看到了两种设置tkinter程序的基本方法.有没有理由更喜欢一个到另一个?
from Tkinter import *
class Application():
def __init__(self, root, title):
self.root = root
self.root.title(title)
self.label = Label(self.root, text='Hello')
self.label.grid(row=0, column=0)
root = Tk()
app = Application(root, 'Sample App')
root.mainloop()
Run Code Online (Sandbox Code Playgroud)
和
from Tkinter import *
class Application(Frame):
def __init__(self, title, master=None):
Frame.__init__(self, master)
self.grid()
self.master.title(title)
self.label = Label(self, text='Hello')
self.label.grid(row=0, column=0)
app = Application('Sample App')
app.mainloop()
Run Code Online (Sandbox Code Playgroud) 我所知道的是,如果我想创建一个没有标题栏的窗口,我可以写
root = Tk()
........
root.overrideredirect(1)
Run Code Online (Sandbox Code Playgroud)
但我也希望窗口可以调整大小.有什么解决方案吗?
(仅供参考:我正在使用Windows机器,虽然我不确定它是否真的很重要.如果有独立于操作系统的解决方案,它将是完美的,但如果至少有Windows的解决方案,我很高兴.)