本文整理汇总了Python中PySide2.QtUiTools.QUiLoader方法的典型用法代码示例。如果您正苦于以下问题:Python QtUiTools.QUiLoader方法的具体用法?Python QtUiTools.QUiLoader怎么用?Python QtUiTools.QUiLoader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide2.QtUiTools
的用法示例。
在下文中一共展示了QtUiTools.QUiLoader方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _pyside2
# 需要导入模块: from PySide2 import QtUiTools [as 别名]
# 或者: from PySide2.QtUiTools import QUiLoader [as 别名]
def _pyside2():
import PySide2
from PySide2 import QtGui, QtWidgets, QtCore, QtUiTools
_remap(QtCore, "QStringListModel", QtGui.QStringListModel)
_add(PySide2, "__binding__", PySide2.__name__)
_add(PySide2, "load_ui", lambda fname: QtUiTools.QUiLoader().load(fname))
_add(PySide2, "translate", lambda context, sourceText, disambiguation, n: (
QtCore.QCoreApplication(context, sourceText,
disambiguation, None, n)))
_add(PySide2,
"setSectionResizeMode",
QtWidgets.QHeaderView.setSectionResizeMode)
_maintain_backwards_compatibility(PySide2)
return PySide2
示例2: _pyside2
# 需要导入模块: from PySide2 import QtUiTools [as 别名]
# 或者: from PySide2.QtUiTools import QUiLoader [as 别名]
def _pyside2():
import PySide2
from PySide2 import QtGui, QtWidgets, QtCore, QtUiTools
_remap(QtCore, "QStringListModel", QtGui.QStringListModel)
_add(QtCompat, "__binding__", PySide2.__name__)
_add(QtCompat, "__binding_version__", PySide2.__version__)
_add(QtCompat, "__qt_version__", PySide2.QtCore.qVersion())
_add(QtCompat, "load_ui", lambda fname: QtUiTools.QUiLoader().load(fname))
_add(QtCompat, "setSectionResizeMode",
QtWidgets.QHeaderView.setSectionResizeMode)
_add(QtCompat, "translate", QtCore.QCoreApplication.translate)
_maintain_backwards_compatibility(PySide2)
return PySide2
示例3: _pyside_loadui
# 需要导入模块: from PySide2 import QtUiTools [as 别名]
# 或者: from PySide2.QtUiTools import QUiLoader [as 别名]
def _pyside_loadui(fname):
'''
this function is for PySide load_ui bug when there are custom widgets in the ui file
'''
import PySide.QtUiTools as QtUiTools
import importlib
loader = QtUiTools.QUiLoader()
# get custom_widget
with open(fname) as ui_file:
all_xml = ui_file.read()
custom_wgt_xmls = re.findall(r'<customwidget>.*?</customwidget>', all_xml, re.S)
for cus_wgt_xml in custom_wgt_xmls:
class_search = re.search(r"<class>(.*?)</class>", cus_wgt_xml, re.S)
class_name = class_search.group(1)
module_search = re.search(r"<header.*>(.*?)</header>", cus_wgt_xml, re.S)
module_name = module_search.group(1).replace("/", ".")
# import and register
module = importlib.import_module(module_name)
loader.registerCustomWidget(getattr(module, class_name))
return loader.load(fname)
示例4: _pyside
# 需要导入模块: from PySide2 import QtUiTools [as 别名]
# 或者: from PySide2.QtUiTools import QUiLoader [as 别名]
def _pyside():
import PySide
from PySide import QtGui, QtCore, QtUiTools
_remap(PySide, "QtWidgets", QtGui)
_remap(QtCore, "QSortFilterProxyModel", QtGui.QSortFilterProxyModel)
_remap(QtCore, "QStringListModel", QtGui.QStringListModel)
_remap(QtCore, "QItemSelection", QtGui.QItemSelection)
_remap(QtCore, "QItemSelectionModel", QtGui.QItemSelectionModel)
_remap(QtCore, "QAbstractProxyModel", QtGui.QAbstractProxyModel)
try:
from PySide import QtWebKit
_remap(PySide, "QtWebKitWidgets", QtWebKit)
except ImportError:
# QtWebkit is optional in Qt, therefore might not be available
pass
_add(PySide, "__binding__", PySide.__name__)
_add(PySide, "load_ui", lambda fname: QtUiTools.QUiLoader().load(fname))
_add(PySide, "translate", lambda context, sourceText, disambiguation, n: (
QtCore.QCoreApplication(context, sourceText,
disambiguation, None, n)))
_add(PySide, "setSectionResizeMode", QtGui.QHeaderView.setResizeMode)
_maintain_backwards_compatibility(PySide)
return PySide
示例5: __init__
# 需要导入模块: from PySide2 import QtUiTools [as 别名]
# 或者: from PySide2.QtUiTools import QUiLoader [as 别名]
def __init__(self, parent=None):
super(BaseTab, self).__init__(parent)
#self.parent = parent
#loader = QUiLoader()
#f = QFile(uifile)
#f.open(QFile.ReadOnly)
#widget = loader.load(f, self)
#f.close()
#layout = QVBoxLayout()
#layout.addWidget(widget)
#self.setLayout(layout)
#utils.loadUi(uifile)
#----------------------------------------------------------------------
示例6: _pyside2_load_ui
# 需要导入模块: from PySide2 import QtUiTools [as 别名]
# 或者: from PySide2.QtUiTools import QUiLoader [as 别名]
def _pyside2_load_ui(fyle, parent=None):
from PySide2.QtUiTools import QUiLoader
loader = QUiLoader()
return loader.load(fyle, parent)
示例7: _pyside_load_ui
# 需要导入模块: from PySide2 import QtUiTools [as 别名]
# 或者: from PySide2.QtUiTools import QUiLoader [as 别名]
def _pyside_load_ui(fyle, parent=None):
from PySide.QtUiTools import QUiLoader
loader = QUiLoader()
return loader.load(fyle, parent)
示例8: __init__
# 需要导入模块: from PySide2 import QtUiTools [as 别名]
# 或者: from PySide2.QtUiTools import QUiLoader [as 别名]
def __init__(self, object_name):
super().__init__(None)
# get path to files
cd = os.path.dirname(os.path.abspath(__file__))
tmp_untitled = os.path.join(cd, 'tmp_untitled.ui')
result_psg_ui = os.path.join(cd, 'result_psg.layout')
try:
# READ xml-UI into python-qt object
xml_ui_file = QFile(tmp_untitled)
xml_ui_file.open(QFile.ReadOnly)
ui = QUiLoader().load(xml_ui_file)
# convert to psg
no_bad_widgets = sys.argv[2] == '1'
psg_ui = optimize_psg_code(to_psg_element(
getattr(ui, object_name), pass_bad_widgets=no_bad_widgets))
# output psg code to file
with open(result_psg_ui, 'w', encoding='utf-8') as ff:
ff.write(psg_ui)
except Exception as e:
message = 'Error: \n' + str(e)
if '''PySide2.QtWidgets.QMainWindow' object has no attribute''' in str(e):
message = 'Error: \nElement with "object name"="' + object_name + '" not found'
# output psg code to file
with open(result_psg_ui, 'w', encoding='utf-8') as ff:
ff.write(message)
return message
示例9: _pyside
# 需要导入模块: from PySide2 import QtUiTools [as 别名]
# 或者: from PySide2.QtUiTools import QUiLoader [as 别名]
def _pyside():
import PySide
from PySide import QtGui, QtCore, QtUiTools
_remap(PySide, "QtWidgets", QtGui)
_remap(QtCore, "QSortFilterProxyModel", QtGui.QSortFilterProxyModel)
_remap(QtCore, "QStringListModel", QtGui.QStringListModel)
_remap(QtCore, "QItemSelection", QtGui.QItemSelection)
_remap(QtCore, "QItemSelectionModel", QtGui.QItemSelectionModel)
_remap(QtCore, "QAbstractProxyModel", QtGui.QAbstractProxyModel)
try:
from PySide import QtWebKit
_remap(PySide, "QtWebKitWidgets", QtWebKit)
except ImportError:
"QtWebkit is optional in Qt, therefore might not be available"
_add(QtCompat, "__binding__", PySide.__name__)
_add(QtCompat, "__binding_version__", PySide.__version__)
_add(QtCompat, "__qt_version__", PySide.QtCore.qVersion())
_add(QtCompat, "load_ui", lambda fname: QtUiTools.QUiLoader().load(fname))
_add(QtCompat, "setSectionResizeMode", QtGui.QHeaderView.setResizeMode)
_add(QtCompat, "translate",
lambda context, sourceText, disambiguation, n:
QtCore.QCoreApplication.translate(context,
sourceText,
disambiguation,
QtCore.QCoreApplication.CodecForTr,
n))
_maintain_backwards_compatibility(PySide)
return PySide
示例10: create_ui
# 需要导入模块: from PySide2 import QtUiTools [as 别名]
# 或者: from PySide2.QtUiTools import QUiLoader [as 别名]
def create_ui(self):
"""
Create UI.
Assign functions to buttons and actions.
"""
self.settings = QtCore.QSettings(settings_path, QtCore.QSettings.IniFormat)
self.setWindowTitle('DMNK - SpeedTree Importer')
self.setWindowFlags(QtCore.Qt.Dialog)
self.resize(self.settings.value("size", QtCore.QSize(hou.ui.scaledSize(425), hou.ui.scaledSize(238))))
self.move(self.settings.value("pos", QtCore.QPoint(0, 0)))
# Layout
loader = QtUiTools.QUiLoader()
self.ui = loader.load(scriptpath + "/speedtree_importer_ui.ui")
mainLayout = QtWidgets.QGridLayout()
mainLayout.addWidget(self.ui)
mainLayout.setContentsMargins(0, 0, 0, 0)
self.setLayout(mainLayout)
self.ui.settings.setStyleSheet(CLGRP_STYLE)
# Get values from config
self.ui.renderer_dropdown.setCurrentText(self.settings.value("renderer_dropdown", ""))
self.ui.opc_as_stencil.setChecked(str(self.settings.value("opc_as_stencil", False)).lower() == 'true')
self.ui.diff_is_linear.setChecked(str(self.settings.value("diff_is_linear", False)).lower() == 'true')
self.ui.use_env.setChecked(str(self.settings.value("use_env", False)).lower() == 'true')
self.ui.env.setText(self.settings.value("env", ""))
# Connect functions to signals
## Config related signals
self.ui.renderer_dropdown.currentIndexChanged.connect(self.updateConfig)
self.ui.renderer_dropdown.currentIndexChanged.connect(self.updateEngine)
self.ui.opc_as_stencil.toggled.connect(self.updateConfig)
self.ui.diff_is_linear.toggled.connect(self.updateConfig)
self.ui.use_env.toggled.connect(self.updateConfig)
self.ui.env.editingFinished.connect(self.updateConfig)
## Open/close settings
self.ui.settings.toggled.connect(self.open_settings)
## Main functions
self.ui.node_jump.clicked.connect(self.jump_to_tree)
self.ui.import_mat.clicked.connect(self.createGeo)
if self.ui.use_env.isChecked() == False:
self.ui.env.setDisabled(True)
else:
self.ui.env.setDisabled(False)
self.updateEngine()