I want to fully customize my app so I created a title bar and figured out a way to drag it around but now my issue is that it's lacking features, like resizing and animations of sorts, I was wondering if it's possible to just get rid of the title bar with some library? or perhaps one that could restore some of the functionality and allow me to not have to use overrideredirect every time i want to hide the window?
the first option is better tho, I did use ctypes.windll
to get the window back into the taskbar, but it also does not appear te be the most practical solution.
the code so far looks something like this:
import tkinter as tk
from ctypes import windll
GWL_EXSTYLE = -20
WS_EX_APPWINDOW = 0x00040000
WS_EX_TOOLWINDOW = 0x00000080
WS_BORDER = 0x00800000
class Application(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self.overrideredirect(True)
self.after(10, self.setup_window)
self.geometry('1000x500+500+250')
self.app_hidden = False
self.bind('<Expose>', self.show_app)
# for full customization im using different widgets as buttons
# lets assume its on the custom title bar
text = tk.Label(self, width=10, height=2,
bg='blue', text='close', foreground='white')
text.pack()
text.bind('<ButtonPress-1>', self.hide_app)
# taken from another post
def setup_window(self, t: int = 10):
hwnd = windll.user32.GetParent(self.winfo_id())
style = windll.user32.GetWindowLongPtrW(hwnd, GWL_EXSTYLE)
style = style & ~WS_EX_TOOLWINDOW
style = style | WS_EX_APPWINDOW
res = windll.user32.SetWindowLongPtrW(hwnd, GWL_EXSTYLE, style)
self.wm_withdraw()
self.after(t, self.wm_deiconify)
def hide_app(self):
if not self.app_hidden:
self.overrideredirect(False)
self.iconify()
self.app_hidden = True
def show_app(self, event):
if self.app_hidden:
self.overrideredirect(True)
self.setup_window()
self.app_hidden = False
if __name__ == '__main__':
app = Application()
app.mainloop()
what I want is to be able to either get back the border, Iv'e tried doing it by adding
WS_BORDER = 0x00800000
...
def setup_window(self):
...
style = style | WS_BORDER
...
But it didn't work, and i would also like to not have unnecessary bindings that already exist, so the main question is whether it's possible to overrideredirect
without overrideredirect
, if there's some library out there that is capeable of interacting with the default windows maneger on high level?