israel-dryer / ttkbootstrap

A supercharged theme extension for tkinter that enables on-demand modern flat style themes inspired by Bootstrap.
MIT License
1.99k stars 395 forks source link

Move iconify to before setting alpha (#236) #428

Open laggykiller opened 1 year ago

laggykiller commented 1 year ago

This PR is written to solve #236.

Below is an exerpt from my response the issue:


If self._toplevel is created with iconify=True, then execution is stuck until opening back the window. This is caused by src/ttkbootstrap/window.py Window.init and Toplevel.init:

# Function continue above...

if iconify:
    self.iconify()

# Function continues...

if alpha is not None:
    if self.winsys == 'x11':
        self.wait_visibility(self)
    self.attributes("-alpha", alpha)

# Function continue below...

Linux uses x11 display system. The Window/Toplevel was iconified before setting alpha, which causes wait_visibility() to get stuck until user open back the window. Hence, deiconify() in src/ttkbootstrap/dialogs/dialogs Dialog.build could not be called until user open back the window.

It seems like the visbility check is introduced by https://github.com/israel-dryer/ttkbootstrap/commit/2abfeb464a028196109ba2a353cfb554978c3de6 in response to https://github.com/israel-dryer/ttkbootstrap/issues/108 so removing that check is not an option.


This PR would swap iconify() and set alpha such that alpha is set when 'visbible' before iconifying. Note that iconify() has to be called before self.transient(transient) to avoid error.