Python PySide2.QtWidgets.QDialog() Examples

The following are 19 code examples of PySide2.QtWidgets.QDialog(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PySide2.QtWidgets , or try the search function .
Example #1
Source File: excel_dialog.py    From GridCal with GNU General Public License v3.0 9 votes vote down vote up
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) 
Example #2
Source File: export_depth_maps_dialog.py    From metashape-scripts with MIT License 5 votes vote down vote up
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() 
Example #3
Source File: test_.py    From GridCal with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #4
Source File: tests.py    From Qt.py with MIT License 5 votes vote down vote up
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() 
Example #5
Source File: tests.py    From Qt.py with MIT License 5 votes vote down vote up
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() 
Example #6
Source File: universal_tool_template_1010.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
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) 
Example #7
Source File: universal_tool_template_1000.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
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) 
Example #8
Source File: universal_tool_template_0904.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
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);")
        ''' 
Example #9
Source File: universal_tool_template_0904.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
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) 
Example #10
Source File: universal_tool_template_0903.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
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);")
        ''' 
Example #11
Source File: universal_tool_template_0903.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
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) 
Example #12
Source File: UITranslator.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
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') 
Example #13
Source File: GearBox_template_1010.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
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) 
Example #14
Source File: copy_bounding_box_dialog.py    From metashape-scripts with MIT License 5 votes vote down vote up
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() 
Example #15
Source File: application.py    From Il2cppSpy with MIT License 5 votes vote down vote up
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() 
Example #16
Source File: universal_tool_template_0803.py    From universal_tool_template.py with MIT License 4 votes vote down vote up
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') 
Example #17
Source File: universal_tool_template_v8.1.py    From universal_tool_template.py with MIT License 4 votes vote down vote up
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
    ############################################# 
Example #18
Source File: UITranslator.py    From universal_tool_template.py with MIT License 4 votes vote down vote up
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
    ############################################# 
Example #19
Source File: model_style_transfer.py    From metashape-scripts with MIT License 4 votes vote down vote up
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()