3

I am new to Python GTK programming. In my UI i have a button. On click of that i have to open a popup which has a three button and some label. I have to pass some variables from main window to popup window. on click of buttons on the popup window I have to update this variable. Then once i close this popup window I need the updated value of the variables in main window. 1. Can I do this in Python GTK. 2. If yes how will i go about achieving it. 3. Can I use glade file for creating a glade file.

1 Answer 1

6

You probably need dialog boxes.

From pygtk :

 import gtk

 label = gtk.Label("Nice label")
 dialog = gtk.Dialog("My dialog",
                    None,
                    gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                    (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                     gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
 dialog.vbox.pack_start(label)
 label.show()
 checkbox = gtk.CheckButton("Useless checkbox")
 dialog.action_area.pack_end(checkbox)
 checkbox.show()
 response = dialog.run()
 dialog.destroy()
Sign up to request clarification or add additional context in comments.

6 Comments

thanks Louis, this was great help. what i want is little bit like what you meant. but as I am new to python and also gtk, just wanted to know if we can stop closing of popup window on clicking action button
skalluraya, i'm happy to have helped. Now I do not understand what you mean with "if we can stop closing of popup window on clicking action button" - Which action button do you want to use to close ? Il the exemple above, the setting is DIALOG_MODAL, this means that the popup stays on top and that you must close it before accessing other windows of your app. Now, every button showed in the dialog box will close it, just giving you a different "response", that you can test and use in your app to act differently. Enjoy !
Louis, Thanks for the reply. "if we can stop closing of popup window on clicking action button" By this i mean Suppose i have 2 buttons on the dialog(Retry, Cancel). Now what is happening is when i click retry and cancel the dialog closes. I dont want to close the dialog when i click the retry. I want to change some UI on the dialog.
Then you'd better use a separate "retry" button into the dialog that is not part of the dialog's answers (that will close the dialog)
"not part of the dialog's answers" what does that mean Louis. How can I do that?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.