English 中文(简体)
继续在草原的Pygtk.main()之后执行。
原标题:Continuing code execution after a pygtk.main() in python

我的申请是,我的数据Fetch()类“Wraps”在我的HBHTray()类左右,目的是与该类职能/变量互动。 不幸的是,在我的数据Fetch()班进行HBHTray和打电话后,我似乎无法继续执行该守则,也未能采用HBray(HBray)的开端方法。

这是相关的法典:


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 init(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 init(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 name ==  main :
    try:
        gobject.threads_init() # Doesn t work?
        Monitor = DataFetch()
        Monitor.Start()

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?

最佳回答

问题在于,我无法找到一种可行的解决办法,因为我正在利用Thread模块的错误方式,并在我应该呼吁开始的时候直接叫跑()。 因此,我认为我没有做任何工作(特别是没有任何错误或从任何东西提出过申诉),并且说,这是我如何总结的问题。

问题回答

http://www.ohchr.org。 它只告诉图书馆,你将重新使用read子,并设置一些锁。 你们仍然不得不制造read子。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签