Cefpython doesn't like .pyw files

Viewed 19

So the thing is i was creating an app with Tkinter and Cefpython, and looked like this, and that is how it should work: enter image description here

However, when i change the file type from .py to .pyw it just doasn't really work: enter image description here

I have searched into my program to know a little what was happening and this is all the information i could get:

  • The BrowserFrame is there
  • However it doasn't make any requests to the server

Here is the class of the BrowserFrame I use, it's from Tkinter cefpython examples:

class Browser_Frame(tk.Frame):

 def __init__(self, master=None, **kw):
      super().__init__(master, **kw)
      self.browser = None
      self.bind('<Configure>', self.on_configure)

 def get_window_handle(self):
      if MAC:
           from AppKit import NSApp
           import objc
           return objc.pyobjc_id(NSApp.windows()[-1].contentView())
      elif self.winfo_id() > 0:
           return self.winfo_id()
      else:
           raise Exception('Could not obtain window handle!')

 def on_configure(self, event):
      if self.browser is None:
           # create the browser and embed it in current frame
           rect = [0, 0, self.winfo_width(), self.winfo_height()]
           cef_winfo = cef.WindowInfo()
           win_id = self.get_window_handle()
           cef_winfo.SetAsChild(win_id, rect)
           self.browser = cef.CreateBrowserSync(cef_winfo, url="http://localhost:8080")

           # start the browser handling loop
           self.cef_loop()

      # resize the browser
      if WINDOWS:
           ctypes.windll.user32.SetWindowPos(
                self.browser.GetWindowHandle(), 0,
                0, 0, event.width, event.height, 0x0002)
      elif LINUX:
           self.browser.SetBounds(0, 0, event.width, event.height)

 def cef_loop(self):
      cef.MessageLoopWork()
      self.after(10, self.cef_loop)

and the settings:

     sys.excepthook = cef.ExceptHook    
 WINDOWS = platform.system() == 'Windows'
 LINUX = platform.system() == 'Linux'
 MAC = platform.system() == 'Darwin'
 settings = {}
 if MAC:
    settings["external_message_pump"] = True
 cef.Initialize(settings=settings)
0 Answers
Related