本文整理汇总了Python中pysideuic.compileUi函数的典型用法代码示例。如果您正苦于以下问题:Python compileUi函数的具体用法?Python compileUi怎么用?Python compileUi使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了compileUi函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_pyside_class
def get_pyside_class( ui_file ):
"""
Pablo Winant
"""
parsed = xml.parse( ui_file )
#print parsed
widget_class = parsed.find( 'widget' ).get( 'class' )
form_class = parsed.find( 'class' ).text
#print widget_class, form_class
with open( ui_file, 'r' ) as f:
print f
o = StringIO()
frame = {}
try:
pysideuic.compileUi( f, o, indent = 0 )
except:
print 'errroorrrrr'
pyc = compile( o.getvalue(), '<string>', 'exec' )
exec pyc in frame
# Fetch the base_class and form class based on their type in the xml from designer
form_class = frame['Ui_{0}'.format( form_class )]
base_class = eval( 'QtGui.{0}'.format( widget_class ) )
return form_class, base_class
开发者ID:Mortaciunea,项目名称:bdScripts,代码行数:27,代码来源:pyside_util.py
示例2: loadUiType
def loadUiType(ui_file):
from wishlib.qt import active, QtGui
if active == "PySide":
import pysideuic
parsed = xml.parse(ui_file)
widget_class = parsed.find('widget').get('class')
form_class = parsed.find('class').text
with open(ui_file, 'r') as f:
o = StringIO()
frame = {}
pysideuic.compileUi(f, o, indent=0)
pyc = compile(o.getvalue(), '<string>', 'exec')
exec pyc in frame
# Fetch the base_class and form class based on their type in the
# xml from designer
form_class = frame['Ui_%s' % form_class]
# base_class = eval('QtGui.%s' % widget_class)
base_class = getattr(QtGui, widget_class)
return form_class, base_class
elif active == "PyQt4":
from PyQt4 import uic
return uic.loadUiType(ui_file)
return None
开发者ID:csaez,项目名称:wishlib,代码行数:26,代码来源:helpers.py
示例3: _load_ui_type
def _load_ui_type(ui_file):
"""Load a ui file for PySide.
PySide lacks the "_load_ui_type" command, so we have to convert
the UI file to python code in-memory first and then execute it in a
special frame to retrieve the form_class.
Args:
ui_file (str): The .ui file.
Returns:
The base and form class, derived from the .ui file.
"""
parsed = xml.parse(ui_file)
widget_class = parsed.find('widget').get('class')
form_class = parsed.find('class').text
with open(ui_file, 'r') as f:
o = StringIO()
frame = {}
pysideuic.compileUi(f, o, indent=0)
pyc = compile(o.getvalue(), '<string>', 'exec')
exec pyc in frame
# Fetch the base_class and form_class based on their type
# in the xml from designer
base_class = getattr(QtWidgets, widget_class)
form_class = frame['Ui_%s' % form_class]
return base_class, form_class
开发者ID:PaulSchweizer,项目名称:PySideWidgetCollection,代码行数:27,代码来源:utility.py
示例4: loadUiType
def loadUiType(uiFile):
"""
Pyside "loadUiType" command like PyQt4 has one, so we have to convert
the ui file to py code in-memory first and then execute it in a
special frame to retrieve the form_class.
from stackoverflow: http://stackoverflow.com/a/14195313/3781327
seems like this might also be a legitimate solution, but I'm not sure
how to make PyQt4 and pyside look the same...
http://stackoverflow.com/a/8717832
"""
import pysideuic
import xml.etree.ElementTree as xml
# from io import StringIO
parsed = xml.parse(uiFile)
widget_class = parsed.find("widget").get("class")
form_class = parsed.find("class").text
with open(uiFile, "r") as f:
o = StringIO()
frame = {}
pysideuic.compileUi(f, o, indent=0)
pyc = compile(o.getvalue(), "<string>", "exec")
exec(pyc, frame)
# Fetch the base_class and form class based on their type in the xml from designer
form_class = frame["Ui_%s" % form_class]
base_class = eval("QtGui.%s" % widget_class)
return form_class, base_class
开发者ID:mainczjs,项目名称:Playground,代码行数:34,代码来源:Qt.py
示例5: loadUiType
def loadUiType(uiFile):
"""
Pyside lacks the "loadUiType" command, so we have to convert the ui file to py code in-memory first
and then execute it in a special frame to retrieve the form_class.
"""
parsed = xml.parse(uiFile)
widget_class = parsed.find("widget").get("class")
form_class = parsed.find("class").text
with open(uiFile, "r") as f:
o = StringIO()
frame = {}
if QtType == "PySide":
pysideuic.compileUi(f, o, indent=0)
pyc = compile(o.getvalue(), "<string>", "exec")
exec pyc in frame
# Fetch the base_class and form class based on their type in the xml from designer
form_class = frame["Ui_%s" % form_class]
base_class = eval("QtGui.%s" % widget_class)
elif QtType == "PyQt":
form_class = PyQtFixer
base_class = QtGui.QMainWindow
return form_class, base_class
开发者ID:BenoitValdes,项目名称:PipelineTools_Maya,代码行数:25,代码来源:mirorBlenshape.py
示例6: loadUiType
def loadUiType(cls, uifile, respath=None):
"""
Pyside lacks the "loadUiType" command, so we have to convert the ui file to py code in-memory first
and then execute it in a special frame to retrieve the form_class.
"""
parsed = xml.parse(uifile)
widget_class = parsed.find('widget').get('class')
form_class = parsed.find('class').text
with open(uifile, 'r') as f:
o = StringIO()
frame = {}
pysideuic.compileUi(f, o, indent=0)
pyc = compile(o.getvalue(), '<string>', 'exec')
hasres = respath and respath not in sys.path
if hasres:
sys.path.append(respath)
exec(pyc, frame)
if hasres:
sys.path.remove(respath)
#Fetch the base_class and form class based on their type in the xml from designer
form_class = frame['Ui_%s'%form_class]
base_class = eval('PySide.QtGui.%s'%widget_class)
return form_class, base_class
开发者ID:dbarsam,项目名称:kousen,代码行数:29,代码来源:uiloader.py
示例7: loadUiType
def loadUiType(uiFile):
"""
Pyside "loadUiType" command like PyQt4 has one, so we have to convert the ui file to py code in-memory first and then execute it in a special frame to retrieve the form_class.
"""
import pysideuic
import xml.etree.ElementTree as xml
#from io import StringIO
parsed = xml.parse(uiFile)
widget_class = parsed.find('widget').get('class')
form_class = parsed.find('class').text
with open(uiFile, 'r') as f:
o = StringIO()
frame = {}
pysideuic.compileUi(f, o, indent=0)
pyc = compile(o.getvalue(), '<string>', 'exec')
exec(pyc, frame)
#Fetch the base_class and form class based on their type in the xml from designer
form_class = frame['Ui_%s'%form_class]
base_class = eval('QtGui.%s'%widget_class)
return form_class, base_class
开发者ID:jensengrouppsu,项目名称:rapid,代码行数:25,代码来源:Qt.py
示例8: compile_ui
def compile_ui(self, ui_file, py_file=None):
"""Compile the .ui files to python modules."""
self._wrapuic(i18n_module=self.i18n_module)
if py_file is None:
py_file = os.path.join(
self.output_dir,
os.path.basename(ui_file).replace(
'.ui', self.generated_extension
).lower()
)
fi = open(ui_file, 'r')
fo = open(py_file, 'wt')
try:
from pysideuic import compileUi
compileUi(fi, fo, execute=self.ui_execute, indent=self.indent,
from_imports=self.from_imports)
log.info("Compiled %s into %s", ui_file, py_file)
except ImportError:
log.warn("You need to have pyside-tools installed in order to "
"compile .ui files.")
except Exception, err:
log.warn("Failed to generate %r from %r: %s", py_file, ui_file, err)
if not os.path.exists(py_file) or not not file(py_file).read():
raise SystemExit(1)
return
开发者ID:UfSoft,项目名称:captcha-trader-qt-client,代码行数:26,代码来源:setup.py
示例9: load_ui_type
def load_ui_type(UI_FILE):
'''
Pyside lacks the "load_ui_type" command, so we have to convert the ui file
to py code in-memory first and then execute it in a special frame to
retrieve the form_class.
'''
parsed = xml.parse(UI_FILE)
widget_class = parsed.find('widget').get('class')
form_class = parsed.find('class').text
with open(UI_FILE, 'r') as f:
o = StringIO()
frame = {}
if QT_BINDINGS == 'PySide':
pysideuic.compileUi(f, o, indent=0)
pyc = compile(o.getvalue(), '<string>', 'exec')
exec pyc in frame
# Fetch the base_class and form class based on their type in the xml
# from designer
form_class = frame['Ui_%s'%form_class]
base_class = eval('QtGui.%s'%widget_class)
elif QT_BINDINGS == 'PyQt':
form_class = PyQtFixer
base_class = QtGui.QMainWindow
return form_class, base_class
开发者ID:vorcil,项目名称:pyVFX-boilerplate,代码行数:27,代码来源:boilerplate.py
示例10: loadUiType
def loadUiType(ui_file):
"""
Pyside lacks the "loadUiType" command, so we have to convert the ui file
to py code in-memory first and then execute it in a special frame to
retrieve the form_class.
Usage:
>>> class SomeDialog(loadUiType('some_dialog.ui')):
>>> def __init__(self, *args, **kwargs):
>>> super(SomeDialog, self).__init__(*args, **kwargs)
"""
parsed = xml.parse(ui_file)
widget_class = parsed.find('widget').get('class')
form_class = parsed.find('class').text
with open(ui_file, 'r') as f:
o = StringIO()
frame = {}
pysideuic.compileUi(f, o, indent=0)
pyc = compile(o.getvalue(), '<string>', 'exec')
exec pyc in frame
# Fetch the base_class and form class based on their type in the xml
# from designer
form_class = frame['Ui_%s' % form_class]
base_class = eval('QtGui.%s' % widget_class)
return type('PySideUI', (form_class, base_class), {})
开发者ID:arubertoson,项目名称:maya-mampy,代码行数:30,代码来源:utils.py
示例11: loadUiType
def loadUiType(ui_file):
"""
Pyside lacks the "loadUiType" command, so we have to convert
the ui file to py code in-memory first and then execute it in
a special frame to retrieve the form_class.
"""
parsed = xml.parse(ui_file)
widget_class = parsed.find('widget').get('class')
form_class = parsed.find('class').text
with open(ui_file, 'r') as f:
o = StringIO()
frame = {}
pysideuic.compileUi(f, o, indent=0)
pyc = compile(o.getvalue(), '<string>', 'exec')
exec pyc in frame
# Fetch the base_class and form_class based on their type
# in the xml from designer
form_class = frame['Ui_%s' % form_class]
base_class = eval('QtGui.%s' % widget_class)
return form_class, base_class
开发者ID:remusvrm,项目名称:scripts,代码行数:25,代码来源:loadUiType.py
示例12: convert
def convert(input_file):
if not input_file.endswith(".ui"):
return False
output_file = os.path.join(os.path.dirname(input_file),
os.path.basename(input_file).replace(".ui", ".py"))
with open(output_file, 'w') as fp:
compileUi(input_file, fp, False, 4, False)
return output_file
开发者ID:csaez,项目名称:mauto,代码行数:8,代码来源:pyside-uic.py
示例13: generateUi
def generateUi(uifname, pyfname, execute, indent):
if pyfname == "-":
pyfile = sys.stdout
else:
pyfile = file(pyfname, "w")
pysideuic.compileUi(uifname, pyfile, execute, indent)
return 0
开发者ID:highchen,项目名称:grblfeedr,代码行数:8,代码来源:_pyuic.py
示例14: compileUI
def compileUI():
from pysideuic import compileUi
moduleName = __name__.split('.')[0]
modulePath = os.path.abspath(imp.find_module(moduleName)[1])
pyfile = open(modulePath+'\\mainWindow.py', 'w')
compileUi(modulePath+"\\mainWindow.ui", pyfile, False, 4,False)
pyfile.close()
开发者ID:DavideAlidosi,项目名称:May9,代码行数:8,代码来源:utils.py
示例15: compileUIFiles
def compileUIFiles(uiDir):
for name in os.listdir(uiDir):
uiFilePath = os.path.join(uiDir, name)
if os.path.isfile(uiFilePath):
if name.endswith(".ui"):
uiResultPath = (name[:-3] + ".py").lower()
with open(os.path.join(uiDir, uiResultPath), "w") as f:
compileUi(uiFilePath, f)
开发者ID:Bertram25,项目名称:ceed,代码行数:10,代码来源:compileuifiles.py
示例16: load_ui_type
def load_ui_type(ui_file):
"""
Pyside lacks the "loadUiType" command, so we have to convert the ui file to py code in-memory first
and then execute it in a special frame to retrieve the form_class.
This function return the form and base classes for the given qtdesigner ui file.
"""
# add path for pysideuic
import sys
sys.path.append(THIRD_PARTY_PATH)
# lazy import
try:
# python
import os
import logging
import re
import shutil
from cStringIO import StringIO
import xml.etree.ElementTree as xml
import types
# PySide
from PySide import QtGui
from PySide import QtCore
from PySide import QtUiTools
import pysideuic
except Exception as exception_instance:
# log
logger.debug('Import failed: {0}'.format(exception_instance))
# return None
return None
# compile ui
parsed = xml.parse(ui_file)
widget_class = parsed.find('widget').get('class')
form_class = parsed.find('class').text
with open(ui_file, 'r') as f:
o = StringIO()
frame = {}
pysideuic.compileUi(f, o, indent=0)
pyc = compile(o.getvalue(), '<string>', 'exec')
exec pyc in frame
# Fetch the base_class and form class based on their type in the xml from designer
form_class = frame['Ui_%s' % form_class]
base_class = eval('QtGui.%s' % widget_class)
return form_class, base_class
开发者ID:Quazo,项目名称:breakingpoint,代码行数:53,代码来源:renderthreads_gui_helper.py
示例17: rebuild_pyui_file
def rebuild_pyui_file(filename):
uifile_patch = LTK_PATCH + LGT_UI_PATCH + filename
pyfile_patch = LTK_PATCH + LGT_PYUI_PATCH + filename.split(".")[0] + ".py"
uifile_time = os.path.getmtime(uifile_patch)
pyfile_time = os.path.isfile(pyfile_patch) == True and os.path.getmtime(pyfile_patch) or 0
if pyfile_time < uifile_time:
uifile = open(uifile_patch, "r")
pyfile = open(pyfile_patch, "w")
uic.compileUi(uifile, pyfile)
print "RECOMPILE: " + LTK_PATCH + LGT_UI_PATCH + filename
uifile.close()
pyfile.close()
开发者ID:k0k0c,项目名称:scripts,代码行数:12,代码来源:ui_to_py.py
示例18: compile_if_necessary
def compile_if_necessary(input_ui_file,output_py_file):
#prepare the file names
input_path = module_folder+input_ui_file
output_path = module_folder+output_py_file
#recompile the .ui Qt file if this script is launched directly
#or if the compiled .py GUI file does not exist
#or if it is more recent than the compiled .py GUI file,
#if __name__=='__main__' or not(os.path.isfile(output_path)) or os.path.getmtime(input_path)>os.path.getmtime(output_path):
if not(os.path.isfile(output_path)) or os.path.getmtime(input_path)>os.path.getmtime(output_path):
print "update detected: recompiling "+input_ui_file
f=open(output_path,"w")
pysideuic.compileUi(input_path,f)
f.close()
开发者ID:Argonne-National-Laboratory,项目名称:PyGMI,代码行数:13,代码来源:__init__.py
示例19: main
def main():
for root, dirs, files in os.walk(os.path.abspath(CURRENT_DIR)):
for f in files:
print f
if f.lower().endswith(".qrc"):
name = os.path.basename(f).split(".")[0] + ".py"
subprocess.call([PYSIDE_RCC_EXE, os.path.join(root, f), "-o", os.path.join(OUTPUT_DIR, name)])
if f.lower().endswith(".ui"):
name = os.path.basename(f).split(".")[0] + ".py"
ui_path = os.path.join(root, f)
pyfile = open(os.path.join(OUTPUT_DIR, name), 'w')
compileUi(ui_path, pyfile, False, 4, False)
pyfile.close()
开发者ID:thirstydevil,项目名称:tk-multi-versioner,代码行数:14,代码来源:build_resources.py
示例20: load_ui_type
def load_ui_type(ui_file):
parsed= xml.parse(ui_file)
widget_class =parsed.find('widget').get('class')
form_class =parsed.find('class').text
with open(ui_file,'r') as f:
o= StringIO()
frame={}
pysideuic.compileUi(f,o,indent=0)
pyc= compile(o.getvalue(), '<string>', 'exec')
exec pyc in frame
form_class = frame ['Ui_{0}'.format (form_class)]
base_class = eval( 'QtGui.{0}'.format(widget_class))
return form_class, base_class
开发者ID:RobRuckus,项目名称:rcTools,代码行数:15,代码来源:loadUI.py
注:本文中的pysideuic.compileUi函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论