Skip to content

Conversation

atitus
Copy link
Contributor

@atitus atitus commented Jun 19, 2019

I added a new file qtbrowser.py that creates a PyQt application and web browser window that looks more like VPython classic. I modified vpython.py to create a function set_browser() by which the browser can be changed from the default to pyqt. I modified _no_notebook.py to take advantage of the browser option. Because a PyQt application must run in the main thread, I had to use the multiprocessing package and launch the PyQt application in its own process from a separate .py file. (I could not launch the application from a function in _no_notebook.py.)

In a VPython program, use the code below to pop up a PyQt window with the VPython canvas and scene(s).

# use type='pyqt' to open the program in a pyqt5 browser window
set_browser(type='pyqt')

Here is a simple example that creates a sphere in a PyQt window:

from vpython import *

set_browser(type='pyqt')

ball=sphere()

@mwcraig
Copy link
Contributor

mwcraig commented Jun 19, 2019

oh my, this looks interesting!

I'd like to do a bit of testing before this gets merged (shouldn't take more than 24 hours)

@atitus
Copy link
Contributor Author

atitus commented Jun 19, 2019 via email

@mwcraig
Copy link
Contributor

mwcraig commented Dec 3, 2019

@atitus -- I think this is going to be of interest to a lot of users. I'm hoping to have a chance to take a look at it later this week (finally).

@mwcraig
Copy link
Contributor

mwcraig commented Dec 31, 2019

@atitus -- I finally played around with this tonight! It seemed to work pretty well (I was trying it from within ipython) though I didn't try every demo program. I have a few minor code formatting suggestions/request. Do you want me to:

  1. Comment on those here so you can fix them, or
  2. Make the fixes and push them to your branch?

@atitus
Copy link
Contributor Author

atitus commented Dec 31, 2019

@mwcraig Great! Please make the fixes and push them to my branch. I'm guessing you noticed that I did not sufficiently check for whether one is using pypy. At the time, I noted that a pypy user who sets the browser to pyqt might have a problem that I did not test nor check for.

There is one other potential issue that I did not check--the GPL license of PyQt. According to the web site, "PyQt5 is dual licensed on all platforms under the Riverbank Commercial License and the GPL v3." It seems that GPL v3 is consistent with the VPython license at:

https://www.glowscript.org/docs/VPythonDocs/license.txt

but perhaps our license will need to include a statement about PyQT.

except:
pass


if platform.python_implementation() == 'PyPy' and _browsertype == 'pyqt':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atitus -- does this look OK to you for PyPy error handling? It doesn't avoid an error but it does give a fairly explicit error message. I'm a little reluctant to have PyPy automagically ignore the pyqt browser setting because I imagine it will lead to confusion about why the regular browser is opening, but it would be straightforward to make that happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's fine with me. I don't know for sure that using PyPy and the pyqt browser are incompatible. I just know that the way I originally implemented pyqt in no_notebook.py was solely for non-PyPy cases. It's possible that you or someone else might implement pyqt in a way that is compatible with PyPy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK; I'll merge tomorrow morning to give folks a bit of time to make comments.

@mwcraig
Copy link
Contributor

mwcraig commented Dec 31, 2019

I think we are fine regarding the license since we aren't incorporating any pyqt code into vpython; the user has to obtain pyqt and install it themselves, so we aren't redistributing the GPLed code. (Though I am not a lawyer, of course)

@pmelanson
Copy link
Contributor

Thank you both for getting this merged, it's going to be really useful!

@mwcraig
Copy link
Contributor

mwcraig commented Jan 1, 2020

Merging, thanks again for this new year's gift!

@mwcraig mwcraig merged commit 11600e0 into vpython:master Jan 1, 2020
@atitus
Copy link
Contributor Author

atitus commented Jan 1, 2020

@mwcraig Thanks! This was my first official contribution to vpython. There's more in the hopper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants