Note that there are some explanatory texts on larger screens.

plurals
  1. POContinuing code execution after a pygtk.main() in python
    primarykey
    data
    text
    <p>I have an application where my DataFetch() class "Wraps" around my HBHTray() class for the purpose of interacting with the functions/variables of that class. Unfortunately, I can't seem to be able to get the code to continue execution after my DataFetch() class makes a instance of HBHTray and calls it, and on the Start() method of HBHTray it hangs.</p> <p>This is the relevant code:</p> <p><pre><code> class DataFetch(): # I need the DataFetch class to be wrapping around HBHTray so I can call/edit certain variables from within functions in DataFetch def <strong>init</strong>(self): self.Interval, self.Username, self.Password, self.CheckShoutBox = GetOptions('.tray') self.Gui = HBHTray() print '1' self.Gui.Start() print '2' def Login(self): pass # Do stuff (Eg: Edit self.Gui.StatusIcon state or call self.Gui.Notify() def Start(self): print 'hi!' sleep(self.Interval) print 'Hi!' class HBHTray(): def <strong>init</strong>(self): self.StatusIcon = gtk.StatusIcon() self.StatusIcon.set_from_file('img') self.StatusIcon.set_tooltip('No new messages') self.Menu = gtk.Menu() self.CheckBox = gtk.CheckMenuItem('Notify') self.CheckBox.connect('activate', self.ChangeCheckBox) self.CheckBox.set_active(True) self.Menu.append(self.CheckBox) self.MenuItem = gtk.ImageMenuItem('Options') self.MenuItem.connect('activate', self.Options, self.StatusIcon) self.Menu.append(self.MenuItem) self.MenuItem = gtk.ImageMenuItem('About') self.MenuItem.connect('activate', self.About, self.StatusIcon) self.Menu.append(self.MenuItem) self.MenuItem = gtk.ImageMenuItem('Quit') self.MenuItem.connect('activate', self.Quit, self.StatusIcon) self.Menu.append(self.MenuItem) self.StatusIcon.connect('popup-menu', self.PopMenu, self.Menu) self.StatusIcon.set_visible(1) def PopMenu(self, widget, button, time, data = None): if data: data.show_all() data.popup(None, None, gtk.status_icon_position_menu, 3, time, self.StatusIcon) def Notify(self, message): pynotify.init('null') notification = pynotify.Notification('Something', message, 'dialogue') notification.attach_to_status_icon(self.StatusIcon) notification.show() def Start(self): gtk.main() def About(self, a, b): self.Notify('test') def Options(self, a, b): print a, b def ChangeCheckBox(self, null): pass def Quit(self, a, b): raise SystemExit if <strong>name</strong> == '<strong>main</strong>': try: gobject.threads_init() # Doesn't work? Monitor = DataFetch() Monitor.Start() </pre></code></p> <p>Sorry for the terrible formatting, Stack Overflow doesn't seem to like blank lines.... Anyways, though, "1" is printed, but "2" is not. So, gtk.main() is obviously where it's hanging. Is there any way to allow me to continue execution and have gtk go do it's own thing?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload