Skip to content

Commit

Permalink
create application function
Browse files Browse the repository at this point in the history
  • Loading branch information
jborbely committed Jul 21, 2017
1 parent 4879c66 commit 551e992
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions msl/qt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
import sys
from collections import namedtuple

from PyQt5 import QtWidgets

__author__ = 'Joseph Borbely'
__copyright__ = '\xa9 2017, ' + __author__
__version__ = '0.1.0'

version_info = namedtuple('version_info', 'major minor micro')(*map(int, __version__.split('.')[:3]))
""":obj:`~collections.namedtuple`: Contains the version information as a (major, minor, micro) tuple."""


def application(args=sys.argv):
"""Returns the QApplication instance (creating one if necessary).
Parameters
----------
args : :obj:`list` of :obj:`str`
A list of arguments to initialize the QApplication.
Returns
-------
The QApplication instance.
"""
app = QtWidgets.QApplication.instance()
if app is None:
app = QtWidgets.QApplication(args)
return app

0 comments on commit 551e992

Please sign in to comment.