问题描述
我在 Stackoverflow 中看到了许多问题,他们提出了与我类似的问题 this。但是他们都没有解释如何在 Mac OS X 中更改标题栏。我在 Mac OS 中使用 python 3.9。
但是,这在 Mac 中不起作用。该应用程序显示在停靠栏和菜单栏中,但未显示。
有什么办法可以做到这一点吗?
提前致谢!
解决方法
希望这能回答你的问题 https://docs.python.org/3/library/tkinter.html
nums_map.empty()
,
经过一番研究,我找到了方法:
from tkinter import *
root = Tk()
def get_pos(event):
xwin = root.winfo_x()
ywin = root.winfo_y()
startx = event.x_root
starty = event.y_root
ywin = ywin - starty
xwin = xwin - startx
def move_window(event):
root.geometry("400x100" + '+{0}+{1}'.format(event.x_root + xwin,event.y_root + ywin))
startx = event.x_root
starty = event.y_root
title_bar.bind('<B1-Motion>',move_window)
root.overrideredirect(1)
root.overrideredirect(0)
root.geometry('400x100+200+200')
title_bar = Frame(root,bg='white',relief='raised',bd=2)
close_button = Button(title_bar,text='X',command=root.destroy)
window = Canvas(root,bg='black')
title_bar.pack(expand=1,fill=X)
close_button.pack(side=RIGHT)
window.pack(expand=1,fill=BOTH)
title_bar.bind('<B1-Motion>',get_pos)
title_bar.bind('<Button-1>',get_pos)
root.mainloop()
注意:此代码来自this link(以及我这边的小改动)