I’m building a GUI (pyqt or pyside) to easily create complex figures (e.g. with plotly) for users.
So far so good, I run the data processing and produce plotly figures that are exported as html and read by QwebEngineView. I even created a qt widget for layout editing by the user (see image below).
The problem with this is the long delay (few seconds) in the process of:
updating the layout -> exporting to a temp html file → open and rendering the file on GUI.
I want to make a better GUI experience with layout editing.
Following this great Jon Mease talk I discovered my plotly figures could be updated in real time using the also great ipywidgets, but only on Jupyter notebooks / lab environment. That is, exporting the widgets+figure to a html file renders all elements, but since the python backend will be lacking for the widgets (in the standalone html file), they won’t interact with the figure’s layout.
However, my application IS running on a python process, so I have the feeling this should be a solvable problem somehow...
Qtconsole won’t render ipywidgets, so I can’t use it to expose my figures in the GUI.
Voila renders Jupyter notebooks with interactive widgets, I’m not sure however if I could access it and incorporate it to the GUI. It says it can work both as a “standalone tornado application” or as a “server extension to notebook or jupyter_server”.
I’m aware there’s probably not a final solution to that, but I would appreciate any suggestions on how to approach this problem! Thanks!
I ended up creating a solution for the problem: QtVoila
It is basically an extended QWebEngineView that manages and renders a Voila process, with some extra functionalities.
Here's a blog post explaining it:
https://www.taufferconsulting.com/portfolio/qtvoila
Related
I am using Jupyter notebook on my laptop (the version coming with Anaconda) to perform some sensitivity analysis.
I use plotly to display the results and I like the interactive features that it has.
However, when I am trying to display more than 7/8 interactive plots on the same notebook, some plots disappears and the output cells of those plots go crazy (see picture attached).
Issue with plotly
A solution I found was to disable the interactive feature at least for some of the plots, changing the diplay mode in config as:
config = {'staticPlot': True}
fig.show(config=config)
This method works, however, I like the feature and I was wondering if there was a solution that does not imply disabling the interactive view.
I read about this post where they say it might be a memory issue (even though their graphs are going blank while mine are behaving crazy):
Plotly: How to prevent graphs from going blank when there are too many interactive plots?
However I did not manage to find/change the jupyter configuration file, maybe because I installed it via Anaconda?
I was also wondering if someone experienced exactly the same or there might be a simpler solution to this issue.
Thanks a lot in advance
I believe that in the second link the config file should be generated if not existing.
You can also try changing to gl rendering:
https://plotly.com/python/webgl-vs-svg/
I've searched on Google and StackOverflow but am having trouble finding the answer, even though it seems like it should be easy to do.
How can I use Python to load a URL into its own window, rather than in a browser? I imagine this should be trivial in Tkinter or some other GUI package.
Yeah. that's very easy with QWebView in PyQt/PySide
You basically instantiate a new QWebView and pass the url to it
QWebView.load(QUrl('http://www.www.pythoncentral.io'))
you can read more here
http://pythoncentral.io/pyside-pyqt-tutorial-qwebview/
and also in the pyQt docs
http://pyqt.sourceforge.net/Docs/PyQt4/qwebview.html
A new option would be: pywebview
pywebview is a lightweight cross-platform wrapper around a webview
component that allows to display HTML content in its own native GUI
window. It gives you power of web technologies in your desktop
application, hiding the fact that GUI is browser based.
See here:
https://github.com/r0x0r/pywebview
When using the web based iPython Notebook/Jupyter capability, i created a notebook with markdown cells of text and code cells to display the code and plots for matplotlib and bokeh. I then download that as .ipynb open with sublime, copy and paste to git, then access it on nbviewer through my git account. When looking at it here:
http://nbviewer.ipython.org/github/angisgrate/test/blob/master/pyohio3.ipynb
in notebook view, it works fine. the markdown, code, and plot steps are all there.
When switching to slides view, the intent of the creation needed for the presentation, this code blocks occurs first, blocking out the first 10 markdown steps and all the matplotlib steps, rendering this weird code without the plots:
http://nbviewer.ipython.org/format/slides/github/angisgrate/test/blob/master/pyohio3.ipynb
How can i fix this asap?? I've looked through and there was a similar problem in 2014 with slides, but it yielded an actual "Error" that i'm not seeing, just this contorted view
I can't say for certain. It's possible in the nbviewer slides view, the execution of JavaScript is suppressed (this happens on GitHub notebook previews, for instance). All of the rendering in Bokeh actually happens from the JavaScript library BokehJS, so if this is the case, then Bokeh will not function, and there is nothing really that can be done. This is probably a question bset directed towards the nbviewer team/community to find out the specifics of how the slides view behaves (and is intended to behave) with respect to executing embedded JavaScript.
Edit: Looks like this is a known/discussed issue. More information here: Issue #484: Jupyter>>nbviewer slides Fail, notebook view fine by angisgrate in jupyter/nbviewer on GitHub
I have developed a Qt GUI using Qt4 and PyQt. I am trying to implement a graph that will dynamically "live update" the graph to represent the rate at which the data is being transmitted in a (data/sec format). However, the problem lies within implementing a graph that can cleanly live update, not finding the speed. For the record, I want this to be built in as a widget within the GUI not a separate pop-up window.
I suggest you to use two threads: One for acquiring data from somewhere, the other for representing it's graphics. You can take a look on A “live” data monitor with Python, PyQt and PySerial or to pyQt Matplotlib widget live data updates.
I've used qCustomPlot (website here) with pretty good success. I can live-update several thousand data points and it's all very straightforward to use.
I am essentially trying to replicate the google finance chart, but for sensor data. I would like to embed the chart in a GUI and have it update on a timer (which samples the sensor for it's value). I would like to incorporate panning, resizing, and adding moving averages, much like the google finance charts, all of which is updated at some steady interval.
Much of my code base is already in python, so I would like to stick with it. Can this be done with Python?
I have checked out matplotlib, but I am not sure if it can do dynamic charts. I am using wxPython to create the GUI.
I recently came across Chaco from Enthought.
http://code.enthought.com/projects/chaco/
It is an open source framework written in Python that binds with wx, Qt etc and more usable than matplotlib for building full applications. Very usable and easily customizable. You can use the packaged panning, zooming tools or build your own.
I would suggest downloading the epd-free package to ensure you get all dependencies if you choose to move ahead with it.
http://www.enthought.com/products/epd_free.php/
I just implement a method to draw dynamic charts in ipython notebook, you can check my blog post here : http://litaotao.github.io/dynamic-charts-matplotlib-alternative-ipython-notebook-python-drawing-js
and bellow is a screenshot: