Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt event loop does not execute the application in MS Windows #162

Open
carez opened this issue Nov 6, 2021 · 0 comments · May be fixed by #163
Open

Qt event loop does not execute the application in MS Windows #162

carez opened this issue Nov 6, 2021 · 0 comments · May be fixed by #163

Comments

@carez
Copy link
Contributor

carez commented Nov 6, 2021

Expected Behavior

The event loop created by gui_qt() should execute the QApplication if it is not already running.

Current Behavior

When running the code as a python module (python -m module_name), it seems to work fine in my Linux environment, but in Windows the program just finishes without launching the application window.

The problem lies here:

if app.applicationName() == app_name:

  • In Linux app.applicationName() contains the name passed to the QApplication constructor app = QApplication([app_name]). This is what the code above is expecting.
  • In Windows app.applicationName() contains the string python, therefore the if statement always evaluates to false.

On a side note, the code of the gui_qt() function seems to mask command line arguments instead of passing them on to the application.

Possible Solution

a. Manually set the application name with setApplicationName(). I've pushed #163 implementing this.
b. Alternatively, refactor the gui_qt function to receive the same parameters as QApplication. That is, receive argv and pass it on to QApplication, instead of only receiving a single string with the application_name. I believe this would also allow to pass command line arguments to the application, which is probably not the case at the moment.

Steps to Reproduce (for bugs)

  1. python -m bluesky_widgets.examples.qt_run_tree_view
  2. The program runs until completion without launching the application window.

Your Environment

Windows 10, python 3.9.7, conda 4.10.3, PyQt5 5.15.4

carez added a commit to carez/bluesky-widgets that referenced this issue Nov 6, 2021
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 a pull request may close this issue.

1 participant