I am working with python and gtk. There is a checker thread, which looks for variables. If all conditions are ok, it should raise an event to the gtk.main loop. The raised event should open a window and start some other things.
its something like this:
if x==True and y==True:
raise event
def event:
newWindow()
Please give a code example how to implement this
gtk events always have a target. You cannot send an event "to the main loop". Most targets are widgets. You can:
The first option makes most sense to me. I included the second just to tell you that it can be done (it most resembles what you ask for). The third may be useful if you are working with multiple threads or processes, and it is important to you which thread or process does the window creation.
So.. got it done by myself.
the code is easy:
import gobject
class XX(gobject.GObject):
# define signal parameters
__gsignals__ = { 'signal-name' : (gobject.SIGNAL_RUN_FIRST, gobject.SIGNAL_TYPE_NONE, ())}
gobject.__init__(self)
def __init__(self):
# some code
def function(self):
# emit signal
self.emit('signal-name')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.