Tkinter Window focusing on KDE manjaro

I am attempting to bring a tkinter window to focus but can’t seem to get it to move forward. A snippet of the code below:

  def player_file_manager(self):
      if not self.pfm_running:
          self.pfm_running = True
          self.pfm_root = Tk()
          self.pfm_root.protocol("WM_DELETE_WINDOW", self.player_file_manager_quit)
          PlayerFileManager(self.pfm_root, self.player_file_dir).start()
      else:
          # method 1
          self.pfm_root.attributes('-topmost', 1)
          self.pfm_root.attributes('-topmost', 0)
          # method 2
          self.pfm_root.lift()
          # method 3
          self.pfm_root.tkraise(self.root)

  def player_file_manager_quit(self):
      self.pfm_root.destroy()
      self.pfm_root.quit()
      self.pfm_running = False

I have tried the above 3 methods, and none seem to bring the window to the front or even focus it. Method 2 makes the application icon on the taskbar flash as if it has been focused. I’m unsure if this is a bug or if I’m using some platform-dependent code.

The forum is Manjaro Linux Community - a user community - not a programming community.

Your topic is far too generic and - to me - look like homework - I suggest you read the manual https://www.tcl.tk

I posted this here as I believe this bug may be specific to KDE Manjaro. This post is less about what method to use and more about how it is reproducible. I am past the point of doing homework in my life and - to me - that is an unnecessary comment and part of the reason why more people are moving to generative tools. Specific Tkinter interactions are somewhat discussed here but more along the lines of installation issues.

Then it would be applicable to any Arch derived system and to Arch itself.

Sorry for the homework comment - but we have a policy about homework Forum Rules - Manjaro thus the comment.

It is quite an uncommon topic to raise for an account just created.

Still the documentation is your best hope toplevel manual page - Tk Built-In Commands

If I need to do some Python GUI of any kind I am using pyside6 or pyqt6.

I appreciate the response and was not aware of pyqt6 and am now looking into it. I feel as if Tkinter is slowly being deprecated anyway and it may to time to start doing simple GUI work with something more modern. Thank you.

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.