python没有tkinter_没有标题b的python tkinter还原窗口

这取决于您使用的操作系统。如果您使用的是Windows,下面的解决方案应该适用于您。在

我添加了一个函数,它将重新应用overriderdirect。这个函数被我们在根目录上使用的绑定调用。在

我还把你的画布改成了一个框架,因为这样更容易管理按钮之类的东西。在

对于linux,您可能需要使用不同的文件类型。你可能需要在windows和windows上使用。在

更新:

我已经添加了iconbitmap和root.tk.call('wm', 'iconphoto', root._w, icon),但是我不确定你是否能够改变你的任务栏图标,直到你至少在windows中编译代码。您可以使用py2exe或freeze。我以前用过freeze,我有一个客户桌面和任务栏图标。在import tkinter as tk

root = tk.Tk()

root.geometry("400x400")

root.overrideredirect(1)

root.resizable(False, False)

root.columnconfigure(0, weight=1)

root.iconbitmap(default='./Colors/small_red.ico')

def close():

root.destroy()

def minimizeWindow():

root.withdraw()

root.overrideredirect(False)

root.iconify()

def check_map(event): # apply override on deiconify.

if str(event) == "":

root.overrideredirect(1)

print ('Deiconified', event)

else:

print ('Iconified', event)

bar_frame = tk.Frame(root)

bar_frame.grid(row=0, column=0, sticky="ew")

bar_frame.columnconfigure(0, weight=1)

icon = tk.PhotoImage(file='./Colors/small_red.gif')

# This appears to have the same results so not sure what the difference is from iconbitmap.

# root.tk.call('wm', 'iconphoto', root._w, icon)

tk.Button(bar_frame, text='x', command=close).grid(row=0, column=1)

tk.Button(bar_frame, text='-', command=minimizeWindow).grid(row=0, column=2)

root.bind('', check_map) # added bindings to pass windows status to function

root.bind('', check_map)

root.mainloop()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值