Пример #1
1
def compile():
    if getattr(sys, 'frozen', False):
        return

    from PyQt5 import uic

    print("Compiling all files unders %s" % os.path.abspath("."))
    uic.compileUiDir(".", recurse=True)
Пример #2
0
def compileUiFiles(dir, recurse=False):
    """
    Module function to compile the .ui files of a directory tree to Python
    sources.
    
    @param dir name of a directory to scan for .ui files (string)
    @param recurse flag indicating to recurse into subdirectories (boolean)
    """
    compileUiDir(dir, recurse, __pyName)
Пример #3
0
def gen_ui():
    from os import listdir, remove
    from os.path import join, isfile
    from PyQt5.uic import compileUiDir

    target_dir = "src/ui_templates"
    init_fname = "__init__.py"
    for item in listdir(target_dir):
        if item != init_fname and isfile(join(target_dir, item)):
            remove(join(target_dir, item))
    compileUiDir("resources/templates", map=lambda dir, fname: (target_dir, fname), from_imports=True)
Пример #4
0
def compileGUI(pyrcc_path=None, uic_path=".\\..\\Cube\\UI\\"):
    if not pyrcc_path:
        head, _ = os.path.split(sys.executable)
        pyrcc_path = os.path.join(head, r"Lib\site-packages\PyQt5\pyrcc5.exe")
    
    if os.path.exists( pyrcc_path ):
        print("Compiling Resources")
        cmd = "%s -o ./resources_rc.py ./resources.qrc -py3" % pyrcc_path
        os.system(cmd)
    else:
        print("Cannot find pyrcc5.exe")
    
    print("\nComping UI files")
    uic.compileUiDir(uic_path, recurse=True)
Пример #5
0
    def write_output(self, out_path, **kwargs):
        args = self.validate_arguments(kwargs, ["target_license", "version"])

        self.clear_output_dir(out_path)
        bolts_path = join(out_path, "BOLTS")

        # generate macro
        start_macro = open(join(out_path, "start_bolts.FCMacro"), "w")
        start_macro.write("import BOLTS\n")
        start_macro.write("BOLTS.show_widget()\n")
        start_macro.close()

        # copy files
        # bolttools
        if not license.is_combinable_with("LGPL 2.1+", args["target_license"]):
            raise IncompatibleLicenseError(
                "bolttools is LGPL 2.1+, which is not compatible with {}".
                format(args["target_license"]))
        copytree(join(self.repo.path, "bolttools"),
                 join(bolts_path, "bolttools"))
        # remove the test suite and documentation, to save space
        rmtree(join(bolts_path, "bolttools", "test_blt"))

        # generate version file
        date = datetime.now()
        version_file = open(join(bolts_path, "VERSION"), "w")
        version_file.write("{}\n{}-{}-{}\n{}\n".format(args["version"],
                                                       date.year, date.month,
                                                       date.day,
                                                       args["target_license"]))
        version_file.close()

        # freecad gui code
        if not license.is_combinable_with("LGPL 2.1+", args["target_license"]):
            raise IncompatibleLicenseError(
                "FreeCAD gui files are LGPL 2.1+, "
                "which is not compatible with {}".format(
                    args["target_license"]))
        if not exists(join(bolts_path, "freecad")):
            makedirs(join(bolts_path, "freecad"))
        if not exists(join(bolts_path, "data")):
            makedirs(join(bolts_path, "data"))
        open(join(bolts_path, "freecad", "__init__.py"), "w").close()

        copytree(join(self.repo.path, "backends", "freecad", "gui"),
                 join(bolts_path, "gui"))
        copytree(join(self.repo.path, "backends", "freecad", "assets"),
                 join(bolts_path, "assets"))
        copytree(join(self.repo.path, "icons"), join(bolts_path, "icons"))
        copyfile(join(self.repo.path, "backends", "freecad", "init.py"),
                 join(bolts_path, "__init__.py"))
        open(join(bolts_path, "gui", "__init__.py"), "w").close()

        # compile ui files
        uic.compileUiDir(join(bolts_path, "gui"))

        for coll, in self.repo.itercollections():
            if (not license.is_combinable_with(coll.license_name,
                                               args["target_license"])):
                continue
            copy(join(self.repo.path, "data", "%s.blt" % coll.id),
                 join(bolts_path, "data", "%s.blt" % coll.id))

            if not exists(join(bolts_path, "freecad", coll.id)):
                makedirs(join(bolts_path, "freecad", coll.id))

            if (not exists(
                    join(self.repo.path, "freecad", coll.id,
                         "%s.base" % coll.id))):
                continue

            copy(join(self.repo.path, "freecad", coll.id, "%s.base" % coll.id),
                 join(bolts_path, "freecad", coll.id, "%s.base" % coll.id))

            open(join(bolts_path, "freecad", coll.id, "__init__.py"),
                 "w").close()

            for base, in self.dbs["freecad"].iterbases(filter_collection=coll):
                if base.license_name not in license.LICENSES:
                    continue
                if (not license.is_combinable_with(base.license_name,
                                                   args["target_license"])):
                    continue
                copy(
                    join(self.repo.path, "freecad", coll.id,
                         basename(base.filename)),
                    join(bolts_path, "freecad", coll.id,
                         basename(base.filename)))
