Frage

I have a main window in tcl tk named .dsm. This main window has two notebook tabs f1 and f2. When the user clicks a "run" button on the second tab, I want to activate the first tab and ask the user to verify the input before continuing. My problem is, that when the message box asking the user to check the input pops up, the .dsm window is minimized. How can I prevent this, so that the user can see both the messagebox and the main window? I tried "raise", but then the messagebox is dissapears out of sight...

# activate the first notebook tab "f1"
.dsm.nb select .dsm.nb.f1
# Ask the user
set answer [tk_messageBox \
        -message "Are these the setting you want to use for the batch run?" \
        -type okcancel]
War es hilfreich?

Lösung

The behaviour you describe is not a feature of Tk in any default configuration; it doesn't minimize other windows when you use any of the standard dialogs on any platform. It might be possible to write a script that did it by tracking and abusing events like <Focus>, <Leave> or <Deactivate>, etc., but it would be ugly and non-portable. And bad user-interface design. (If anyone is thinking of trying to do this, DON'T DO IT!)

You might be able to fix things by specifying the -parent option to be the window that you don't want to disappear (which marks the message box as being a helper window for that main one) but that can have visual effects too. Otherwise, you're probably going to have to work out what event handler is picking up on the message box and responding in an unexpected way. It shouldn't be any of the widget class handlers — they don't do this sort of thing — but you might have quite a large search ahead of you. Things to be particularly aware of are interactions between several event handlers where some are defined at different bind-tag levels. (You probably don't ever want to define behaviour at any levels other than widget and containing-toplevel; writing truly general controller scripts is very difficult, whereas making them work right for a particular widget or window is much simpler.)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top