我有一个python程序,它打开一个新窗口来显示一些“关于”信息。这个窗口有自己的关闭按钮,我已经使它不可调整大小。但是,最大化和最小化的按钮仍然存在,我希望它们消失。
我正在使用Tkinter,包装所有信息以显示在Tk类中。
目前的代码如下。我知道它不漂亮,我计划将信息扩展到一个类中,但我想在继续之前解决这个问题。
有人知道我如何控制windows管理器显示哪些默认按钮吗?
def showAbout(self):
if self.aboutOpen==0:
self.about=Tk()
self.about.title("About "+ self.programName)
Label(self.about,text="%s: Version 1.0" % self.programName ,foreground='blue').pack()
Label(self.about,text="By Vidar").pack()
self.contact=Label(self.about,text="Contact: adress@gmail.com",font=("Helvetica", 10))
self.contact.pack()
self.closeButton=Button(self.about, text="Close", command = lambda: self.showAbout())
self.closeButton.pack()
self.about.geometry("%dx%d+%d+%d" % (175,\
95,\
self.myParent.winfo_rootx()+self.myParent.winfo_width()/2-75,\
self.myParent.winfo_rooty()+self.myParent.winfo_height()/2-35))
self.about.resizable(0,0)
self.aboutOpen=1
self.about.protocol("WM_DELETE_WINDOW", lambda: self.showAbout())
self.closeButton.focus_force()
self.contact.bind('<Leave>', self.contactMouseOver)
self.contact.bind('<Enter>', self.contactMouseOver)
self.contact.bind('<Button-1>', self.mailAuthor)
else:
self.about.destroy()
self.aboutOpen=0
def contactMouseOver(self,event):
if event.type==str(7):
self.contact.config(font=("Helvetica", 10, 'underline'))
elif event.type==str(8):
self.contact.config(font=("Helvetica", 10))
def mailAuthor(self,event):
import webbrowser
webbrowser.open('mailto:adress@gmail.com',new=1)
以下是tkinter中禁用“最大化”和“最小化”选项的两种方法
请记住,图中所示按钮的代码并不是示例,因为这是关于如何使max/min选项卡不起作用或如何删除的解决方案
一般来说,WM(window manager)决定显示什么样的装饰不能由Tkinter这样的工具包轻松决定。所以让我总结一下我知道的以及我发现的:
对于根窗口以外的
Toplevel
窗口,还可能执行以下操作:这将删除最小/最大按钮,但也取决于窗口管理器。从我读到的内容来看,MS-Windows-WM确实删除了它们。
相关问题 更多 >
编程相关推荐