mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-25 21:58:38 -05:00
Improve functions for script
This commit is contained in:
parent
7b6d423dc8
commit
de461ce1be
@ -45,11 +45,11 @@ Enjoy!
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
|
||||||
import platform
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import importlib
|
import importlib
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
__version__ = "2.6"
|
__version__ = "2.6"
|
||||||
@ -349,31 +349,43 @@ def load_stylesheet_pyqt5():
|
|||||||
stylesheet += mac_fix
|
stylesheet += mac_fix
|
||||||
return stylesheet
|
return stylesheet
|
||||||
|
|
||||||
|
|
||||||
def information():
|
def information():
|
||||||
"""Get system and runtime information."""
|
"""Get system and runtime information."""
|
||||||
info = []
|
info = []
|
||||||
qt_api = ''
|
qt_api = ''
|
||||||
qt_lib = ''
|
qt_lib = ''
|
||||||
|
qt_bin = ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
qt_api = os.environ['QT_API']
|
qt_api = os.environ['QT_API']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
qt_api = 'Not set or inexistent'
|
qt_api = 'Not set or nonexistent'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
qt_lib = os.environ['PYQTGRAPH_QT_LIB']
|
from Qt import __binding__
|
||||||
|
qt_lib = __binding__
|
||||||
|
except (KeyError, ModuleNotFoundError):
|
||||||
|
qt_lib = 'Not set or nonexistent'
|
||||||
|
|
||||||
|
try:
|
||||||
|
qt_bin = os.environ['PYQTGRAPH_QT_LIB']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
qt_lib = 'Not set or inexistent'
|
qt_bin = 'Not set or nonexistent'
|
||||||
|
|
||||||
info.append('QDarkStyle: %s' % __version__)
|
info.append('QDarkStyle: %s' % __version__)
|
||||||
info.append('OS: %s %s %s' % (os.uname().sysname, os.uname().release, os.uname().machine))
|
info.append('OS: %s %s %s' % (platform.system(), platform.release(), platform.machine()))
|
||||||
info.append('Platform: %s' % sys.platform)
|
info.append('Platform: %s' % sys.platform)
|
||||||
info.append('Python: %s' % '.'.join(str(e) for e in sys.version_info[:]))
|
info.append('Python: %s' % '.'.join(str(e) for e in sys.version_info[:]))
|
||||||
info.append('Python API: %s' % sys.api_version)
|
info.append('Python API: %s' % sys.api_version)
|
||||||
|
|
||||||
info.append('Binding in use: %s' % QT_BINDING)
|
info.append('Binding in use: %s' % QT_BINDING)
|
||||||
info.append('Abstraction in use: %s' % QT_ABSTRACTION)
|
info.append('Abstraction in use: %s' % QT_ABSTRACTION)
|
||||||
info.append('QT_API: %s' % qt_api)
|
|
||||||
info.append('PYQTGRAPH_QT_LIB: %s' % qt_lib)
|
info.append('qtpy (QT_API): %s' % qt_api)
|
||||||
|
info.append('pyqtgraph (PYQTGRAPH_QT_LIB): %s' % qt_lib)
|
||||||
|
info.append('Qt.py (__binding__): %s' % qt_bin)
|
||||||
|
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
|
||||||
@ -403,13 +415,14 @@ def qt_abstractions():
|
|||||||
|
|
||||||
|
|
||||||
def import_qt_modules_from(use_binding='pyqt5', use_abstraction='qtpy'):
|
def import_qt_modules_from(use_binding='pyqt5', use_abstraction='qtpy'):
|
||||||
|
"""New approach to import modules using importlib."""
|
||||||
spec_binding = importlib.util.find_spec(use_binding)
|
spec_binding = importlib.util.find_spec(use_binding)
|
||||||
spec_abstraction = importlib.util.find_spec(use_abstraction)
|
spec_abstraction = importlib.util.find_spec(use_abstraction)
|
||||||
|
|
||||||
if spec_binding is None:
|
if spec_binding is None:
|
||||||
print("Cannot find Qt binding: ", use_binding)
|
print("Cannot find Qt binding: ", use_binding)
|
||||||
else:
|
else:
|
||||||
module = importlib.util.module_from_spec(spec)
|
module = importlib.util.module_from_spec(spec_binding)
|
||||||
spec.loader.exec_module(module)
|
spec.loader.exec_module(module)
|
||||||
# Adding the module to sys.modules is optional.
|
# Adding the module to sys.modules is optional.
|
||||||
sys.modules[name] = module
|
sys.modules[name] = module
|
||||||
|
Loading…
Reference in New Issue
Block a user