QuantumQuadrate / CsPyController

GNU Lesser General Public License v3.0
3 stars 3 forks source link

Windowmanagement #50

Closed c-poole closed 4 years ago

c-poole commented 4 years ago

You may no longer open more than one of the same window at the same time. Closing the main window closes all windows.

I have set this up so that depending on the Qt backend we use, we can have one of two behaviors.

If we stick with PySide, we can't prompt the user to confirm they want to close with a dialog box and instead the application will always close. I have tried for quite some time to manufacture a work around using a home-brewed dialog box but my current abilities with enaml are insufficient to make that work. The issue causing the problem is an issue with enaml binding to PySide for MessageBox objects. It doesn't seem like with PySide you can instantiate any MessageBox objects. As far as I know, this is the first major bug that we have to live with as a result of sticking with Python 2, but who knows if it will be the last.

If we switch to PyQt4, we can have that prompt. Disadvantage is that PyQt4 is not pip install-able outright. We would need to place a link to a wheel download in the README and instruct the person installing to download the wheel and pip install it. This complicates install instructions, but the program runs as intended.

Interesting behavior I discovered while testing for this (This is also true on master, not related to this PR): You can no longer CTRL+C kill CsPy. It will only kill the main thread and leave the rest alive. However, if we choose the PyQt4 route, CTRL+C disables the dialog box and attempting to close the window will automatically shut down the program.

To toggle between the two behaviors when testing, simply switch which line is commented and which is uncommented in the closing:: block of the main experiment window near the end of CS_GUI.enaml.

We can in theory detect the back-end the user uses and switch between the behaviors accordingly in the code, but I don't really like that option. Before merging this I'd like us to make a formal decision about which of PySide and PyQt to use as the back-end for enaml and have only one of them in the installation instructions.

c-poole commented 4 years ago

The wheel for PyQt4 can be found here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4. Choose the one named PyQt4‑4.11.4‑cp27‑cp27m‑win_amd64.whl

You should uninstall PySide and install the PyQt4 wheel when looking at the option with the dialog box and vice versa. The current version of the PR assumes that we make the swap to using PyQt4 so we are free to merge if everyone approves of switching to it. Will need minor edits if we decide to stick to PySide. I'm personally in favor of PyQt4.