plotly dash

124 views
Skip to first unread message

kn ck

unread,
Jan 4, 2019, 4:39:58 AM1/4/19
to CEF Python
i need to run plotly dash in python desktop app. i need to do server side (flask) stuff to make my charts. can i use cef to make it? is there a way to run flask in cef python? thank you!

Buff

unread,
Jan 5, 2019, 11:27:04 AM1/5/19
to CEF Python
i never try before, but i thot use D3.js is gonna be working. and also u can use cefpython execute javascript like this.
self.mainBrowser.GetMainFrame().ExecuteJavascript('window.disConnectExh && window.disConnectExh("' + exhId + '")')

and both flask with cefpython can run together,  i just run another threading 

al syntax

unread,
Oct 22, 2021, 5:02:36 PM10/22/21
to CEF Python
I can't seem to get flask and cefpython to work together. When I combine the code for plotly with cefpython3, python will only run one or the other (cefpython or flask/plotly), but will not run both at the same time in a single script. 

From my observation, both cefpython and flask have 'block until quit' mechanisms. For instance, if I ran plotly only, my CMD window has an alert: running x y z... (Press CTRL+C to quit). --- So no other code is executed until i press CTRL+C. Then, on the cefpython side, messageloop() will block until quit. So no additional code is executed until the cefpython process terminates. Even if I put print("hello world") after messageloop(), this will not print until i close the cefpython application window. 

Hopefully, this is just limited by my understanding of python and threading, and I'm missing a step somewhere. I tested your threading snapshot like this (with no luck):

assume this basic code structure:

```
def main() #cefpython
def plotlystuff()

def createThreading(): 
     t1 = threading.Thread(target=main()) 
     t1.setDaemon(True) 
     t1.start() 
     t2 = threading.Thread(target=plotlystuff())
     t2.setDaemon(True) 
     t2.start()

if __name__ == '__main__':
    createThreading()
```
Thanks for any help. I know this thread is old; but it's all I could find.

Czarek Tomczak.

unread,
Oct 25, 2021, 3:05:58 PM10/25/21
to CEF Python
You could try multi threaded message loop, but it's not officially supported and there may be an issue on exit (Issue #380).

Mohamed Ashraf

unread,
Feb 12, 2022, 10:51:00 AM2/12/22
to CEF Python
I have created simple lib to build gui using cefpython and tkinter(container) based on the tkinter-embeded-browser example on cefpython github.
and I have added some features to the lib like executing js sync and other features, and I think it may help you to combine flask stuff and gui 
the name of my lib is photongui "https://github.com/Mohamed501258/photongui"
Reply all
Reply to author
Forward
0 new messages