diff options
| author | Christoph Berg <myon@debian.org> | 2025-01-09 22:12:06 +0100 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2025-01-09 22:12:06 +0100 |
| commit | 992d4b4b8d3f3a630a2cf00d593ee4ce4dfa7ce8 (patch) | |
| tree | fbfdfe6bcb0a8a114be2480dac53d88c977e4869 /contrib/QDarkStyleSheet/script | |
| parent | 4320ce238aae1fe87fc9f379cdd816e9317885fa (diff) | |
New upstream version 2.7.0~rc8+repackupstream/2.7.0_rc8+repack
Diffstat (limited to 'contrib/QDarkStyleSheet/script')
| -rwxr-xr-x | contrib/QDarkStyleSheet/script/get_info.py | 48 | ||||
| -rwxr-xr-x | contrib/QDarkStyleSheet/script/process_qrc.py | 250 | ||||
| -rwxr-xr-x | contrib/QDarkStyleSheet/script/process_ui.py | 248 | ||||
| -rwxr-xr-x | contrib/QDarkStyleSheet/script/run_ui_css_edition.py | 104 |
4 files changed, 325 insertions, 325 deletions
diff --git a/contrib/QDarkStyleSheet/script/get_info.py b/contrib/QDarkStyleSheet/script/get_info.py index 63795977..91a4d0ce 100755 --- a/contrib/QDarkStyleSheet/script/get_info.py +++ b/contrib/QDarkStyleSheet/script/get_info.py @@ -1,24 +1,24 @@ -
-# -*- coding: utf-8 -*-
-"""Script to get system information.
-"""
-
-from __future__ import absolute_import, print_function
-
-import os
-import sys
-import qdarkstyle
-
-def get_info():
- """Process UI files."""
- info = []
- info.append('QDarkStyle: ', qdarkstyle.__version__)
- info.append('OS: ', sys.platform)
- info.append('Python: ', sys.version)
- info.append('QT_API: ', os.getenv['QT_API'])
- info.append('PYQTGRAPH_QT_LIB: ', os.getenv['PYQTGRAPH_QT_LIB'])
- for item in info:
- print(item)
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv[1:]))
+ +# -*- coding: utf-8 -*- +"""Script to get system information. +""" + +from __future__ import absolute_import, print_function + +import os +import sys +import qdarkstyle + +def get_info(): + """Process UI files.""" + info = [] + info.append('QDarkStyle: ', qdarkstyle.__version__) + info.append('OS: ', sys.platform) + info.append('Python: ', sys.version) + info.append('QT_API: ', os.getenv['QT_API']) + info.append('PYQTGRAPH_QT_LIB: ', os.getenv['PYQTGRAPH_QT_LIB']) + for item in info: + print(item) + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/contrib/QDarkStyleSheet/script/process_qrc.py b/contrib/QDarkStyleSheet/script/process_qrc.py index 98bda2d7..1f282db0 100755 --- a/contrib/QDarkStyleSheet/script/process_qrc.py +++ b/contrib/QDarkStyleSheet/script/process_qrc.py @@ -1,125 +1,125 @@ -# -*- coding: utf-8 -*-
-"""Script to process QRC files (convert .qrc to _rc.py and .rcc).
-
-The script will attempt to compile the qrc file using the following tools:
-
- - pyrcc4 for PyQt4 and PyQtGraph (Python)
- - pyrcc5 for PyQt5 and QtPy (Python)
- - pyside-rcc for PySide (Python)
- - pyside2-rcc for PySide2 (Python)
- - rcc for Qt4 and Qt5 (C++)
-
-Delete the compiled files that you don't want to use manually after
-running this script.
-
-Links to understand those tools:
-
- - pyrcc4: http://pyqt.sourceforge.net/Docs/PyQt4/resources.html#pyrcc4
- - pyrcc5: http://pyqt.sourceforge.net/Docs/PyQt5/resources.html#pyrcc5
- - pyside-rcc: https://www.mankier.com/1/pyside-rcc
- - pyside2-rcc: https://doc.qt.io/qtforpython/overviews/resources.html (Documentation Incomplete)
- - rcc on Qt4: http://doc.qt.io/archives/qt-4.8/rcc.html
- - rcc on Qt5: http://doc.qt.io/qt-5/rcc.html
-
-"""
-
-from __future__ import absolute_import, print_function
-
-import argparse
-import glob
-import os
-import sys
-from subprocess import call
-
-
-def main(arguments):
- """Process QRC files."""
- parser = argparse.ArgumentParser(description=__doc__,
- formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument('--qrc_dir',
- default='../qdarkstyle',
- type=str,
- help="QRC file directory, relative to current directory.",)
- parser.add_argument('--create',
- default='all',
- choices=['pyqt', 'pyqt5', 'pyside', 'pyside2', 'qtpy', 'pyqtgraph', 'qt', 'qt5', 'all'],
- type=str,
- help="Choose which one would be generated.")
-
- args = parser.parse_args(arguments)
-
- print('Changing directory to: ', args.qrc_dir)
- os.chdir(args.qrc_dir)
-
- print('Converting .qrc to _rc.py and/or .rcc ...')
-
- for qrc_file in glob.glob('*.qrc'):
- # get name without extension
- filename = os.path.splitext(qrc_file)[0]
-
- print(filename, '...')
- ext = '_rc.py'
- ext_c = '.rcc'
-
- # creating names
- py_file_pyqt5 = 'pyqt5_' + filename + ext
- py_file_pyqt = 'pyqt_' + filename + ext
- py_file_pyside = 'pyside_' + filename + ext
- py_file_pyside2 = 'pyside2_' + filename + ext
- py_file_qtpy = 'qtpy_' + filename + ext
- py_file_pyqtgraph = 'pyqtgraph_' + filename + ext
-
- # calling external commands
- if args.create in ['pyqt', 'pyqtgraph', 'all']:
- print("Compiling for PyQt4 ...")
- try:
- call(['pyrcc4', '-py3', qrc_file, '-o', py_file_pyqt])
- except FileNotFoundError:
- print("You must install pyrcc4")
-
- if args.create in ['pyqt5', 'qtpy', 'all']:
- print("Compiling for PyQt5 ...")
- try:
- call(['pyrcc5', qrc_file, '-o', py_file_pyqt5])
- except FileNotFoundError:
- print("You must install pyrcc5")
-
- if args.create in ['pyside', 'all']:
- print("Compiling for PySide ...")
- try:
- call(['pyside-rcc', '-py3', qrc_file, '-o', py_file_pyside])
- except FileNotFoundError:
- print("You must install pyside-rcc")
-
- if args.create in ['pyside2', 'all']:
- print("Compiling for PySide 2...")
- try:
- call(['pyside2-rcc', '-py3', qrc_file, '-o', py_file_pyside2])
- except FileNotFoundError:
- print("You must install pyside2-rcc")
-
- if args.create in ['qtpy', 'all']:
- print("Compiling for QtPy ...")
- # special case - qtpy - syntax is PyQt5
- with open(py_file_pyqt5, 'r') as file:
- filedata = file.read()
- # replace the target string
- filedata = filedata.replace('from PyQt5', 'from qtpy')
- with open(py_file_qtpy, 'w+') as file:
- # write the file out again
- file.write(filedata)
-
- if args.create in ['pyqtgraph', 'all']:
- print("Compiling for PyQtGraph ...")
- # special case - pyqtgraph - syntax is PyQt4
- with open(py_file_pyqt, 'r') as file:
- filedata = file.read()
- # replace the target string
- filedata = filedata.replace('from PyQt4', 'from pyqtgraph.Qt')
- with open(py_file_pyqtgraph, 'w+') as file:
- # write the file out again
- file.write(filedata)
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv[1:]))
+# -*- coding: utf-8 -*- +"""Script to process QRC files (convert .qrc to _rc.py and .rcc). + +The script will attempt to compile the qrc file using the following tools: + + - pyrcc4 for PyQt4 and PyQtGraph (Python) + - pyrcc5 for PyQt5 and QtPy (Python) + - pyside-rcc for PySide (Python) + - pyside2-rcc for PySide2 (Python) + - rcc for Qt4 and Qt5 (C++) + +Delete the compiled files that you don't want to use manually after +running this script. + +Links to understand those tools: + + - pyrcc4: http://pyqt.sourceforge.net/Docs/PyQt4/resources.html#pyrcc4 + - pyrcc5: http://pyqt.sourceforge.net/Docs/PyQt5/resources.html#pyrcc5 + - pyside-rcc: https://www.mankier.com/1/pyside-rcc + - pyside2-rcc: https://doc.qt.io/qtforpython/overviews/resources.html (Documentation Incomplete) + - rcc on Qt4: http://doc.qt.io/archives/qt-4.8/rcc.html + - rcc on Qt5: http://doc.qt.io/qt-5/rcc.html + +""" + +from __future__ import absolute_import, print_function + +import argparse +import glob +import os +import sys +from subprocess import call + + +def main(arguments): + """Process QRC files.""" + parser = argparse.ArgumentParser(description=__doc__, + formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument('--qrc_dir', + default='../qdarkstyle', + type=str, + help="QRC file directory, relative to current directory.",) + parser.add_argument('--create', + default='all', + choices=['pyqt', 'pyqt5', 'pyside', 'pyside2', 'qtpy', 'pyqtgraph', 'qt', 'qt5', 'all'], + type=str, + help="Choose which one would be generated.") + + args = parser.parse_args(arguments) + + print('Changing directory to: ', args.qrc_dir) + os.chdir(args.qrc_dir) + + print('Converting .qrc to _rc.py and/or .rcc ...') + + for qrc_file in glob.glob('*.qrc'): + # get name without extension + filename = os.path.splitext(qrc_file)[0] + + print(filename, '...') + ext = '_rc.py' + ext_c = '.rcc' + + # creating names + py_file_pyqt5 = 'pyqt5_' + filename + ext + py_file_pyqt = 'pyqt_' + filename + ext + py_file_pyside = 'pyside_' + filename + ext + py_file_pyside2 = 'pyside2_' + filename + ext + py_file_qtpy = 'qtpy_' + filename + ext + py_file_pyqtgraph = 'pyqtgraph_' + filename + ext + + # calling external commands + if args.create in ['pyqt', 'pyqtgraph', 'all']: + print("Compiling for PyQt4 ...") + try: + call(['pyrcc4', '-py3', qrc_file, '-o', py_file_pyqt]) + except FileNotFoundError: + print("You must install pyrcc4") + + if args.create in ['pyqt5', 'qtpy', 'all']: + print("Compiling for PyQt5 ...") + try: + call(['pyrcc5', qrc_file, '-o', py_file_pyqt5]) + except FileNotFoundError: + print("You must install pyrcc5") + + if args.create in ['pyside', 'all']: + print("Compiling for PySide ...") + try: + call(['pyside-rcc', '-py3', qrc_file, '-o', py_file_pyside]) + except FileNotFoundError: + print("You must install pyside-rcc") + + if args.create in ['pyside2', 'all']: + print("Compiling for PySide 2...") + try: + call(['pyside2-rcc', '-py3', qrc_file, '-o', py_file_pyside2]) + except FileNotFoundError: + print("You must install pyside2-rcc") + + if args.create in ['qtpy', 'all']: + print("Compiling for QtPy ...") + # special case - qtpy - syntax is PyQt5 + with open(py_file_pyqt5, 'r') as file: + filedata = file.read() + # replace the target string + filedata = filedata.replace('from PyQt5', 'from qtpy') + with open(py_file_qtpy, 'w+') as file: + # write the file out again + file.write(filedata) + + if args.create in ['pyqtgraph', 'all']: + print("Compiling for PyQtGraph ...") + # special case - pyqtgraph - syntax is PyQt4 + with open(py_file_pyqt, 'r') as file: + filedata = file.read() + # replace the target string + filedata = filedata.replace('from PyQt4', 'from pyqtgraph.Qt') + with open(py_file_pyqtgraph, 'w+') as file: + # write the file out again + file.write(filedata) + + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/contrib/QDarkStyleSheet/script/process_ui.py b/contrib/QDarkStyleSheet/script/process_ui.py index d83ff7af..bbe11545 100755 --- a/contrib/QDarkStyleSheet/script/process_ui.py +++ b/contrib/QDarkStyleSheet/script/process_ui.py @@ -1,124 +1,124 @@ -# -*- coding: utf-8 -*-
-"""Script to process UI files (convert .ui to .py).
-
-It compiles .ui files to be used with PyQt4, PyQt5, PySide, QtPy, PyQtGraph.
-You just need to run (it has default values) from script folder.
-
-To run this script you need to have these tools available on system:
-
- - pyuic4 for PyQt4 and PyQtGraph
- - pyuic5 for PyQt5 and QtPy
- - pyside-uic for Pyside
- - pyside2-uic for Pyside2
-
-Links to understand those tools:
-
- - pyuic4: http://pyqt.sourceforge.net/Docs/PyQt4/designer.html#pyuic4
- - pyuic5: http://pyqt.sourceforge.net/Docs/PyQt5/designer.html#pyuic5
- - pyside-uic: https://www.mankier.com/1/pyside-uic
- - pyside2-uic: https://wiki.qt.io/Qt_for_Python_UiFiles (Documentation Incomplete)
-
-"""
-
-from __future__ import absolute_import, print_function
-
-import argparse
-import glob
-import os
-import sys
-from subprocess import call
-
-
-def main(arguments):
- """Process UI files."""
- parser = argparse.ArgumentParser(description=__doc__,
- formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument('--ui_dir',
- default='../example/ui',
- type=str,
- help="UI files directory, relative to current directory.",)
- parser.add_argument('--create',
- default='all',
- choices=['pyqt', 'pyqt5', 'pyside', 'pyside2', 'qtpy', 'pyqtgraph', 'all'],
- type=str,
- help="Choose which one would be generated.")
-
- args = parser.parse_args(arguments)
-
- print('Changing directory to: ', args.ui_dir)
- os.chdir(args.ui_dir)
-
- print('Converting .ui to .py ...')
-
- for ui_file in glob.glob('*.ui'):
- # get name without extension
- filename = os.path.splitext(ui_file)[0]
- print(filename, '...')
- ext = '.py'
-
- # creating names
- py_file_pyqt5 = filename + '_pyqt5_ui' + ext
- py_file_pyqt = filename + '_pyqt_ui' + ext
- py_file_pyside = filename + '_pyside_ui' + ext
- py_file_pyside2 = filename + '_pyside2_ui' + ext
- py_file_qtpy = filename + '_qtpy_ui' + ext
- py_file_pyqtgraph = filename + '_pyqtgraph_ui' + ext
-
- # calling external commands
- if args.create in ['pyqt', 'pyqtgraph', 'all']:
- try:
- call(['pyuic4', '--from-imports', ui_file, '-o', py_file_pyqt])
- except Exception as er:
- print("You must install pyuic4 %s" % str(er))
- else:
- print("Compiling using pyuic4 ...")
-
- if args.create in ['pyqt5', 'qtpy', 'all']:
- try:
- call(['pyuic5', '--from-imports', ui_file, '-o', py_file_pyqt5])
- except Exception as er:
- print("You must install pyuic5 %s" % str(er))
- else:
- print("Compiling using pyuic5 ...")
-
- if args.create in ['pyside', 'all']:
- try:
- call(['pyside-uic', '--from-imports', ui_file, '-o', py_file_pyside])
- except Exception as er:
- print("You must install pyside-uic %s" % str(er))
- else:
- print("Compiling using pyside-uic ...")
-
- if args.create in ['pyside2', 'all']:
- try:
- call(['pyside2-uic', '--from-imports', ui_file, '-o', py_file_pyside2])
- except Exception as er:
- print("You must install pyside2-uic %s" % str(er))
- else:
- print("Compiling using pyside2-uic ...")
-
- if args.create in ['qtpy', 'all']:
- print("Creating also for qtpy ...")
- # special case - qtpy - syntax is PyQt5
- with open(py_file_pyqt5, 'r') as file:
- filedata = file.read()
- # replace the target string
- filedata = filedata.replace('from PyQt5', 'from qtpy')
- with open(py_file_qtpy, 'w+') as file:
- # write the file out again
- file.write(filedata)
-
- if args.create in ['pyqtgraph', 'all']:
- print("Creating also for pyqtgraph ...")
- # special case - pyqtgraph - syntax is PyQt4
- with open(py_file_pyqt, 'r') as file:
- filedata = file.read()
- # replace the target string
- filedata = filedata.replace('from PyQt4', 'from pyqtgraph.Qt')
- with open(py_file_pyqtgraph, 'w+') as file:
- # write the file out again
- file.write(filedata)
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv[1:]))
+# -*- coding: utf-8 -*- +"""Script to process UI files (convert .ui to .py). + +It compiles .ui files to be used with PyQt4, PyQt5, PySide, QtPy, PyQtGraph. +You just need to run (it has default values) from script folder. + +To run this script you need to have these tools available on system: + + - pyuic4 for PyQt4 and PyQtGraph + - pyuic5 for PyQt5 and QtPy + - pyside-uic for Pyside + - pyside2-uic for Pyside2 + +Links to understand those tools: + + - pyuic4: http://pyqt.sourceforge.net/Docs/PyQt4/designer.html#pyuic4 + - pyuic5: http://pyqt.sourceforge.net/Docs/PyQt5/designer.html#pyuic5 + - pyside-uic: https://www.mankier.com/1/pyside-uic + - pyside2-uic: https://wiki.qt.io/Qt_for_Python_UiFiles (Documentation Incomplete) + +""" + +from __future__ import absolute_import, print_function + +import argparse +import glob +import os +import sys +from subprocess import call + + +def main(arguments): + """Process UI files.""" + parser = argparse.ArgumentParser(description=__doc__, + formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument('--ui_dir', + default='../example/ui', + type=str, + help="UI files directory, relative to current directory.",) + parser.add_argument('--create', + default='all', + choices=['pyqt', 'pyqt5', 'pyside', 'pyside2', 'qtpy', 'pyqtgraph', 'all'], + type=str, + help="Choose which one would be generated.") + + args = parser.parse_args(arguments) + + print('Changing directory to: ', args.ui_dir) + os.chdir(args.ui_dir) + + print('Converting .ui to .py ...') + + for ui_file in glob.glob('*.ui'): + # get name without extension + filename = os.path.splitext(ui_file)[0] + print(filename, '...') + ext = '.py' + + # creating names + py_file_pyqt5 = filename + '_pyqt5_ui' + ext + py_file_pyqt = filename + '_pyqt_ui' + ext + py_file_pyside = filename + '_pyside_ui' + ext + py_file_pyside2 = filename + '_pyside2_ui' + ext + py_file_qtpy = filename + '_qtpy_ui' + ext + py_file_pyqtgraph = filename + '_pyqtgraph_ui' + ext + + # calling external commands + if args.create in ['pyqt', 'pyqtgraph', 'all']: + try: + call(['pyuic4', '--from-imports', ui_file, '-o', py_file_pyqt]) + except Exception as er: + print("You must install pyuic4 %s" % str(er)) + else: + print("Compiling using pyuic4 ...") + + if args.create in ['pyqt5', 'qtpy', 'all']: + try: + call(['pyuic5', '--from-imports', ui_file, '-o', py_file_pyqt5]) + except Exception as er: + print("You must install pyuic5 %s" % str(er)) + else: + print("Compiling using pyuic5 ...") + + if args.create in ['pyside', 'all']: + try: + call(['pyside-uic', '--from-imports', ui_file, '-o', py_file_pyside]) + except Exception as er: + print("You must install pyside-uic %s" % str(er)) + else: + print("Compiling using pyside-uic ...") + + if args.create in ['pyside2', 'all']: + try: + call(['pyside2-uic', '--from-imports', ui_file, '-o', py_file_pyside2]) + except Exception as er: + print("You must install pyside2-uic %s" % str(er)) + else: + print("Compiling using pyside2-uic ...") + + if args.create in ['qtpy', 'all']: + print("Creating also for qtpy ...") + # special case - qtpy - syntax is PyQt5 + with open(py_file_pyqt5, 'r') as file: + filedata = file.read() + # replace the target string + filedata = filedata.replace('from PyQt5', 'from qtpy') + with open(py_file_qtpy, 'w+') as file: + # write the file out again + file.write(filedata) + + if args.create in ['pyqtgraph', 'all']: + print("Creating also for pyqtgraph ...") + # special case - pyqtgraph - syntax is PyQt4 + with open(py_file_pyqt, 'r') as file: + filedata = file.read() + # replace the target string + filedata = filedata.replace('from PyQt4', 'from pyqtgraph.Qt') + with open(py_file_pyqtgraph, 'w+') as file: + # write the file out again + file.write(filedata) + + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/contrib/QDarkStyleSheet/script/run_ui_css_edition.py b/contrib/QDarkStyleSheet/script/run_ui_css_edition.py index 4b8c2576..754f46c8 100755 --- a/contrib/QDarkStyleSheet/script/run_ui_css_edition.py +++ b/contrib/QDarkStyleSheet/script/run_ui_css_edition.py @@ -1,52 +1,52 @@ -#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-"""Process qrc and ui files, then run example in while loop."""
-
-from __future__ import absolute_import, print_function
-
-import sys
-from subprocess import call
-
-
-def main():
- """Process qrc and ui files, then run example in while loop."""
- dark = None
- no_dark = None
-
- while True:
- try:
- dark.kill()
- except AttributeError:
- print('Dark not running!')
- except Exception:
- print('Dark still running!')
- else:
- print('Dark was killed!')
-
- try:
- no_dark.kill()
- except AttributeError:
- print('No Dark not running!')
- except Exception:
- print('No Dark still running!')
- else:
- print('No Dark was killed!')
-
- print(sys.argv)
-
- # process qrc files
- call(['python', 'process_qrc.py'])
- # process ui files
- call(['python', 'process_ui.py'])
- # open dark example
- dark = call(['python', '../example/example.py'] + sys.argv[1:])
- # open no dark example
- no_dark = call(['python', '../example/example.py', '--no_dark'] + sys.argv[1:])
-
- if dark or no_dark:
- print('Unf! It not worked! Please, check the error(s).')
- break
-
-
-if __name__ == "__main__":
- sys.exit(main())
+#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""Process qrc and ui files, then run example in while loop.""" + +from __future__ import absolute_import, print_function + +import sys +from subprocess import call + + +def main(): + """Process qrc and ui files, then run example in while loop.""" + dark = None + no_dark = None + + while True: + try: + dark.kill() + except AttributeError: + print('Dark not running!') + except Exception: + print('Dark still running!') + else: + print('Dark was killed!') + + try: + no_dark.kill() + except AttributeError: + print('No Dark not running!') + except Exception: + print('No Dark still running!') + else: + print('No Dark was killed!') + + print(sys.argv) + + # process qrc files + call(['python', 'process_qrc.py']) + # process ui files + call(['python', 'process_ui.py']) + # open dark example + dark = call(['python', '../example/example.py'] + sys.argv[1:]) + # open no dark example + no_dark = call(['python', '../example/example.py', '--no_dark'] + sys.argv[1:]) + + if dark or no_dark: + print('Unf! It not worked! Please, check the error(s).') + break + + +if __name__ == "__main__": + sys.exit(main()) |