Пример #6
0
def compileUiFiles(dir, recurse=False):
    """
    Module function to compile the .ui files of a directory tree to Python
    sources.
    
    @param dir name of a directory to scan for .ui files (string)
    @param recurse flag indicating to recurse into subdirectories (boolean)
    """                                                 # __IGNORE_WARNING__
    try:
        from PyQt5.uic import compileUiDir
    except ImportError:
        from PyQt5.uic import compileUi

        def compileUiDir(
                dir,
                recurse=False,  # __IGNORE_WARNING__
                map=None,
                **compileUi_args):
            """
            Creates Python modules from Qt Designer .ui files in a directory or
            directory tree.
            
            Note: This function is a modified version of the one found in
            PyQt5.

            @param dir Name of the directory to scan for files whose name ends
                with '.ui'. By default the generated Python module is created
                in the same directory ending with '.py'.
            @param recurse flag indicating that any sub-directories should be
                scanned.
            @param map an optional callable that is passed the name of the
                directory containing the '.ui' file and the name of the Python
                module that will be created. The callable should return a tuple
                of the name of the directory in which the Python module will be
                created and the (possibly modified) name of the module.
            @param compileUi_args any additional keyword arguments that are
                passed to the compileUi() function that is called to create
                each Python module.
            """
            def compile_ui(ui_dir, ui_file):
                """
                Local function to compile a single .ui file.
                
                @param ui_dir directory containing the .ui file (string)
                @param ui_file file name of the .ui file (string)
                """
                # Ignore if it doesn't seem to be a .ui file.
                if ui_file.endswith('.ui'):
                    py_dir = ui_dir
                    py_file = ui_file[:-3] + '.py'

                    # Allow the caller to change the name of the .py file or
                    # generate it in a different directory.
                    if map is not None:
                        py_dir, py_file = list(map(py_dir, py_file))

                    # Make sure the destination directory exists.
                    try:
                        os.makedirs(py_dir)
                    except:
                        pass

                    ui_path = os.path.join(ui_dir, ui_file)
                    py_path = os.path.join(py_dir, py_file)

                    ui_file = open(ui_path, 'r')
                    py_file = open(py_path, 'w')

                    try:
                        compileUi(ui_file, py_file, **compileUi_args)
                    finally:
                        ui_file.close()
                        py_file.close()

            if recurse:
                for root, _, files in os.walk(dir):
                    for ui in files:
                        compile_ui(root, ui)
            else:
                for ui in os.listdir(dir):
                    if os.path.isfile(os.path.join(dir, ui)):
                        compile_ui(dir, ui)

    def pyName(py_dir, py_file):
        """
        Local function to create the Python source file name for the compiled
        .ui file.
        
        @param py_dir suggested name of the directory (string)
        @param py_file suggested name for the compile source file (string)
        @return tuple of directory name (string) and source file name (string)
        """
        return py_dir, "Ui_{0}".format(py_file)

    compileUiDir(dir, recurse, pyName)
Пример #7
0
def compileUIC():
    uic.compileUiDir('./')
