1

I'm using the latest version of Mac OS, and Python 3.9. I tried using the overrideredirect to delete the title bar and add my own. However, the result does not show the window. The app is seen in the dock, and the menu bar. But it is not displayed.

My code:

from tkinter import *

root = Tk()

def move_window(event):
    root.geometry('+{0}+{1}'.format(event.x_root, event.y_root))

root.overrideredirect(True) 
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>', move_window)

root.mainloop()

The same code works well in windows.

Thanks in advance! :)

  • 1
    Try [this](https://stackoverflow.com/a/66194808/11106801) code and tell me if it works. Does MacOS support `self.root.attributes("-type", "splash")`? – TheLizzard May 06 '21 at 10:59

1 Answers1

0

On Macs, we need two calls of overrideredirect to remove the border.
Do it like this:

root.overrideredirect(False)
root.overrideredirect(True)

But note that certain events might fail to bind properly, per this post

Andy Zhang
  • 198
  • 4
  • 21