Oct-25-2021, 11:27 AM
still strugling with this :s
i got this and it works with the exception that the frame opens in the bottom of the page after i resize it
i got this and it works with the exception that the frame opens in the bottom of the page after i resize it
import ctypes import platform from cefpython3 import cefpython as cef from tkinter import * import tkinter as tk import sys # platforms from cefpython.examples.tkinter_ import logger WINDOWS = platform.system() == 'Windows' LINUX = platform.system() == 'Linux' MAC = platform.system() == 'Darwin' class BrowserFrame(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 self.update() 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=urlset) # 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) def main(): root = tk.Tk() root.minsize(600, 600) w, h = root.winfo_screenwidth(), root.winfo_screenheight() root.geometry("%dx%d+0+0" % (w-550, h-250)) root.title('Test') WindowUtils = cef.WindowUtils() sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error settings = {} if MAC: settings["external_message_pump"] = True cef.Initialize(settings=settings) leftfrm = LabelFrame(root, text="left frame for buttons with links", padx=5, pady=5, highlightbackground="black", highlightthickness=2) leftfrm.grid(row=0, column=0, rowspan=99, sticky='nw', pady=2) home_browser = LabelFrame(root, text="right frame for browser", padx=5, pady=5, highlightbackground="black", highlightthickness=2) home_browser.grid(row=0, column=1, rowspan=99, sticky='ne', pady=2) browser_frame = BrowserFrame(home_browser).grid(row=1, column=0, sticky=(tk.N + tk.S + tk.E + tk.W)) for x in range(1, 25): Label(leftfrm, text=str("Link "+str(x))).grid(row=x,column=0) global urlset urlset = "http://www.google.com" root.mainloop() if __name__ == '__main__': main()