Пример #8
0
from PyQt5 import uic

if __name__ == "__main__":
    uic.compileUiDir("ui")
Пример #9
0
Файл: setup.py Проект: le717/ICU
"""


import os
import sys
import subprocess
from cx_Freeze import (setup, Executable)

from src import constants as const
# from Tools.bin import (copyfiles, runasadmin)

# Only compile GUI on full build
if sys.argv[1] == "build":
    print("Generating GUI resources")
    from PyQt5 import uic
    uic.compileUiDir("src/ui")
    subprocess.call(["pyrcc5", "src/ui/graphics.qrc", "-o", "graphics_rc.py"])

if sys.platform == "win32":
    if sys.maxsize < 2 ** 32:
        destFolder = os.path.join("bin", "Windows", "x86")
    else:
        destFolder = os.path.join("bin", "Windows", "x64")

else:
    print("{0} is not supported on non Windows OS!".format(const.APP_NAME))
    raise SystemExit(0)

# Create the freeze path if it doesn't exist
if not os.path.exists(destFolder):
    os.makedirs(destFolder)
Пример #10
0
from PyQt5 import uic

uic.compileUiDir(".")
Пример #11
0
"""
Compiles PyQt UI templates found in SRC and places the corresponding compiled
Python modules in DEST. Output files have the same name, but have a `.py`
extension instead of `.ui`.
"""

import os
from PyQt5 import uic

SRC = '.'
DEST = '.'

if __name__ == '__main__':
    uic.compileUiDir(SRC, map=lambda src, name: (DEST, name))
Пример #12
0
import sys, os
from PyQt5 import uic

os.chdir(os.path.dirname(sys.argv[0]))
uic.compileUiDir('yt_downloader_gui')
Пример #13
0
from PyQt5 import uic

uic.compileUiDir("UI")
Пример #14
0
import os
from PyQt5.uic import compileUiDir

try:
    compileUiDir(os.getcwd() + '\\ui_files')
    #compileUiDir(os.getcwd()+'\\resources')
except Exception as err:
    print(err)
Пример #15
0
def recompile(folder):
    print('recompiling')
    uic.compileUiDir(folder, execute=True)
    print('done')
Пример #16
0
#!/usr/bin/env python3

from PyQt5 import uic


def c(d, f):
    f = f[:-3] + "_ui" + f[-3:]
    return d, f


uic.compileUiDir("ui", map=c)
Пример #17
0
from PyQt5 import uic
uic.compileUiDir('kniffel_gui')
Пример #18
0
from PyQt5.QtGui import *
from RigLib.pes16crypto import EditFile


# Application information #TODO: do this correctly and in a more practical way
name = 'RigIt'
version = '0.4.0'
wiki = 'https://implyingrigged.info/wiki/RigIt'
repository = 'https://github.com/the4chancup/RigIt/'
welcomeText = '''WARNING: this tool is in its beta phase and may not work
correctly. Backup before editing and be careful!'''

if __name__ == '__main__':
    # Compile *.ui files (only if not run as a stand-alone)
    if (not hasattr(sys, "frozen") and not imp.is_frozen("__main__")):
        uic.compileUiDir('ui')

    # Prepare main window
    from modules.mainwindow import MainWindow # import after compilation
    app = QApplication(sys.argv)
    mainWindow = MainWindow()
    mainWindow.setWindowTitle(name + ' v' + version)

    # Prepare status bar
    versionString = '<a href=\'' + repository + '\'>' + 'v' + version + '</a>'
    versionLabel = QLabel(versionString)
    versionLabel.setOpenExternalLinks(True)
    mainWindow.statusbar.insertPermanentWidget(0, versionLabel)
    websiteLabel = QLabel('<a href=\'' + wiki + '\'>' + wiki + '</a>')
    websiteLabel.setOpenExternalLinks(True)
    mainWindow.statusbar.insertPermanentWidget(0, websiteLabel)
Пример #19
0
def main():

    app = QtWidgets.QApplication([])
    win = QtWidgets.QMainWindow()
    myWidget = MyMainWidgetArm()
    win.setCentralWidget(myWidget)

    win.show()

    #    win.raise_()

    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()


#    try:
#       sys.exit(app.exec_())
#    except KeyboardInterrupt:
#        print("Bye!")

if __name__ == "__main__":
    from PyQt5.uic import compileUiDir
    from PyQt5 import QtCore, QtGui, QtWidgets
    import sys
    import os
    #compile before import
    compileUiDir(os.getcwd())
    from myMainWidgetArm import MyMainWidgetArm

    main()
Пример #20
0
# GLOBALS #
########################################################################################################################

PLAYGROUND_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'playground')
sys.path.insert(0, os.path.join(PLAYGROUND_DIR, 'src'))
QDir.setCurrent(PLAYGROUND_DIR)

def compile_map(d, f):
    return 'src/playground/ui/', f

QIcon.setThemeSearchPaths([os.path.join(PLAYGROUND_DIR, 'icons')])
QIcon.setThemeName('Faenza')

########
# MAIN #
########################################################################################################################

if __name__ == '__main__':

    # good for develop and first run.
    compileUiDir(
        dir='ui',
        recurse=True,
        map=compile_map
    )

    from playground.main import main
    main()

########################################################################################################################
Пример #21
0
# python -m PyQt5.uic.pyuic -x [FILENAME].ui -o [FILENAME].py
from PyQt5 import uic


def get_target(dir, name):
    return ('./package/ui/widgets', name)


uic.compileUiDir('./views', recurse=True, map=get_target)
Пример #22
0
print("Updating version numbers to version {} ...".format(VERSION))

# Update version numbers in .iss files
for i in isspath:
    process_iss(i)

# disable all debug variables:
for i in pypath:
    disable_debug(i)

print("Version numbers updated.")

try:
    print(os.path.abspath('./gui'))
    uic.compileUiDir('./gui')
    print('recompiled ui')
except:
    print("Unable to compile UI!")
    raise


def make_distribs():
    # create binary distribution of 64bit variant:
    subprocess.run(['venv2/Scripts/pyinstaller.exe',
                    '--clean',
                    '-p',
                    r'D:\Programme\Windows Kits\10\Redist\ucrt\DLLs\x64',
                    r'--add-binary=C:\tools\opengl64\opengl32sw.dll;opengl32sw.dll',
                    r'--add-data=gui;gui',
                    r'--add-data=displaymol;displaymol',
Пример #23
0
def compileUiFiles(dir, recurse=False):
    """
    Module function to compile the .ui files of a directory tree to Python
    sources.
    
    @param dir name of a directory to scan for .ui files (string)
    @param recurse flag indicating to recurse into subdirectories (boolean)
    """                                                 # __IGNORE_WARNING__
    try:
        from PyQt5.uic import compileUiDir
    except ImportError:
        from PyQt5.uic import compileUi
        
        def compileUiDir(dir, recurse=False,            # __IGNORE_WARNING__
                         map=None, **compileUi_args):
            """
            Creates Python modules from Qt Designer .ui files in a directory or
            directory tree.
            
            Note: This function is a modified version of the one found in
            PyQt5.

            @param dir Name of the directory to scan for files whose name ends
                with '.ui'. By default the generated Python module is created
                in the same directory ending with '.py'.
            @param recurse flag indicating that any sub-directories should be
                scanned.
            @param map an optional callable that is passed the name of the
                directory containing the '.ui' file and the name of the Python
                module that will be created. The callable should return a tuple
                of the name of the directory in which the Python module will be
                created and the (possibly modified) name of the module.
            @param compileUi_args any additional keyword arguments that are
                passed to the compileUi() function that is called to create
                each Python module.
            """
            def compile_ui(ui_dir, ui_file):
                """
                Local function to compile a single .ui file.
                
                @param ui_dir directory containing the .ui file (string)
                @param ui_file file name of the .ui file (string)
                """
                # Ignore if it doesn't seem to be a .ui file.
                if ui_file.endswith('.ui'):
                    py_dir = ui_dir
                    py_file = ui_file[:-3] + '.py'

                    # Allow the caller to change the name of the .py file or
                    # generate it in a different directory.
                    if map is not None:
                        py_dir, py_file = list(map(py_dir, py_file))

                    # Make sure the destination directory exists.
                    try:
                        os.makedirs(py_dir)
                    except:
                        pass

                    ui_path = os.path.join(ui_dir, ui_file)
                    py_path = os.path.join(py_dir, py_file)

                    ui_file = open(ui_path, 'r')
                    py_file = open(py_path, 'w')

                    try:
                        compileUi(ui_file, py_file, **compileUi_args)
                    finally:
                        ui_file.close()
                        py_file.close()

            if recurse:
                for root, _, files in os.walk(dir):
                    for ui in files:
                        compile_ui(root, ui)
            else:
                for ui in os.listdir(dir):
                    if os.path.isfile(os.path.join(dir, ui)):
                        compile_ui(dir, ui)

    def pyName(py_dir, py_file):
        """
        Local function to create the Python source file name for the compiled
        .ui file.
        
        @param py_dir suggested name of the directory (string)
        @param py_file suggested name for the compile source file (string)
        @return tuple of directory name (string) and source file name (string)
        """
        return py_dir, "Ui_{0}".format(py_file)
    
    compileUiDir(dir, recurse, pyName)
Пример #24
0
def recompile():
    print('recompiling')
    ui_file = '.\lib\StepScan_GUI.ui'
    ui_dir = '.\lib'
    uic.compileUiDir(ui_dir, execute=True)
    print('done')
Пример #25
0
def compileUIC():
    uic.compileUiDir('./')
Пример #26
0
        files_list = []
        self.ui.OutputTextEdit.clear()
        for num in range(self.ui.CifFileListListWidget.count()):
            item = self.ui.CifFileListListWidget.item(num)
            itemtxt = item.text()
            files_list.append(Path(itemtxt))
            self.ui.OutputTextEdit.append(Path(itemtxt).name)
        if not files_list:
            return
        output_filename, _ = QFileDialog.getSaveFileName(
            filter='MS Word Documents (*.docx);;',
            caption="Save Table To",
            directory='./multitable.docx')
        # initialFilter='*.docx')
        multitable.make_report_from(files_list, output_filename)
        self.ui.OutputTextEdit.append(
            '\nReport finished - output file: {}'.format(output_filename))
        self.open_report_document(output_filename)
        self.ui.CifFileListListWidget.clear()


if __name__ == '__main__':
    if DEBUG:
        uic.compileUiDir(os.path.join(application_path, './gui'))
    from gui.mainwindow import Ui_MultitableWindow

    app = QApplication(sys.argv)
    w = AppWindow()
    w.show()
    sys.exit(app.exec_())
Пример #27
0
"""

