GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Dec 19, 2014 1:33 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Two windows
PostPosted: Thu Sep 19, 2013 8:33 pm 
Offline

Joined: Wed Sep 18, 2013 7:43 pm
Posts: 1
I am trying to write a small personal finance program in Python.

To enter a new post, I want the program to create a new window where necessary values are entered. When I click the OK button, the values should be written to the database and the input window should close.

I have tried to do this using a gtk.Dialog, which works but has a small drawback. If I enter something erroneous the Dialog "hangs". The CANCEL button doesn't work any more, and I have no chance to correct the bad value and press OK again. The only thing I can do is using the "destroy" button in the upper right corner to get back to the main window, then create a new Dialog and try not to type something wrong.

Maybe I should create a new toplevel Window instead of a Dialog, but I don't know how to handle that. How to tell the main window that a new post is written to the database? Sending a signal? Seems complicated.

Please send suggestions.


Top
 Profile  
 
 Post subject: Re: Two windows
PostPosted: Fri Sep 20, 2013 6:32 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 799
Location: UK
Hallo,

Without knowing what your code is doing it is very hard to debug.

At a guess what you are doing is creating a GtkDialog, then running it. Once a button is clicked it will return from running the GtkDialog. This is where I expect that you think the Dialog has "hung" as it is not destroyed, hidden or being interacted with any more. The "OK" and "Cancel" buttons should both close the window with "OK" accepting the entered values. I would put another button "Undo" to revert the entries back to their starting values and at this point re-run the GtkDialog.

_________________
E.


Top
 Profile  
 
 Post subject: Re: Two windows
PostPosted: Wed Sep 25, 2013 4:00 am 
Offline
Familiar Face

Joined: Wed Jan 30, 2013 8:28 pm
Posts: 20
A modal GtkWindow would be good here


Top
 Profile  
 
 Post subject: Re: Two windows
PostPosted: Thu Sep 26, 2013 5:28 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 799
Location: UK
nar6du14,

GtkDialog is a GtkWindow that is usually used as a modal window. It has extra features that make this easier such as extra API calls to run the window in modal mode and a button area.

_________________
E.


Top
 Profile  
 
 Post subject: Re: Two windows
PostPosted: Thu Oct 03, 2013 11:33 pm 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
I do not think your dialog window is hanging, but more likely your code transferring the data is hanging preventing a return to the gtk_main loop.
Dialogs are normally run in a new thread by gtk (you can watch this happen by running your program from a terminal prompt) in which case when you kill the dialog it will kill the thread along with the bit of code that is hanging and then gtk can resume as normal.
I don't think there is any issue with your use of the dialog. What you need is better error checking and handling with what you're sending to the database.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group