473,395 Members | 1,422 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

pygtk closing popup - destroy function doesn't work for button

3
Completely noob question as I am not a programmer but really trying hard to learn Python (Object oriented programming in general).

I am writing a program in python that calls a popup window with some general information with an ok button. If I close the window using the window's close button I have no problems but If I call the same destroy function using the button call, it will not kill the popup.


Expand|Select|Wrap|Line Numbers
  1. def destroy(self, widget, data=None):
  2.         print("Delete event occurred")
  3.         return False
  4.  
  5. self.popup.connect("destroy", self.destroy)
  6.  
  7. self.button_pop.connect("clicked", self.destroy)
  8.  
self.popup.connect("destroy", self.destroy)
is the gtk window and......

self.button_pop.connect("clicked", self.destroy)
is the button widget in the window. How do I handle this?

z
Feb 25 '09 #1
3 6494
drzoo2
3
I realize this is a really beginner question. I'm really stuck on this. I can't find an answer. Currently I'm hiding the window with a button call to a function that just runs.....

self.popup.hide()

I don't think this is the right way to handle the popup window since the window's close is tied to the destroy function. It works when called from the window but not from the button.

z
Feb 25 '09 #2
micmast
144 100+
I would try to destroy the popup window itself:

for example this is code I used in an application to display errors

Expand|Select|Wrap|Line Numbers
  1. self.errorm = gtk.MessageDialog(parent = self.mainwindow, buttons = gtk.BUTTONS_OK, flags = gtk.DIALOG_MODAL, type = gtk.MESSAGE_ERROR, message_format = "Error occured:\n"+message)
  2.         self.errorm.set_title("Error occured")
  3.         result = self.errorm.run()
  4.         self.errorm.destroy()
  5.  
Feb 25 '09 #3
drzoo2
3
micmast,
Thanks you very much.

I modified this code........
Expand|Select|Wrap|Line Numbers
  1. def destroy(self, widget, data=None):
  2.         print("Delete event occurred")
  3.         return False
  4.  
  5. self.popup.connect("destroy", self.destroy)
  6.  
  7. self.button_pop.connect("clicked", self.destroy)
  8.  
too this.......

Expand|Select|Wrap|Line Numbers
  1. def destroy(self, widget, data=None):
  2.         print("Delete event occurred")
  3.         self.popup.destroy()
  4.  
  5. self.popup.connect("destroy", self.destroy)
  6.  
  7. self.button_pop.connect("clicked", self.destroy)
  8.  
and all is well. All I added was self.popup.destroy(). I swear I tried that! This has been haunting me for a week. I just couldn't get it. Your help is very much appreciated.......back to coding.

z
Feb 26 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Samuele Giovanni Tonon | last post by:
hi, i'm trying to develop a trivial application which random copy files from a directory to another one. i made it using pygtk for the graphical interface, however i find some problem with...
0
by: Johan | last post by:
Hello! I'm trying to figure out how to use PYGTK to implement a rudimentary UI: I want to have an Image as the background, and then be able to put buttons (eventually icons, but buttons for...
3
by: Steve | last post by:
Hi, I have a nice little script that works well displaying images on my website. It's a script where if you clik a thumbnail image a pop up window opens that contains a larger version of the same...
1
by: MJEASSOC | last post by:
I need some help with closing a popup window. I'm making an online portfolio, that has one base page with text and thumbnails. When a user clicks on a thumb, a new window opens containing a larger...
0
by: kingcrowbar.list | last post by:
Hello Everyone I have been playing a little with pyGTK and threading to come up with simple alert dialog which plays a sound in the background. The need for threading came when in the first...
10
by: jubei | last post by:
I've been trying to write a custom widget for a project, however when i try to run code that uses it i get the following error > ./nokiagui.py Traceback (most recent call last): File...
4
by: Macbane | last post by:
Hi, I have a 'main' form called frmIssues which has a subform control (named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs. A control button on the main form opens a pop-up form...
5
by: xrado | last post by:
when i say window.hide(), window dont hide imidetly i want to hide it for a few seconds, do something and then show it back how can i do this? i have this example: import pygtk,time...
2
by: Laharl | last post by:
I'm working in pyGTK (completely new to it) and I need to display a tic-tac-toe board. It doesn't have to keep track of the game state, just place Xs and Os on click. Unfortunately, I can't get all 9...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...

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.