cefpython

Why can't run both tkinter mainloop and cefpython3 messageloop?

旧城冷巷雨未停 提交于 2020-08-05 07:08:13
问题 I'm working at a project in Python3 in which i have both tkinter and a frame in tkinter with cef browser. This is the code. from tkinter import messagebox #import threading from cefpython3 import cefpython as cef import platform import sys from tkinter import * import time def on_closing (): print('closing') r.destroy() cef.Shutdown() r = Tk() r.geometry('800x600') r.protocol('WM_DELETE_WINDOW', on_closing) f = Frame(r, bg = 'blue', height = 200) f.pack(side = TOP, fill = 'x') g=Frame(r,bg =

How to call MessageLoopWork in cefpython?

烂漫一生 提交于 2020-01-21 13:48:49
问题 I made a simple offscreen renderer with cefpython. I used cefpython.MessageLoop() but I would like to execute a javascript function with browser.GetFocusedFrame().ExecuteFunction which must be called from main UI thread. Is there a way to set a callback on cefpython's message loop? Alternatively I could use MessageLoopWork , but I don't know how. I tried to call it in a separate thread but it does not work: import threading def main_loop(): cefpython.MessageLoopWork() threading.Timer(0.01,

Thread slows down when running cefpython MessageLoop()

Deadly 提交于 2019-12-14 02:28:41
问题 I made a simple offscreen renderer with cefpython. I use cefpython.MessageLoop() , and I have a separate thread to do something every seconds: [... cefpython initialization ...] startTime = time.time() def main_loop(): print time.time() - startTime threading.Timer(1, main_loop).start() main_loop() cefpython.MessageLoop() This works fine, but it slows down after 30 seconds (then the loop updates every 10 seconds). This is the output that I get: [CEF Python] Initialize() called [CEF Python]

Cefpython app with html/js files in local filesystem

旧巷老猫 提交于 2019-12-12 09:54:32
问题 I'm trying to make a hybrid python-js application with cefpython. I would like to have: JS and HTML files local to the cef python app (e.g. in './html', './js', etc) Load one of the HTML files as the initial page Avoid any CORS issues with files accessing each other (e.g. between directories) The following seems to work to load the first page: browser = cef.CreateBrowserSync(url='file:///html/index.html', window_title="Rulr 2.0") However, I then hit CORS issues. Do I need to run a webserver

Need to get HTML source as string CEFPython

孤街浪徒 提交于 2019-12-12 07:02:44
问题 I am trying to get HTML source as string from web URL using CEFPython I want MainFrame 's source content to be crawled and get string in def save_screenshot(browser): # Browser object provides GetUserData/SetUserData methods # for storing custom data associated with browser. The # "OnPaint.buffer_string" data is set in RenderHandler.OnPaint. buffer_string = browser.GetUserData("OnPaint.buffer_string") if not buffer_string: raise Exception("buffer_string is empty, OnPaint never called?")

Cefpython app with html/js files in local filesystem

北慕城南 提交于 2019-12-06 02:39:58
I'm trying to make a hybrid python-js application with cefpython. I would like to have: JS and HTML files local to the cef python app (e.g. in './html', './js', etc) Load one of the HTML files as the initial page Avoid any CORS issues with files accessing each other (e.g. between directories) The following seems to work to load the first page: browser = cef.CreateBrowserSync(url='file:///html/index.html', window_title="Rulr 2.0") However, I then hit CORS issues. Do I need to run a webserver also? Or is there an effective pattern for working with local files? Try passing "disable-web-security"

How to call MessageLoopWork in cefpython?

泄露秘密 提交于 2019-12-02 01:12:43
I made a simple offscreen renderer with cefpython . I used cefpython.MessageLoop() but I would like to execute a javascript function with browser.GetFocusedFrame().ExecuteFunction which must be called from main UI thread. Is there a way to set a callback on cefpython's message loop? Alternatively I could use MessageLoopWork , but I don't know how. I tried to call it in a separate thread but it does not work: import threading def main_loop(): cefpython.MessageLoopWork() threading.Timer(0.01, main_loop).start() threading.Timer(0.01, main_loop).start() I get the following error: [0324/174806