相关疑难解决方法(0)

在Tkinter应用程序中是否继承Frame

我已经看到了两种设置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)

python tkinter

28
推荐指数
2
解决办法
3万
查看次数

Tkinter:没有标题栏但可调整大小的窗口

我所知道的是,如果我想创建一个没有标题栏的窗口,我可以写

    root = Tk()
    ........
    root.overrideredirect(1)
Run Code Online (Sandbox Code Playgroud)

但我也希望窗口可以调整大小.有什么解决方案吗?

(仅供参考:我正在使用Windows机器,虽然我不确定它是否真的很重要.如果有独立于操作系统的解决方案,它将是完美的,但如果至少有Windows的解决方案,我很高兴.)

python resize tk-toolkit tkinter titlebar

8
推荐指数
1
解决办法
7800
查看次数

标签 统计

python ×2

tkinter ×2

resize ×1

titlebar ×1

tk-toolkit ×1