Hi.
I am a spanish programmer and I start with pyGtk.
And I try to make a example that it is a simple window that blink a
button with two colours, for test events and threads. But I don't know
how to send custom event.
This is the source code:
--------------------------------------------------------------------
import pygtk
pygtk.require('2.0')
import gtk
import time
import thread
class test:
def __init__(self):
self.toggle = False
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title("Test")
self.window.set_border_width(10)
self.window.connect("destroy", self.destroy)
#I want to
#self.window.connect("custom_event", self.custom_event)
self.button = gtk.Button("Button")
self.button.connect("clicked", self.clicked, None)
self.window.add(self.button)
self.button.show()
self.window.show()
thread.start_new_thread(self.mThread, ())
def destroy(self, widget, data=None):
gtk.main_quit()
def main(self):
gtk.main()
def clicked(self, widget, data):
print "Clicked event"
def custom_event(self, widget, data):
if self.toggle:
self.button.modify_bg(gtk.STATE_NORMAL,
gtk.gdk.Color(65535,0,0))
else:
self.button.modify_bg(gtk.STATE_NORMAL,
gtk.gdk.Color(0,65535,0))
def mThread(self):
while True:
print "Thread"
#self.emit('custom_event')
time.sleep(5)
if __name__ == "__main__":
test = test()
test.main()
--------------------------------------------------------------------
Bye and thanks.
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/