Skip to content

App doesn't redraw on unmaximize properly #103

@rdbende

Description

@rdbende

@sumeshir26 i see, you copied this part from Tukaan, but did you ever test it? (No). This code won't work as it is.

TimerX/main.py

Lines 62 to 69 in f1a8375

def fullredraw(e):
global prev_state
if prev_state == "zoomed":
app._dwm_set_window_attribute(app.DWMWA_TRANSITIONS_FORCEDISABLED, 1)
app.minimize()
app.restore()
app._dwm_set_window_attribute(app.DWMWA_TRANSITIONS_FORCEDISABLED, 0)
prev_state = app.state()

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()

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions