微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何更改 tkinter Mac OS X 中的标题栏?

如何解决如何更改 tkinter Mac OS X 中的标题栏?

我在 Stackoverflow 中看到了许多问题,他们提出了与我类似的问题 this。但是他们都没有解释如何在 Mac OS X 中更改标题栏。我在 Mac OS 中使用 python 3.9。

但是,这在 Mac 中不起作用。该应用程序显示在停靠栏和菜单栏中,但未显示

代码来自 This link 也不起作用。

有什么办法可以做到这一点吗?

提前致谢!

解决方法

希望这能回答你的问题 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(以及我这边的小改动)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。