mkQApp: Use sys.argv if non-empty and always set given name (#1199)
Always pass `sys.argv`, if non-empty, to `QApplication` constructor. This allows code to continue to rely on the fact that the application name is by default set from `sys.argv[0]`, which is important for example on Linux where this determines the WM_CLASS X attribute used by desktop environments to match applications to their launchers. If `sys.argv` is empty, as it is in an interactive Python session, pass `["pyqtgraph"]` in its place as a sensible default for the application name, which causes issues if not set (issue #1165). If a `name` is given, set it using `setApplicationName()` instead of via the argument list. This ensures it will be set even if the singleton `QApplication` already existed prior to calling `mkQApp()`.
This commit is contained in:
parent
fb56d3eaa9
commit
9a9be68d90
@ -330,21 +330,19 @@ if m is not None and list(map(int, m.groups())) < versionReq:
|
||||
|
||||
|
||||
QAPP = None
|
||||
def mkQApp(name="pyqtgraph", qt_args=None):
|
||||
def mkQApp(name=None):
|
||||
"""
|
||||
Creates new QApplication or returns current instance if existing.
|
||||
|
||||
============== =================================================================================
|
||||
============== ========================================================
|
||||
**Arguments:**
|
||||
name Application name, passed to Qt
|
||||
qt_args Array of command line arguments passed to Qt
|
||||
============== =================================================================================
|
||||
name (str) Application name, passed to Qt
|
||||
============== ========================================================
|
||||
"""
|
||||
global QAPP
|
||||
QAPP = QtGui.QApplication.instance()
|
||||
if QAPP is None:
|
||||
args = [name]
|
||||
if qt_args is not None:
|
||||
args.extend(qt_args)
|
||||
QAPP = QtGui.QApplication(args)
|
||||
QAPP = QtGui.QApplication(sys.argv or ["pyqtgraph"])
|
||||
if name is not None:
|
||||
QAPP.setApplicationName(name)
|
||||
return QAPP
|
||||
|
Loading…
Reference in New Issue
Block a user