473,669 Members | 2,460 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 9545
On 22 Feb 2005 06:03:14 -0800, Sean McIlroy <se**********@y ahoo.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(p arentWdw)
## 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
3625
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, the same frame is used -- this is done using a singleton. The user can do other stuff in the main window while the help window is up. However, when I have a modal dialog pop-up to get information from the user, it blocks events to the help...
2
4342
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" Thanks. Sean.
1
2856
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 trawled the newsgroups for information on opening a modal dialog in Mozilla. I am using Mozilla 1.6 and have found that the following piece of code should work:- var w = window.open('http://www.hotmail.com', '_blank', 'modal');
2
2555
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 bring up a modal dialog (MessageBox)
2
4933
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 the javascript command window.showModalDialog() we loose the current Session if a new window is opend from within the modal one (using the window.open() method). The "funny" thing is that this only occurs if another instance of IE has been
6
1753
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 += "window.print();" strScript += "</script>" Page.RegisterStartupScript("print", strScript)
1
1387
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 properly and also does the validation of the values but it doesn't hit the event handler of the button where it is supposed to save those values and close the box. Any help is appreciated. Thanks
1
1399
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: Public fMain As frmMain Public Sub Main() Try
1
3562
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 as modal while others are opened up as modeless on this main form. Whenever some error occurs in client server communication we show it in modal message box. Now I ran into a case: a modal form is opened up on the main form. And some error...
0
8895
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8588
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6210
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4386
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2797
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.