2

I know how to regularly call a function in a separate thread:

def main_loop():
    cefpython.MessageLoopWork() # do something
    threading.Timer(0.01, main_loop).start()

main_loop()

But how can I do it in the main thread (cefpython.MessageLoopWork() must be called from the main thread).

In the cefpython example, it is done with wxTimer, but I don't want to use wxpython:

class MyApp(wx.App):
    [...]
    def CreateTimer(self):
        self.timer = wx.Timer(self, self.timerID)
        self.timer.Start(10) # 10ms
        wx.EVT_TIMER(self, self.timerID, self.OnTimer)

    def OnTimer(self, event):
        cefpython.MessageLoopWork()
arthur.sw
  • 11,052
  • 9
  • 47
  • 104
  • 1
    Well, you're going to have to use some library built around an event loop. The cefpython documentation has [examples for a bunch of GUI frameworks](https://code.google.com/p/cefpython/w/list?q=label:Example), in addition to wxpython. – dano Mar 24 '15 at 17:33
  • I do not want to use big GUI frameworks, but I might have solved my problem thanks to [this answer](http://stackoverflow.com/a/29239050/719276) (it does not answer this question though) – arthur.sw Mar 25 '15 at 12:08

0 Answers0