hi,everyone.
I am a python newbie.and I write a python program with glade,as following: -
import sys
-
import gtk
-
import gtk.glade
-
-
class TLaitSignals:
-
'''Define TLait singals handler'''
-
def test(self):
-
return self.signals_dict
-
def on_BtnBack_clicked(self):
-
gtk.main_quit()
-
def on_BtnForward_clicked(self):
-
pass
-
def gtk_widget_destroy(self):
-
gtk.main_quit()
-
#sys.exit(0)
-
def __init__(self):
-
self.signals_dict = {"gtk_widget_destroy" : self.gtk_widget_destroy,}
-
-
if __name__ == "__main__":
-
gladexml = gtk.glade.XML("ui/TLait-first.glade")
-
gladexml.signal_autoconnect(TLaitSignals().test())
-
mainWin = gladexml.get_widget("tlait_selectAppVer")
-
mainWin.set_default_size(800,600)
-
mainWin.show()
-
gtk.main()
-
-
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!
5 2546
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.
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.
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.)
Not a python guy, but could that trailing comma on line #17 be causing the error (passing a null 2nd argument?)?
I see,thanks Hackworth for your explanation,thanks everybody again.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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 ?
|
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...
|
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...
|
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...
|
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...
|
by: PapaRandy |
last post by:
Hello,
I am trying to validate the following .py webpage as HTML (through
W3C).
I put:
-----------------------------------------------------------------------------
print "Content-type:...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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: 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,...
| |