1 year ago

#374693

test-img

mijorus

Gtk how to bring my app to foregrout when it is minimized or in another workspace

I am trying to develop a simple Gtk app which should be launched with a custom shortcut. Right now, I call the following methods to present the window to the user:

# if the user executes the same shortcut but another instance is already opened, we skip this part
 if not self.window:
            # when the last one is closed the application shuts down
            self.window = MyCustomClass()

self.window.show_all()
self.window.present()

however, if the app is minimized in another workspace it is maximized but doesn't get the focus.

Do you know how I can fix this?

EDIT ✅:

I ended up using Wnck, which if you are building a flatpak is not included by default in the runtime: you can compile it from source like this.

Then, I use the name of my app + the name of the icon (just to be sure) to move my app around.

https://lazka.github.io/pgi-docs/#Wnck-3.0/classes/Window.html#Wnck.Window.move_to_workspace

python

gtk

gtk3

pygtk

pygobject

0 Answers

Your Answer

Accepted video resources