Python/Tkinter 制作自定义窗口 [英] Python/Tkinter make a custom window
问题描述
我想制作一个没有顶部任务栏(可移动)的窗口,因此 GUI 框周围只有细小的轮廓.我还想在框中添加我自己的X".
I want to make a window without the top taskbar (that is movable), so there is only thin outline around the GUI box. I also want to add my own 'X' to the box.
import Tkinter
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.parent = master
............
def main():
root = Tk()
root.attributes('-fullscreen', True)
root.geometry('500x250+500+200')
app = Application(root)
app.parent.configure(background = 'gray32')
root.resizable(width=FALSE, height=FALSE)
app.mainloop()
main()
我尝试在进入全屏模式后强制调整框的大小以移除任务栏,但框不再可移动.有什么建议吗?
I tried forcing the box to resize after going into fullscreen to remove the taskbar, though box is no longer movable. Any suggestions?
[我看过这个帖子:删除或禁用 Windows 下可调整大小的 Tkinter 窗口最大化按钮
-toolwindow 属性对我不起作用,可能是因为我使用的是 linux...]
The -toolwindow attribute didn't work for me, maybe because I use linux...]
推荐答案
我用 root.overrideredirect(1)
替换了全屏命令(你说你不希望它完全最大化),它给出一个没有标题栏的窗口(不是任务栏,这是否则).
I replaced the fullscreen command (you said you don't want it fully maximized) with root.overrideredirect(1)
, which gives a window without title bar (not a taskbar, that is something else).
def main():
root = Tk()
root.overrideredirect(1)
root.geometry('500x250+500+200')
app = Application(root)
app.parent.configure(background = 'gray32')
root.resizable(width=FALSE, height=FALSE)
app.mainloop()
这篇关于Python/Tkinter 制作自定义窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!