473,396 Members | 1,726 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,396 software developers and data experts.

[Python+glade] why need two arguments?

hi,everyone.

I am a python newbie.and I write a python program with glade,as following:
Expand|Select|Wrap|Line Numbers
  1. import sys
  2. import gtk
  3. import gtk.glade
  4.  
  5. class TLaitSignals:
  6.     '''Define TLait singals handler'''
  7.     def test(self):
  8.         return self.signals_dict
  9.     def on_BtnBack_clicked(self):
  10.         gtk.main_quit()
  11.     def on_BtnForward_clicked(self):
  12.         pass
  13.     def gtk_widget_destroy(self):
  14.         gtk.main_quit()
  15.         #sys.exit(0)
  16.     def __init__(self):
  17.         self.signals_dict = {"gtk_widget_destroy" : self.gtk_widget_destroy,}
  18.  
  19. if __name__ == "__main__":
  20.     gladexml = gtk.glade.XML("ui/TLait-first.glade")
  21.     gladexml.signal_autoconnect(TLaitSignals().test())
  22.     mainWin = gladexml.get_widget("tlait_selectAppVer")
  23.     mainWin.set_default_size(800,600)
  24.     mainWin.show()
  25.     gtk.main()
  26.  
  27.  
when I clicked close button,it report "TypeError: gtk_widget_destroy() takes exactly 1 argument (2 given)" info.

if I add any argument to gtk_widget_destroy() ,for example:
def gtk_widget_destroy(self,sfsadfsadfs):
then it will execute successful. So I don't why need two arguments,where define to need two arguments?
thanks very much!
Aug 27 '09 #1
5 2546
micmast
144 100+
usually the second argument is the widget that did the original call. You could play with the second argument, print it, and view what is in it.
Aug 27 '09 #2
micmast,thanks for your reply.
I print it,as following:
<gtk.Dialog object at 0xa0a2dc4 (GtkDialog at 0xa158860)>

but I can't find any define of about gtk.Dialog class, any help will be appreciate.
Aug 28 '09 #3
I'm not entirely sure about this as I am a wx user not a gtk user, however, it looks as though gtk_widget_destroy is an event/signal. Of course the first argument is self, while the second (as micmast said) is usually an instance of the widget that called it.

This is useful for various things, for example if the user entered some data in a dialog, with this method, as it is destroyed you could look up the value of the data entered using the second argument. Make sense? Of course you don't always need to access the calling widget, so the second argument might not come into play.

To summarize, the second (widget instance) argument is there only if you need it, otherwise just ignore it! :)

Hope this helps.

P.S. Here is the doc for gtk.Dialog (Google is your friend.)
Aug 28 '09 #4
Markus
6,050 Expert 4TB
Not a python guy, but could that trailing comma on line #17 be causing the error (passing a null 2nd argument?)?
Aug 28 '09 #5
I see,thanks Hackworth for your explanation,thanks everybody again.
Aug 31 '09 #6

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

Similar topics

0
by: Ton K. | last post by:
Folks, I'm planning to build MIDI sysex tools in Python on Windows 98SE. I need a simple read/write to MIDI interface, preferably with a read callback integrated with the Tkinter event loop. I...
1
by: Don Bruder | last post by:
Greetings, oh scaly ones... :) I'm a Mac user with a fairly high level of computer literacy, including reasonable programming skills in BASIC, C, Pascal, and several flavors of ML, just trying...
5
by: Jonathon McKitrick | last post by:
Hi all, I am totally hooked on what I have learned about python. I am going to use it to develop a simple data entry app I need for some financial record keeping. I understand tkinter is...
2
by: Al Dykes | last post by:
I'm looking for info on programming with glade on python, and maybe some sample code to hack. I've got python installed, but need a howto for glade and google doesn't help me. Any suggestions ?
2
by: Benji99 | last post by:
Hi guys, I'm starting to learn Python and so far am very impressed with it's possibilities. I do however need some help with certain things I'm trying to do which as of yet haven't managed to find...
5
by: somesh | last post by:
hello, I wrote a small tute for my brother to teach him python + glade, plz see, and suggest to make it more professional , In tute I discussed on Glade + Python for developing Applications too...
0
by: Jon Monteleone | last post by:
Greetings, I posted a few days back and didnt get much of a response, so I figured I would post again with more detail. I am running gnome under fedora core 4. I want a kid to be able to drop a...
6
by: Doug | last post by:
Hi all, Can someone tell me why I do not get a connection between the events and the functions in the sample below. GUI window appears OK, just no connections seem to be made. I am new to this...
2
by: PapaRandy | last post by:
Hello, I am trying to validate the following .py webpage as HTML (through W3C). I put: ----------------------------------------------------------------------------- print "Content-type:...
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:
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
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,...

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.