Forum: Poser Python Scripting


Subject: Making Dialog box stay on top (automatically return focus?)

Amadan opened this issue on Apr 16, 2009 · 3 posts


Amadan posted Thu, 16 April 2009 at 12:43 PM

So I have created a Tk widget in which you're required to select an output directory. If you press the action button (which performs renders) and you have not yet selected an output directory, it will pop up a warning dialog saying "You must choose an output directory!"

The problem is, after pressing "OK" to banish the warning dialog, my GUI disappears behind Poser's document window. I have to click it in the Windows taskbar or Alt+Tab to it to make it reappear.

Is there a way to make the application's focus automatically return to the main Tk  widget after it's spawned a warning dialog?

ETA: I've also noticed Poser is kind of flaky about displaying Python guis. Even when I do click on the widget in the taskbar, it seems to slow Poser down, take a long time to redraw after being moved, and sometimes I have to click it several times to make it reappear because it keeps disappearing behind the document window again. Is this typical?


Adom posted Sat, 18 April 2009 at 5:51 AM

I learn python from time to time when I want to write simple script for myself so my answer could be wrong.

I found it in python (standalone not poser's python folder):
c:Python24Liblib-tkTkinter.py
open that file and go to the very end of it. You'll see an example with :

    # The following three commands are needed so the window pops
    # up on top on Windows...
    root.iconify()
    root.update()
    root.deiconify()

I personaly use it and it gives me the focus on main window after the script was executed.


nruddock posted Sat, 18 April 2009 at 6:43 AM

The real problem here is that the tkinter main loop isn't integrated with Poser's own.

If you look at other scripts with tkinter GUIs (a lot of ockham's have them) you'll see the technique required to keep a tkinter window above the Poser window.

When using Poser's own dialogs, this problem doesn't arise, but the variety of controls is limited, and you can only have modal dialogs.