TimerX
TimerX copied to clipboard
App doesn't redraw on unmaximize properly
@sumeshir26 i see, you copied this part from Tukaan, but did you ever test it? (No). This code won't work as it is.
https://github.com/Futura-Py/TimerX/blob/f1a83751a3f0ba2e334a48cc2c4b3b7be33408e2/main.py#L62-L69
tkinter.Tk (app in this case) doesn't have neither _dwm_set_window_attribute, DWMWA_TRANSITIONS_FORCEDISABLED, minimize nor restore attribute.
In tkinter you should use iconify instead of minimize and deiconify instead of restore.
Instead of _dwm_set_window_attribute and DWMWA_TRANSITIONS_FORCEDISABLED you can use these two snippets:
# To disable transitions
true_value = ctypes.c_int(1)
ctypes.windll.dwmapi.DwmSetWindowAttribute(app.wm_frame(), 3, ctypes.byref(true_value), ctypes.sizeof(true_value))
# To enable transitions again
false_value = ctypes.c_int(0)
ctypes.windll.dwmapi.DwmSetWindowAttribute(app.wm_frame(), 3, ctypes.byref(false_value), ctypes.sizeof(false_value))
So the full function should look like this:
def fullredraw(e):
global prev_state
if prev_state == "zoomed":
true_value = ctypes.c_int(1)
ctypes.windll.dwmapi.DwmSetWindowAttribute(app.wm_frame(), 3, ctypes.byref(true_value), ctypes.sizeof(true_value))
app.iconify()
app.deiconify()
false_value = ctypes.c_int(0)
ctypes.windll.dwmapi.DwmSetWindowAttribute(app.wm_frame(), 3, ctypes.byref(false_value), ctypes.sizeof(false_value))
prev_state = app.state()
I realized that, but I forgot to fix it before commiting. Fixing now... Thanks for reporting!
Well, it iconifies and deiconifies, but it turns out thta on Windows 11, the expose function gets called about 25 times with the prev_state as zoomed (Probably due to te smooth animation that playes while unmaximizing) and the animations dont get disabled properley, so my entire PC became unusable due to TimerX maximizing and unmaximizing, then the expose function gets called again due to the window showing up again and I couldent even click end task on taskmanger so I literallay had to restart my pc
Any idea on how to fix this?
Uhh, stange. Try binding to <Configure>.
Also, I updated the function (unindent the last line) because prev_state would have been updated only the first time the window was unmaximized (and not anymore), which could cause problems.
def fullredraw(e):
global prev_state
if prev_state == "zoomed":
true_value = ctypes.c_int(1)
ctypes.windll.dwmapi.DwmSetWindowAttribute(app.wm_frame(), 3, ctypes.byref(true_value), ctypes.sizeof(true_value))
app.iconify()
app.deiconify()
false_value = ctypes.c_int(0)
ctypes.windll.dwmapi.DwmSetWindowAttribute(app.wm_frame(), 3, ctypes.byref(false_value), ctypes.sizeof(false_value))
prev_state = app.state()
Yeah, I also did that, will try soon
Configure does not work either, it just keeps maximizing and unmaximizing
What if you could control the minimum number of resizes? Maybe only once or twice, nothing more.