本文整理汇总了Python中PySide2.QtWidgets.QDialog方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QDialog方法的具体用法?Python QtWidgets.QDialog怎么用?Python QtWidgets.QDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide2.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QDialog [as 别名]
def __init__(self, parent=None, excel_file=None):
QtWidgets.QDialog.__init__(self, parent)
self.ui = Ui_ExcelSelectionDialog()
self.ui.setupUi(self)
self.excel_sheet = None
if excel_file is not None:
xls = xlrd.open_workbook(excel_file, on_demand=True)
self.sheet_names = xls.sheet_names()
self.ui.sheets_list.addItems(self.sheet_names)
# click
self.ui.buttonBox.accepted.connect(self.accepted_action)
self.ui.buttonBox.rejected.connect(self.rejected_action)
self.ui.sheets_list.doubleClicked.connect(self.accepted_action)
示例2: open_error_dialog
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QDialog [as 别名]
def open_error_dialog(self):
error_dialog = QDialog(self)
label = QLabel()
label.setText('Sorry...\nNot support this apk.')
layout = QHBoxLayout()
layout.addWidget(label)
error_dialog.setLayout(layout)
error_dialog.show()
示例3: __init__
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QDialog [as 别名]
def __init__ (self, parent):
QtWidgets.QDialog.__init__(self, parent)
self.setWindowTitle("Export depth maps")
self.btnQuit = QtWidgets.QPushButton("&Close")
self.btnP1 = QtWidgets.QPushButton("&Export")
self.pBar = QtWidgets.QProgressBar()
self.pBar.setTextVisible(False)
# self.selTxt =QtWidgets.QLabel()
# self.selTxt.setText("Apply to:")
self.radioBtn_all = QtWidgets.QRadioButton("Apply to all cameras")
self.radioBtn_sel = QtWidgets.QRadioButton("Apply to selected")
self.radioBtn_all.setChecked(True)
self.radioBtn_sel.setChecked(False)
self.formTxt = QtWidgets.QLabel()
self.formTxt.setText("Export format:")
self.formCmb = QtWidgets.QComboBox()
self.formCmb.addItem("1-band F32")
self.formCmb.addItem("Grayscale 8-bit")
self.formCmb.addItem("Grayscale 16-bit")
# creating layout
layout = QtWidgets.QGridLayout()
layout.setSpacing(10)
layout.addWidget(self.radioBtn_all, 0, 0)
layout.addWidget(self.radioBtn_sel, 1, 0)
layout.addWidget(self.formTxt, 0, 1)
layout.addWidget(self.formCmb, 1, 1)
layout.addWidget(self.btnP1, 2, 0)
layout.addWidget(self.btnQuit, 2, 1)
layout.addWidget(self.pBar, 3, 0, 1, 2)
self.setLayout(layout)
QtCore.QObject.connect(self.btnP1, QtCore.SIGNAL("clicked()"), self.export_depth)
QtCore.QObject.connect(self.btnQuit, QtCore.SIGNAL("clicked()"), self, QtCore.SLOT("reject()"))
self.exec()
示例4: __init__
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QDialog [as 别名]
def __init__(self, parent):
QtWidgets.QDialog.__init__(self, parent)
self.setWindowTitle("Copy bounding box")
self.labelFrom = QtWidgets.QLabel("From")
self.labelTo = QtWidgets.QLabel("To")
self.fromChunk = QtWidgets.QComboBox()
for chunk in Metashape.app.document.chunks:
self.fromChunk.addItem(chunk.label)
self.toChunks = QtWidgets.QListWidget()
self.toChunks.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
for chunk in Metashape.app.document.chunks:
self.toChunks.addItem(chunk.label)
self.btnOk = QtWidgets.QPushButton("Ok")
self.btnOk.setFixedSize(90, 50)
self.btnOk.setToolTip("Copy bounding box to all selected chunks")
self.btnQuit = QtWidgets.QPushButton("Close")
self.btnQuit.setFixedSize(90, 50)
layout = QtWidgets.QGridLayout() # creating layout
layout.addWidget(self.labelFrom, 0, 0)
layout.addWidget(self.fromChunk, 0, 1)
layout.addWidget(self.labelTo, 0, 2)
layout.addWidget(self.toChunks, 0, 3)
layout.addWidget(self.btnOk, 1, 1)
layout.addWidget(self.btnQuit, 1, 3)
self.setLayout(layout)
QtCore.QObject.connect(self.btnOk, QtCore.SIGNAL("clicked()"), self.copyBoundingBox)
QtCore.QObject.connect(self.btnQuit, QtCore.SIGNAL("clicked()"), self, QtCore.SLOT("reject()"))
self.exec()
示例5: setupUI
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QDialog [as 别名]
def setupUI(self, layout='grid'):
#------------------------------
# main_layout auto creation for holding all the UI elements
#------------------------------
main_layout = None
if isinstance(self, QtWidgets.QMainWindow):
main_widget = QtWidgets.QWidget()
self.setCentralWidget(main_widget)
main_layout = self.quickLayout(layout, 'main_layout') # grid for auto fill window size
main_widget.setLayout(main_layout)
else:
# main_layout for QDialog
main_layout = self.quickLayout(layout, 'main_layout')
self.setLayout(main_layout)
示例6: setupUI
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QDialog [as 别名]
def setupUI(self):
#------------------------------
# main_layout auto creation for holding all the UI elements
#------------------------------
main_layout = None
if isinstance(self, QtWidgets.QMainWindow):
main_widget = QtWidgets.QWidget()
self.setCentralWidget(main_widget)
main_layout = self.quickLayout('vbox', 'main_layout') # grid for auto fill window size
main_widget.setLayout(main_layout)
else:
# main_layout for QDialog
main_layout = self.quickLayout('vbox', 'main_layout')
self.setLayout(main_layout)
#------------------------------
# user ui creation part
#------------------------------
# + template: qui version since universal tool template v7
# - no extra variable name, all text based creation and reference
self.qui('dict_table | source_txtEdit | result_txtEdit','info_split;v')
self.qui('filePath_input | fileLoad_btn;Load | fileLang_choice | fileExport_btn;Export', 'fileBtn_layout;hbox')
self.qui('info_split | process_btn;Process and Update Memory From UI | fileBtn_layout', 'main_layout')
self.uiList["source_txtEdit"].setWrap(0)
self.uiList["result_txtEdit"].setWrap(0)
#------------- end ui creation --------------------
for name,each in self.uiList.items():
if isinstance(each, QtWidgets.QLayout) and name!='main_layout' and not name.endswith('_grp_layout'):
each.setContentsMargins(0,0,0,0) # clear extra margin some nested layout
#self.quickInfo('Ready')
示例7: setupUI
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QDialog [as 别名]
def setupUI(self):
#------------------------------
# main_layout auto creation for holding all the UI elements
#------------------------------
main_layout = None
if isinstance(self, QtWidgets.QMainWindow):
main_widget = QtWidgets.QWidget()
self.setCentralWidget(main_widget)
main_layout = self.quickLayout('vbox', 'main_layout') # grid for auto fill window size
main_widget.setLayout(main_layout)
else:
# main_layout for QDialog
main_layout = self.quickLayout('vbox', 'main_layout')
self.setLayout(main_layout)
示例8: setupWin
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QDialog [as 别名]
def setupWin(self):
super(self.__class__,self).setupWin()
self.setGeometry(500, 300, 250, 110) # self.resize(250,250)
#------------------------------
# template list: for frameless or always on top option
#------------------------------
# - template : keep ui always on top of all;
# While in Maya, dont set Maya as its parent
'''
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
'''
# - template: hide ui border frame;
# While in Maya, use QDialog instead, as QMainWindow will make it disappear
'''
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
'''
# - template: best solution for Maya QDialog without parent, for always on-Top frameless ui
'''
self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint)
'''
# - template: for transparent and non-regular shape ui
# note: use it if you set main ui to transparent, and want to use alpha png as irregular shape window
# note: black color better than white for better look of semi trans edge, like pre-mutiply
'''
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.setStyleSheet("background-color: rgba(0, 0, 0,0);")
'''
示例9: test_load_ui_dialog
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QDialog [as 别名]
def test_load_ui_dialog():
"""Tests to see if the baseinstance loading loads a QDialog properly"""
import sys
from Qt import QtWidgets, QtCompat
app = QtWidgets.QApplication(sys.argv)
win = QtWidgets.QDialog()
QtCompat.loadUi(self.ui_qdialog, win)
assert hasattr(win, 'lineEdit'), \
"loadUi could not load instance to main window"
app.exit()
示例10: test_load_ui_existingLayoutOnDialog
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QDialog [as 别名]
def test_load_ui_existingLayoutOnDialog():
"""Tests to see if loading a ui onto a layout in a Dialog works"""
import sys
from Qt import QtWidgets, QtCompat
msgs = 'QLayout: Attempting to add QLayout "" to QDialog ' \
'"Dialog", which already has a layout'
with ignoreQtMessageHandler([msgs]):
app = QtWidgets.QApplication(sys.argv)
win = QtWidgets.QDialog()
QtWidgets.QComboBox(win)
QtWidgets.QHBoxLayout(win)
QtCompat.loadUi(self.ui_qdialog, win)
app.exit()
示例11: __init__
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QDialog [as 别名]
def __init__(self, parent=None):
"""
Constructor
Args:
parent:
"""
QtWidgets.QDialog.__init__(self, parent)
self.setWindowTitle('Tower builder')
# GUI objects
self.setContextMenuPolicy(QtCore.Qt.NoContextMenu)
self.layout = QVBoxLayout(self)
self.wires_tableView = QTableView()
self.add_wire_pushButton = QPushButton()
self.add_wire_pushButton.setText('Add')
self.delete_wire_pushButton = QPushButton()
self.delete_wire_pushButton.setText('Delete')
self.layout.addWidget(self.wires_tableView)
self.layout.addWidget(self.add_wire_pushButton)
self.layout.addWidget(self.delete_wire_pushButton)
self.setLayout(self.layout)
# Model
self.wire_collection = WiresCollection(self)
# set models
self.wires_tableView.setModel(self.wire_collection)
# button clicks
self.add_wire_pushButton.clicked.connect(self.add_wire_to_collection)
self.delete_wire_pushButton.clicked.connect(self.delete_wire_from_collection)
示例12: __init__
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QDialog [as 别名]
def __init__(self, parent):
self.texture_size = 2048
self.rendering_width = 2048
self.steps_number = 1000
self.style_path = ""
self.style_name = "style1"
self.working_dir = ""
self.model_name = "model1"
self.use_cameras_position = len(chunk.cameras) > 0
self.content_weight = 200.0
self.style_decay = 0.95
self.googlenet_style_layers = [
'conv2d2',
'mixed3a',
'mixed3b',
'mixed4a',
'mixed4b',
'mixed4c',
]
self.googlenet_content_layer = 'mixed3b'
if len(Metashape.app.document.path) > 0:
self.working_dir = str(pathlib.Path(Metashape.app.document.path).parent / "model_style_transfer")
self.model_name = pathlib.Path(Metashape.app.document.path).stem
# Paths will be inited in self.exportInput()
self.input_model_path = None
self.input_texture_path = None
self.input_cameras_path = None # Can be None if no cameras or self.use_cameras_position is False
self.output_dir = None
self.output_texture_path = None
self.result_model_path = None
# Cameras will be loaded with self.exportCameras() + self.loadCameras() or randomly sampled with meshutil.sample_view(10.0, 12.0)
self.cameras = None
self.max_fovy = 10.0
self.aspect_ratio = 1.0
QtWidgets.QDialog.__init__(self, parent)
self.setWindowTitle("Model style transfer")
self.createGUI()
self.initDefaultParams()
self.exec()
示例13: setupWin
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QDialog [as 别名]
def setupWin(self):
self.setWindowTitle("UITranslator" + " - v" + self.version + " - host: " + hostMode)
self.setGeometry(300, 300, 300, 300)
#------------------------------
# auto window icon setup
path = os.path.join(os.path.dirname(self.location),'icons','UITranslator.png')
self.setWindowIcon(QtGui.QIcon(path))
#------------------------------
# initial win drag position
self.drag_position=QtGui.QCursor.pos()
#------------------------------
# template list: for frameless or always on top option
#------------------------------
# - template : keep ui always on top of all;
# While in Maya, dont set Maya as its parent
'''
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
'''
# - template: hide ui border frame;
# While in Maya, use QDialog instead, as QMainWindow will make it disappear
'''
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
'''
# - template: best solution for Maya QDialog without parent, for always on-Top frameless ui
'''
self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint)
'''
# - template: for transparent and non-regular shape ui
# note: use it if you set main ui to transparent, and want to use alpha png as irregular shape window
# note: black color better than white for better look of semi trans edge, like pre-mutiply
'''
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.setStyleSheet("background-color: rgba(0, 0, 0,0);")
'''
#############################################
# customized SUPER quick ui function for speed up programming
#############################################
示例14: setupUI
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QDialog [as 别名]
def setupUI(self):
#------------------------------
# main_layout auto creation for holding all the UI elements
#------------------------------
main_layout = None
if isinstance(self, QtWidgets.QMainWindow):
main_widget = QtWidgets.QWidget()
self.setCentralWidget(main_widget)
main_layout = self.quickLayout('vbox', 'main_layout') # grid for auto fill window size
main_widget.setLayout(main_layout)
else:
# main_layout for QDialog
main_layout = self.quickLayout('vbox', 'main_layout')
self.setLayout(main_layout)
#------------------------------
# user ui creation part
#------------------------------
# + template: qui version since universal tool template v7
# - no extra variable name, all text based creation and reference
self.qui('source_txt | process_btn;Process and Update', 'upper_vbox')
self.qui('upper_vbox | result_txt', 'input_split;v')
self.qui('filePath_input | fileLoad_btn;Load | fileExport_btn;Export', 'fileBtn_layout;hbox')
self.qui('input_split | fileBtn_layout', 'main_layout')
# - template : quickUI version since universal tool template v6
'''
upper_layout = self.quickUI(["source_txt;QTextEdit","process_btn;QPushButton;Process and Update"],"upper_QVBoxLayout")
upper_layout.setContentsMargins(0,0,0,0)
input_split = self.quickSplitUI("input_split", [ upper_layout, self.quickUI(["result_txt;QTextEdit"])[0] ], "v")
fileBtn_layout = self.quickUI(["filePath_input;QLineEdit", "fileLoad_btn;QPushButton;Load", "fileExport_btn;QPushButton;Export"],"fileBtn_QHBoxLayout")
self.quickUI([input_split, fileBtn_layout], main_layout)
'''
# - template : invisible but functional button
'''
self.uiList['secret_btn'] = QtWidgets.QPushButton(self)
self.uiList['secret_btn'].setText("")
self.uiList['secret_btn'].setGeometry(0, 0, 50, 20)
self.uiList['secret_btn'].setStyleSheet("QPushButton{background-color: rgba(0, 0, 0,0);} QPushButton:pressed{background-color: rgba(0, 0, 0,0); border: 0px;} QPushButton:hover{background-color: rgba(0, 0, 0,0); border: 0px;}")
#:hover:pressed:focus:hover:disabled
'''
#------------- end ui creation --------------------
keep_margin_layout = ['main_layout']
for name, each in self.uiList.items():
if isinstance(each, QtWidgets.QLayout) and name not in keep_margin_layout and not name.endswith('_grp_layout'):
each.setContentsMargins(0, 0, 0, 0)
self.quickInfo('Ready')
示例15: setupWin
# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QDialog [as 别名]
def setupWin(self):
self.setWindowTitle("UniversalToolUI" + " - v" + self.version + " - host: " + hostMode)
self.setGeometry(500, 300, 250, 110) # self.resize(250,250)
#------------------------------
# auto window icon setup
path = os.path.join(os.path.dirname(self.location),'icons','UniversalToolUI.png')
self.setWindowIcon(QtGui.QIcon(path))
#------------------------------
# initial win drag position
self.drag_position=QtGui.QCursor.pos()
#------------------------------
# template list: for frameless or always on top option
#------------------------------
# - template : keep ui always on top of all;
# While in Maya, dont set Maya as its parent
'''
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
'''
# - template: hide ui border frame;
# While in Maya, use QDialog instead, as QMainWindow will make it disappear
'''
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
'''
# - template: best solution for Maya QDialog without parent, for always on-Top frameless ui
'''
self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint)
'''
# - template: for transparent and non-regular shape ui
# note: use it if you set main ui to transparent, and want to use alpha png as irregular shape window
# note: black color better than white for better look of semi trans edge, like pre-mutiply
'''
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.setStyleSheet("background-color: rgba(0, 0, 0,0);")
'''
#############################################
# customized SUPER quick ui function for speed up programming
#############################################