【问题标题】:Tkinter: Is there any way to remove the top bar of my program?Tkinter:有什么办法可以删除我程序的顶部栏?
【发布时间】:2020-11-26 04:59:45
【问题描述】:

好的,所以我正在使用 tkinter 制作 GUI,我觉得顶部栏看起来有点难看,所以我打算删除它并放置一些漂亮的图标。我使用这行代码删除了顶部栏gui.overrideredirect(True),它可以工作:D,但是您不能在屏幕上移动程序(它会粘在屏幕的左上角)。有没有其他方法可以做到这一点而不把我的程序粘在角落里?谢谢。

import requests
import tkinter as tk


#GUI Config
gui = tk.Tk()
gui.geometry('970x569')
gui.title("Zombs Royale Tools v1")
gui.resizable(False, False)

#Code below is the one i used to do this[![enter image description here][1]][1]
gui.overrideredirect(True) 


#Background-image
bgImage = tk.PhotoImage(file="width.png")
background_label = tk.Label(gui, image = bgImage)
background_label.place(x=0,y=0,relwidth=1, relheight=1)

#GUI Widgets#

#Exit Button
exit_image = tk.PhotoImage(file="close.gif")
exit_button = tk.Button(gui, image=exit_image, borderwidth=0, command=gui.destroy)
exit_button.place(rely=0.01, relx=0.01)

【问题讨论】:

    标签: python tkinter


    【解决方案1】:

    删除标题栏是通过覆盖重定向完成的。但是,这也会删除每个窗口函数。这包括移动窗口并调整其大小。 这意味着使用 overrideredirect 您可以跳过

    gui.resizable(False, False)

    您可以做的一件事是为窗口的几何形状提供更多信息:

    gui.geometry('970x569+600+500')
    

    最后 2 个数字提供有关您的窗口在桌面上的位置的信息,以防您不希望它出现在左上角。

    如果您想让窗口可移动,则必须集成您自己的代码。之前已经在这里讨论过了。 例如。 here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-20
      • 2023-01-01
      • 1970-01-01
      相关资源
      最近更新 更多