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

Support QApplication command-line args #4035

Open
jaredd opened this issue Jan 2, 2021 · 4 comments
Open

Support QApplication command-line args #4035

jaredd opened this issue Jan 2, 2021 · 4 comments

Comments

@jaredd
Copy link
Contributor

jaredd commented Jan 2, 2021

Background:
The current GRC top-level python file uses the parse_args method of argparse.ArgumentParser to check command line args. Any arguments not explicitly defined as top-level parameter in the GRC flowgraph will be flagged as an error. The default QT GUI class QApplication and its parent class QGuiApplication support a number of command line arguments that can be useful for configuring (or disabling) the Qt application look and feel.

One specific use case is to run a GUI application on a headless box (e.g. a server) without disabling or removing the GUI elements. By specifying a -platform minimal, or -platform offscreen (-platform being an option to QGuiApplication) the GUI-enabled flowgraph may be executed without requiring a display for those GUI elements, thus reducing the burden of disabling GUI elements in the GRC and, often, maintaining two versions of the flowgraph.

Suggestion:
The relevant line in the current top-level GRC-generated application template reads

options = argument_parser().parse_args()

This could be changed to

options, _ = argument_parser().parse_known_args()

which will now ignore arguments intended for the QApplication. This change has the disadvantage of removing checks on arguments to the flowgraph that may be mistyped or otherwise extraneous.

@nickoe
Copy link
Contributor

nickoe commented Jan 4, 2021

Sort of related to #2650

@nickoe
Copy link
Contributor

nickoe commented Jan 5, 2021

@jaredd Shouldn't one give an explicit list to parse_known_args to pass them on?

@jaredd
Copy link
Contributor Author

jaredd commented Jan 6, 2021

@nickoe I'm not sure what you're referring to when you say "to pass them on". The parse_known_args method looks for the args that had been configured in the ArgumentParser object prior to its call. You can collect unknown args in the second return value and pass them to the QApplication, that also works. My suggestion was to minimize changed lines. QApplication seems to ignore args it doesn't understand so other than possible mixups if the GR application args somehow match a QApplication arg, the behavior is pretty well defined.

@tjeng
Copy link

tjeng commented Apr 30, 2021

I am working on resolving the issue.

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

No branches or pull requests

6 participants