コード例 #1
0
ファイル: __init__.py プロジェクト: satishgoda/breakingpoint
def compileUi(uifile, pyfile, execute=False, indent=4, from_imports=False):
    """compileUi(uifile, pyfile, execute=False, indent=4, from_imports=False)

    Creates a Python module from a Qt Designer .ui file.

    uifile is a file name or file-like object containing the .ui file.
    pyfile is the file-like object to which the Python code will be written to.
    execute is optionally set to generate extra Python code that allows the
    code to be run as a standalone application.  The default is False.
    indent is the optional indentation width using spaces.  If it is 0 then a
    tab is used.  The default is 4.
    from_imports is optionally set to generate import statements that are
    relative to '.'.
    """

    from time import ctime
    import PySide

    try:
        uifname = uifile.name
    except AttributeError:
        uifname = uifile

    indenter.indentwidth = indent

    global PySideToolsVersion
    pyfile.write(_header % (uifname, ctime(), __version__, PySide.__version__))

    winfo = compiler.UICompiler().compileUi(uifile, pyfile, from_imports)

    if execute:
        indenter.write_code(_display_code % winfo)
コード例 #2
0
    def _writeImportCode(self):
        imports = {}
        for widget in self._usedWidgets:
            _, module = self._widgets[widget]
            imports.setdefault(module, []).append(widget)

        for module, classes in imports.items():
            write_code("from %s import %s" % (module, ", ".join(classes)))
コード例 #3
0
    def _writeImportCode(self):
        imports = {}
        for widget in self._usedWidgets:
            _, module = self._widgets[widget]
            imports.setdefault(module, []).append(widget)

        for module, classes in imports.items():
            write_code("from %s import %s" % (module, ", ".join(classes)))
コード例 #4
0
 def __call__(self, *args):
     func_call = "%s.%s(%s)" % (self.proxy, self.function_name, ", ".join(
         map(as_string, args)))
     if self.flags & AS_ARGUMENT:
         self.proxy._uic_name = func_call
         return self.proxy
     else:
         needs_translation = False
         for arg in args:
             if isinstance(arg, i18n_string):
                 needs_translation = True
         if needs_translation:
             i18n_print(func_call)
         else:
             write_code(func_call)
コード例 #5
0
ファイル: qtproxies.py プロジェクト: olinord/live-editor
 def __call__(self, *args):
     func_call = "%s.%s(%s)" % (self.proxy,
                                self.function_name,
                                ", ".join(map(as_string, args)))
     if self.flags & AS_ARGUMENT:
         self.proxy._uic_name = func_call
         return self.proxy
     else:
         needs_translation = False
         for arg in args:
             if isinstance(arg, i18n_string):
                 needs_translation = True
         if needs_translation:
             i18n_print(func_call)
         else:
             write_code(func_call)
コード例 #6
0
ファイル: qtproxies.py プロジェクト: olinord/live-editor
    def __init__(self, objectname, is_attribute, args=(), noInstantiation=False):
        if objectname:
            if is_attribute:
                objectname = "self." + objectname

            self._uic_name = objectname
        else:
            self._uic_name = "Unnamed"

        if not noInstantiation:
            funcall = "%s(%s)" % \
                    (moduleMember(self.module, self.__class__.__name__),
                    ", ".join(map(str, args)))

            if objectname:
                funcall = "%s = %s" % (objectname, funcall)

            write_code(funcall)
コード例 #7
0
ファイル: qtproxies.py プロジェクト: lovejunjie1/mayaAPI
    def __init__(self, objectname, is_attribute, args=(), noInstantiation=False):
        if objectname:
            if is_attribute:
                objectname = "self." + objectname

            self._uic_name = objectname
        else:
            self._uic_name = "Unnamed"

        if not noInstantiation:
            funcall = "%s(%s)" % \
                    (moduleMember(self.module, self.__class__.__name__),
                    ", ".join(map(str, args)))

            if objectname:
                funcall = "%s = %s" % (objectname, funcall)

            write_code(funcall)
コード例 #8
0
ファイル: misc.py プロジェクト: Byron/bdep-pyside
def write_import(module_name, from_imports):
    if from_imports:
        write_code("from . import %s" % module_name)
    else:
        write_code("import %s" % module_name)
コード例 #9
0
 def _writeImportCode(self):
     if self._used:
         if self._package is None:
             write_code("import %s" % self._module)
         else:
             write_code("from %s import %s" % (self._package, self._module))
コード例 #10
0
 def _writeImportCode(self):
     if self._used:
         if self._package is None:
             write_code("import %s" % self._module)
         else:
             write_code("from %s import %s" % (self._package, self._module))
コード例 #11
0
 def setDelayedProps(self):
     write_code("")
     write_code("self.retranslateUi(%s)" % self.toplevelWidget)
     UIParser.setDelayedProps(self)
コード例 #12
0
ファイル: misc.py プロジェクト: tryanaditya/mainmain
def write_import(module_name, from_imports):
    if from_imports:
        write_code("from . import %s" % module_name)
    else:
        write_code("import %s" % module_name)
コード例 #13
0
ファイル: compiler.py プロジェクト: lovejunjie1/mayaAPI
 def setDelayedProps(self):
     write_code("")
     write_code("self.retranslateUi(%s)" % self.toplevelWidget)
     UIParser.setDelayedProps(self)