focus_force
PySimpleGUI opened this issue · comments
I saw one place that directly called tkinter:
def show_gui(self):
self.window.un_hide()
self.window.TKroot.focus_force() # force window to be focused
self.hidden = False
There's a function in PySimpleGUI to do this for you so you don't have to invoke any tk calls directly.
self.window.force_focus()
I believe I tried using self.window.force_focus()
, but I just get this:
AttributeError: 'Window' object has no attribute 'focus_force'
I'm on Python 3.9.1 in Windows with PySimpleGUI 4.38.0 (same issue with 4.34.0).
Yes, I'm sure you in fact got that error because the Window
object indeed does not have focus_force
The line of code I included in the comment was this one:
self.window.force_focus()
Words are flipped in this particular call.
I generally have method names, functions, that follow the format of verb_noun. Like set_alpha, instead of alpha_set.
In addition to the call reference, which is searchable with a Control+F
https://pysimplegui.readthedocs.io/en/latest/call%20reference/#window
you might find the built-in help to be useful for these kinds of things too.
Call main_sdk_help()
Or, you can call sg.main()
and choose the SDK Reference button
If you click "Summary Only", then you'll get just the list of methods, properties. There is also an active link at the bottom of this window to the call reference for the object you're looking at.
In the case, of the Window object, note the same link as the one I provided above. It's just a quick way to get to the same info. Clicking it will open your browser.
I hope you don't mind that I posted a Tweet today about your project. I'm sure other users will find it as inspirational as I have!
Oh I didn't realize the words were flipped! Everything's working now.
I didn't know about sg.main
; I'll definitely be using that in the future.
Thanks for all the support!