473,509 Members | 7,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'modal dialogs' with Tkinter

I'd like to have a function f such that, when f is invoked, a Tk
window w is presented in which a number of variables can be modified,
and f returns the values that are indicated by the relevant
menus/checkbuttons/etc at the time w gets closed. I've tried various
ways of doing this, without success. Any assistance would be greatly
appreciated.

Peace,
Sean McIlroy
Jul 18 '05 #1
3 9514
On 22 Feb 2005 06:03:14 -0800, Sean McIlroy <se**********@yahoo.com> wrote:
I'd like to have a function f such that, when f is invoked, a Tk
window w is presented in which a number of variables can be modified,
and f returns the values that are indicated by the relevant
menus/checkbuttons/etc at the time w gets closed. I've tried various
ways of doing this, without success. Any assistance would be greatly
appreciated.


Here are the necessary ritual incantations to create a modal dialog with Tkinter:

dlg = Toplevel()
# ... build the window ...
## Set the focus on dialog window (needed on Windows)
dlg.focus_set()
## Make sure events only go to our dialog
dlg.grab_set()
## Make sure dialog stays on top of its parent window (if needed)
dlg.transient(parentWdw)
## Display the window and wait for it to close
dlg.wait_window(dlg)

The callbacks for your "OK", "Cancel" or whatever buttons you want to use should then call dlg.destroy(). This will terminate the wait_window call and continue the execution of the code after it.

HTH
- Eric Brunel -
Jul 18 '05 #2
Sean McIlroy wrote:
I'd like to have a function f such that, when f is invoked, a Tk
window w is presented in which a number of variables can be modified,
and f returns the values that are indicated by the relevant
menus/checkbuttons/etc at the time w gets closed. I've tried various
ways of doing this, without success. Any assistance would be greatly
appreciated.


does the approach described here work for you?

http://www.pythonware.com/library/tk...og-windows.htm

(note that the tkSimpleDialog module is included in Python's standard library)

if it doesn't work, what doesn't work as required/expected?

</F>

Jul 18 '05 #3
You could try using: EasyGUI http://www.ferg.org/easygui/

EasyGUI is different from other GUIs in that EasyGUI is NOT
event-driven. It allows you to program in a traditional linear fashion,
and to put up dialogs for simple input and output when you need to. If
you have not yet learned the event-driven paradigm for GUI programming,
EasyGUI will allow you to be productive with very basic tasks
immediately. Later, if you wish to make the transition to an
event-driven GUI paradigm, you can do so with a more powerful GUI
package such as anygui, PythonCard, Tkinter, wxPython, etc.

It works for me and is easy to modify to your needs.

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3610
by: Patrick Lim | last post by:
Here is the problem: I have written a non-modal frame class in Java for displaying help text when a user is using an application. It works as desired in that if the user selects "help" again,...
2
4335
by: Sean Burns | last post by:
Hello, does anybody know how to open a dialog window in opera? I use window.showModalDialog(....) for IE but Opera says "Expression did not evaluate to a function object: window.showModalDialog"...
1
2836
by: Emma | last post by:
Hi, I didn't know whether it was best to post this here or on a mozilla-specific newsgroup, but I figured that you have all helped me in the past, so this is a good place to start. I have...
2
2544
by: cassidyc | last post by:
Hi, I was wondering if anyone has come accross this issue? And if they have any solutions I have that can create new copies of itself Form1 as = new form1(); af.show(); This form can also...
2
4924
by: Ricky K. Rasmussen | last post by:
Hi NG, We have a rather large ASP.NET application that uses popups to display various dialogs to the user. In our work we've come over a rather annoying "bug": If we open a modal dialog using...
6
1748
by: Lisa | last post by:
I have an aspx page that has a print button on it. The code for the Clicked Event of the Print button is: Dim strScript As String strScript = "<script language='javascript'>" strScript +=...
1
1381
by: wendy | last post by:
I have got a problem while using the modal dialogs. In my code I need to open a modal dialog from the parent page and I need to enter some values in the dialog and save it. It takes the values...
1
1395
by: VBTricks.de.vu Webmaster | last post by:
Hello there, I've encountered some strange behaviour. I display modal dialogs (using ShowDialog) called from my mainform. This is how the mainform is displayed out of the main sub of a module: ...
1
3546
by: Mohit | last post by:
Hi all, I am working on a windows based client server application with multiple forms. All forms are having custom title bars with no default bars. There is one main form. Some forms are opened up...
0
7347
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7073
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4732
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.