import os
import sys
import subprocess
from cx_Freeze import (setup, Executable)

from src import constants as const
# from Tools.bin import (copyfiles, runasadmin)

# Only compile GUI on full build
if sys.argv[1] == "build":
    print("Generating GUI resources")
    from PyQt5 import uic
    uic.compileUiDir("src/ui")
    subprocess.call(["pyrcc5", "src/ui/graphics.qrc", "-o", "graphics_rc.py"])

if sys.platform == "win32":
    if sys.maxsize < 2**32:
        destFolder = os.path.join("bin", "Windows", "x86")
    else:
        destFolder = os.path.join("bin", "Windows", "x64")

else:
    print("{0} is not supported on non Windows OS!".format(const.APP_NAME))
    raise SystemExit(0)

# Create the freeze path if it doesn't exist
if not os.path.exists(destFolder):
    os.makedirs(destFolder)
Пример #28
0
#!/usr/bin/python3
__author__ = 'alex'

from PyQt5.uic import compileUiDir

compileUiDir(".")
Пример #29
0
#! /usr/bin/python
# -*- coding: utf-8 -*-

"""
Utility to convert .ui files into python modules
"""

from PyQt5 import uic

uic.compileUiDir('./PyCreator',True)
Пример #30
0
import os
import shutil

from PyQt5.uic import compileUiDir

for root, dirs, files in os.walk("./"):
    for dirname in dirs:
        compileUiDir(dirname)

shutil.move("./mainwin/mainwindow.py", "../ui/mainwindow.py")