Python PyQt5.QtWidgets.QDialog() Examples

The following are 30 code examples for showing how to use PyQt5.QtWidgets.QDialog(). These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.

You may also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .

Example 1
Project: simnibs   Author: simnibs   File: main_gui.py    License: GNU General Public License v3.0 6 votes vote down vote up
def openSimulation(self):
        dialog = QtWidgets.QFileDialog(self)
        dialog.setWindowTitle('Open GMSH File')
        dialog.setNameFilter('GMSH files (*.msh)')
        dialog.setDirectory(QtCore.QDir.currentPath())
        dialog.setFileMode(QtWidgets.QFileDialog.ExistingFile)
        if dialog.exec_() == QtWidgets.QDialog.Accepted:
            file_full_path = str(dialog.selectedFiles()[0])

        else:
            return None

        self.thread = openGmshThread(file_full_path)
        self.thread.start()



    #Generates a sim_struct.session() structure, for saving and running 
Example 2
Project: simnibs   Author: simnibs   File: main_gui.py    License: GNU General Public License v3.0 6 votes vote down vote up
def coilDialog(self):
        #get folder with ccd files
        try:
            ccd_folder = os.path.join(SIMNIBSDIR, 'ccd-files')
        except:
            ccd_folder = './'


        dialog = QtWidgets.QFileDialog(self)
        dialog.setWindowTitle('Open Coil Definition File')
        dialog.setNameFilter('Coil Definition files (*.ccd *.nii *.gz)')
        dialog.setDirectory(ccd_folder)
        dialog.setFileMode(QtWidgets.QFileDialog.ExistingFile)
        if dialog.exec_() == QtWidgets.QDialog.Accepted:
            fn = str(dialog.selectedFiles()[0])
        else:
            return None

        self.tmslist.fnamecoil = fn
        self.coil_line_edit.setText(fn) 
Example 3
Project: simnibs   Author: simnibs   File: simulation_menu.py    License: GNU General Public License v3.0 6 votes vote down vote up
def selectFile(self):
        if self.fname is not None and os.path.isfile(self.fname):
            eeg_cap_dir = os.path.dirname(self.fname)
        else:
            eeg_cap_dir = QtCore.QDir.currentPath()
        dialog = QtWidgets.QFileDialog(self)
        dialog.setWindowTitle('Open EEG Position file')
        dialog.setNameFilter('(*.csv)')
        dialog.setDirectory(eeg_cap_dir)
        dialog.setFileMode(QtWidgets.QFileDialog.ExistingFile)
        filename = None
        if dialog.exec_() == QtWidgets.QDialog.Accepted:
            filename = dialog.selectedFiles()
        if filename:
            self.fname = str(filename[0])
            self.group_box.lineEdit.setText(self.fname) 
Example 4
Project: mindfulness-at-the-computer   Author: mindfulness-at-the-computer   File: breathing_phrase_list_wt.py    License: GNU General Public License v3.0 6 votes vote down vote up
def add_new_phrase_button_clicked(self):
        text_sg = self.add_to_list_qle.text().strip()  # strip is needed to remove a newline at the end (why?)
        if not (text_sg and text_sg.strip()):
            conf_result_bool = mc.gui.warning_dlg.WarningDlg.get_safe_confirmation_dialog(
                self.tr("You have to write an item before you press 'Add'.")
            )
            return
        mc.model.PhrasesM.add(
            text_sg,
            BREATHING_IN_DEFAULT_PHRASE,
            BREATHING_OUT_DEFAULT_PHRASE,
            BREATHING_IN_DEFAULT_SHORT_PHRASE,
            BREATHING_OUT_DEFAULT_SHORT_PHRASE,
            mc.mc_global.BreathingPhraseType.in_out
        )
        self.add_to_list_qle.clear()

        self.update_gui()
        self.list_widget.setCurrentRow(self.list_widget.count() - 1)
        # self.in_breath_phrase_qle.setFocus()

        # if dialog_result == QtWidgets.QDialog.Accepted:
        self.edit_dialog = EditDialog()
        self.edit_dialog.finished.connect(self.on_edit_dialog_finished)
        self.edit_dialog.show() 
Example 5
Project: IDAngr   Author: andreafioraldi   File: init_gui.py    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
def __init__(self):
        QtWidgets.QDialog.__init__(self)
        
        self.ui = Ui_IDAngrConnectDialog()
        self.ui.setupUi(self)
        
        host = "localhost"
        port = manage.DEFAULT_SERVER_PORT
        
        try:
            if os.path.exists(config_file):
                with open(config_file) as f:
                    config = json.load(f)
                host = config["host"]
                port = config["port"]
                self.ui.saveBox.setChecked(config["save"])
                self.ui.localBox.setChecked(config["local"])
        except: pass
        
        self.ui.hostTxt.setText(host)
        self.ui.portTxt.setText(str(port)) 
Example 6
Project: IDAngr   Author: andreafioraldi   File: main_gui.py    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
def get_mem(addr):
        dialog = IDAngrAddMemDialog()
        dialog.set_addr(addr)
        r = dialog.exec_()
        if r == QtWidgets.QDialog.Accepted:
            addr = dialog.ui.addrTextEdit.displayText()
            try:
                addr = int(addr, 16)
            except:
                QtWidgets.QMessageBox(QtWidgets.QMessageBox.Critical, 'Error', "Address not in hex format").exec_()
                return None
            length = dialog.ui.lenTextEdit.displayText()
            try:
                length = int(length)
            except:
                QtWidgets.QMessageBox(QtWidgets.QMessageBox.Critical, 'Error', "Length not in dec format").exec_()
                return None
            return (addr, length)
        return None 
Example 7
Project: IDAngr   Author: andreafioraldi   File: main_gui.py    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
def __init__(self):
        global _idangr_ctx
        QtWidgets.QDialog.__init__(self)
        
        self.ui = Ui_IDAngrExecDialog()
        self.ui.setupUi(self)
        
        if _idangr_ctx.find_lambda:
            self.ui.findCondEdit.setPlainText(_idangr_ctx.find_lambda)
        if _idangr_ctx.avoid_lambda:
            self.ui.avoidCondEdit.setPlainText(_idangr_ctx.avoid_lambda)

        self.ui.simprocsBox.setChecked(get_memory_type() == SIMPROCS_FROM_CLE)
        self.ui.textloaderBox.setChecked(get_memory_type() == USE_CLE_MEMORY)
        self.ui.gotloaderBox.setChecked(get_memory_type() == ONLY_GOT_FROM_CLE)
        self.ui.execallBox.setChecked(get_memory_type() == GET_ALL_DISCARD_CLE)
        
        self.fh = PythonHighlighter(self.ui.findCondEdit.document())
        self.ah = PythonHighlighter(self.ui.avoidCondEdit.document()) 
Example 8
Project: kite   Author: pyrocko   File: tool_dialogs.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, sandbox, *args, **kwargs):
        QtWidgets.QDialog.__init__(self, *args, **kwargs)
        loadUi(get_resource('dialog_los.ui'), self)
        self.setSizeGripEnabled(False)

        self.move(
            self.parent().window().mapToGlobal(
                self.parent().window().rect().center()) -
            self.mapToGlobal(self.rect().center()))

        self.sandbox = sandbox
        model = self.sandbox.model
        self.applyButton.released.connect(self.updateValues)
        self.okButton.released.connect(self.updateValues)
        self.okButton.released.connect(self.close)

        self.setValues() 
Example 9
Project: IDASkins   Author: zyantific   File: clrapplier.py    License: MIT License 6 votes vote down vote up
def eventFilter(self, obj, event):
        def is_colors_dialog():
            return isinstance(
                obj, QDialog) and 'IDA Colors' in obj.windowTitle()

        if isinstance(event, QShowEvent) and is_colors_dialog():
            qApp.removeEventFilter(self)

            # Hide window and find &Import button
            obj.windowHandle().setOpacity(0)
            buttons = [widget for widget in obj.children() if isinstance(
                widget, QDialogButtonBox)][0]
            button = [widget for widget in buttons.buttons() if widget.text()
                      == '&Import'][0]

            with NativeHook(ask_file=self.ask_file_handler):
                button.click()

            QTimer.singleShot(0, lambda: obj.accept())
            return 1
        return 0 
Example 10
Project: pychemqt   Author: jjgomera   File: UI_corriente.py    License: GNU General Public License v3.0 6 votes vote down vote up
def repaint(self, psychro=True):
        # Parameter to avoid recursive repaint
        if self.semaforo.available() > 0:
            self.semaforo.acquire(1)
            self.pageDefinition.setStream(self.corriente)
            self.pageConfig.setKwargs(self.corriente.kwargs)
            if psychro and self.psychro:
                psystream = self.corriente.psystream
                self.pagePsychro.setStream(psystream)
            self.pageSolids.setSolido(self.corriente.solido)
            self.PageNotas.setText(self.corriente.notas)
            self.pageProperties.fill(self.corriente)
            if isinstance(self, QtWidgets.QDialog):
                self.status.setState(self.corriente.status, self.corriente.msg)
            if self.corriente.status == 1:
                self.Changed.emit(self.corriente)
            self.semaforo.release(1) 
Example 11
Project: pychemqt   Author: jjgomera   File: costIndex.py    License: GNU General Public License v3.0 6 votes vote down vote up
def accept(self):
        """Overwrite accept signal to save changes"""
        with open(config.conf_dir+"CostIndex.dat", "w") as archivo:
            if self.custom:
                archivo.write("custom\n")
            else:
                archivo.write(self.fecha.currentText()+"\n")

            archivo.write(str(self.index.value)+"\n")
            archivo.write(str(self.equipos.value)+"\n")
            archivo.write(str(self.cambiadores_calor.value)+"\n")
            archivo.write(str(self.maquinaria.value)+"\n")
            archivo.write(str(self.tuberias.value)+"\n")
            archivo.write(str(self.instrumentos.value)+"\n")
            archivo.write(str(self.bombas.value)+"\n")
            archivo.write(str(self.equipos_electricos.value)+"\n")
            archivo.write(str(self.soportes.value)+"\n")
            archivo.write(str(self.construccion.value)+"\n")
            archivo.write(str(self.edificios.value)+"\n")
            archivo.write(str(self.ingenieria.value)+"\n")
            QtWidgets.QDialog.accept(self) 
Example 12
Project: Miyamoto   Author: aboood40091   File: puzzle.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        """
        Creates and initializes the dialog
        """
        QtWidgets.QDialog.__init__(self)
        self.setWindowTitle('Choose Object')

        self.objNum = QtWidgets.QSpinBox()
        count = len(Tileset.objects) - 1
        self.objNum.setRange(0, count)
        self.objNum.setValue(0)

        buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)

        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)

        mainLayout = QtWidgets.QVBoxLayout()
        mainLayout.addWidget(self.objNum)
        mainLayout.addWidget(buttonBox)

        self.setLayout(mainLayout) 
Example 13
Project: multibootusb   Author: mbusb   File: mbusb_gui.py    License: GNU General Public License v2.0 5 votes vote down vote up
def onAboutClick(self):
        about = QtWidgets.QDialog()
        about.ui = Ui_About()
        about.ui.setupUi(about)
        about.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        about.setWindowTitle("About MultiBootUSB - " + mbusb_version())
        about.setWindowIcon(QtGui.QIcon(resource_path(os.path.join("data", "tools", "multibootusb.png"))))
        about.ui.button_close.clicked.connect(about.close)
        about.ui.label_6.linkActivated.connect(webbrowser.open_new_tab)
        about.exec_() 
Example 14
Project: simnibs   Author: simnibs   File: electrodeGUI.py    License: GNU General Public License v3.0 5 votes vote down vote up
def return_el_struct(self):
        dialog = Ui_Electrode(self.electrode_struct)
        result = dialog.exec_()
        struct = dialog.electrode_struct
        return (struct, result == QtWidgets.QDialog.Accepted)






#####################################################################
############Electrode OpenGL Model###################################
##################################################################### 
Example 15
Project: simnibs   Author: simnibs   File: main_gui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def fileDialog(self):
        dialog = QtWidgets.QFileDialog(self)
        dialog.setWindowTitle('Open Mesh File')
        dialog.setNameFilter('gmsh files (*.msh)')
        dialog.setDirectory(QtCore.QDir.currentPath())
        dialog.setFileMode(QtWidgets.QFileDialog.ExistingFile)
        filename = None
        if dialog.exec_() == QtWidgets.QDialog.Accepted:
            filename = dialog.selectedFiles()
        if filename:
            fn = str(filename[0])
            self.file_name.setText(fn)
            self.loadHeadModel(fn)
            self.lookForTensors(fn) 
Example 16
Project: simnibs   Author: simnibs   File: main_gui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def getCond(self):
        result = self.exec_()
        #cond = self.returnCond()
        return (self.simulist, result == QtWidgets.QDialog.Accepted)


#Thread for loading meshes 
Example 17
Project: simnibs   Author: simnibs   File: simulation_menu.py    License: GNU General Public License v3.0 5 votes vote down vote up
def getOptions(self):
        result = self.exec_()
        return (self.session, result == QtWidgets.QDialog.Accepted)

        
 
#Dialog for selecting tensor files 
Example 18
Project: simnibs   Author: simnibs   File: simulation_menu.py    License: GNU General Public License v3.0 5 votes vote down vote up
def getFileNames(self):
        result = self.exec_()
        return (self.fname, result == QtWidgets.QDialog.Accepted) 
Example 19
Project: simnibs   Author: simnibs   File: simulation_menu.py    License: GNU General Public License v3.0 5 votes vote down vote up
def getFileNames(self):
        result = self.exec_()
        return (self.fname, result == QtWidgets.QDialog.Accepted) 
Example 20
Project: mindfulness-at-the-computer   Author: mindfulness-at-the-computer   File: experimental_list_widget.py    License: GNU General Public License v3.0 5 votes vote down vote up
def get_safe_confirmation_dialog(i_description_str):
        dialog = SafeDeleteDialog(i_description_str)
        dialog_result = dialog.exec_()
        confirmation_result_bool = False
        if dialog_result == QtWidgets.QDialog.Accepted:
            confirmation_result_bool = True
        return confirmation_result_bool 
Example 21
Project: mindfulness-at-the-computer   Author: mindfulness-at-the-computer   File: safe_delete_dlg.py    License: GNU General Public License v3.0 5 votes vote down vote up
def get_safe_confirmation_dialog(i_description_str: str) -> bool:
        dialog = SafeDeleteDlg(i_description_str)
        dialog_result = dialog.exec_()
        confirmation_result_bool = False
        if dialog_result == QtWidgets.QDialog.Accepted:
            confirmation_result_bool = True
        return confirmation_result_bool 
Example 22
Project: mindfulness-at-the-computer   Author: mindfulness-at-the-computer   File: rest_action_list_wt.py    License: GNU General Public License v3.0 5 votes vote down vote up
def launch_edit_dialog():
        dialog = EditDialog()
        dialog_result = dialog.exec_()

        if dialog_result == QtWidgets.QDialog.Accepted:
            rest_action = model.RestActionsM.get(mc_global.active_rest_action_id_it)
            rest_action.title = dialog.rest_action_title_qle.text()
        else:
            pass

        return dialog_result 
Example 23
Project: mindfulness-at-the-computer   Author: mindfulness-at-the-computer   File: warning_dlg.py    License: GNU General Public License v3.0 5 votes vote down vote up
def get_safe_confirmation_dialog(i_description_str: str) -> bool:
        dialog = WarningDlg(i_description_str)
        dialog_result = dialog.exec_()
        confirmation_result_bool = False
        if dialog_result == QtWidgets.QDialog.Accepted:
            confirmation_result_bool = True
        return confirmation_result_bool 
Example 24
Project: qhangups   Author: xmikos   File: settings.py    License: GNU General Public License v3.0 5 votes vote down vote up
def accept(self):
        """Save settings after clicking on OK button"""
        settings = QtCore.QSettings()
        settings.setValue("send_client_active", self.sendClientActiveCheckBox.isChecked())
        settings.setValue("send_read_state", self.sendReadStateCheckBox.isChecked())
        settings.setValue("enter_send_message", self.enterSendMessageCheckBox.isChecked())
        settings.setValue("language", self.languageComboBox.itemData(self.languageComboBox.currentIndex()))
        settings.setValue("connection_events", self.connectionEventsCheckBox.isChecked())
        settings.setValue("autoconnect", self.autoConnectCheckBox.isChecked())
        QtWidgets.QDialog.accept(self) 
Example 25
Project: Lector   Author: BasioMeusPuga   File: definitionsdialog.py    License: GNU General Public License v3.0 5 votes vote down vote up
def color_background(self, set_initial=False):
        if set_initial:
            background = self.parent.settings['dialog_background']
        else:
            self.previous_position = self.pos()
            self.parent.get_color()
            background = self.parent.settings['dialog_background']

        # Calculate inverse color for the background so that
        # the text doesn't look blank
        r, g, b, alpha = background.getRgb()
        inv_average = 255 - (r + g + b) // 3
        if 100 < inv_average < 150:
            inv_average = 255

        foreground = QtGui.QColor(
            inv_average, inv_average, inv_average, alpha)

        self.setStyleSheet(
            "QDialog {{background-color: {0}}}".format(background.name()))
        self.definitionView.setStyleSheet(
            "QTextBrowser {{color:{0}; background-color: {1}}}".format(
                foreground.name(), background.name()))

        if not set_initial:
            self.show() 
Example 26
Project: Lector   Author: BasioMeusPuga   File: metadatadialog.py    License: GNU General Public License v3.0 5 votes vote down vote up
def color_background(self, set_initial=False):
        if set_initial:
            background = self.parent.settings['dialog_background']
        else:
            self.previous_position = self.pos()
            self.parent.get_color()
            background = self.parent.settings['dialog_background']

        self.setStyleSheet(
            "QDialog {{background-color: {0}}}".format(background.name()))
        self.coverView.setStyleSheet(
            "QGraphicsView {{background-color: {0}}}".format(background.name()))

        if not set_initial:
            self.show() 
Example 27
Project: visma   Author: aerospaceresearch   File: window.py    License: GNU General Public License v3.0 5 votes vote down vote up
def popupBrowser(self):
        w = QDialog(self)
        w.resize(600, 500)
        w.setWindowTitle('Wiki')
        web = QWebEngineView(w)
        web.load(QUrl('https://github.com/aerospaceresearch/visma/wiki'))
        web.resize(600, 500)
        web.show()
        w.show() 
Example 28
Project: pyleecan   Author: Eomys   File: MPLCanvas.py    License: Apache License 2.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        QtWidgets.QDialog.__init__(self, *args, **kwargs)
        self.setLayout(QtWidgets.QGridLayout())

        self.fig, self.axes = subplots()
        self.canvas = FigureCanvas(self.fig)
        # 'new' method to be compatible with pyleecan's plot-methods
        self.fig.show = self.canvas.draw

        self.layout().addWidget(self.canvas, 0, 0, 1, 1) 
Example 29
Project: dottorrent-gui   Author: kz26   File: gui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def showAboutDialog(self):
        qdlg = QtWidgets.QDialog()
        ad = Ui_AboutDialog()
        ad.setupUi(qdlg)
        ad.programVersionLabel.setText("version {}".format(__version__))
        ad.dtVersionLabel.setText("(dottorrent {})".format(
            dottorrent.__version__))
        qdlg.exec_() 
Example 30
Project: IDAngr   Author: andreafioraldi   File: init_gui.py    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
def go():
        dialog = IDAngrConnectDialog()
        r = dialog.exec_()
        if r == QtWidgets.QDialog.Accepted:
            if dialog.ui.saveBox.isChecked():
                config = {
                    "host": dialog.ui.hostTxt.displayText(),
                    "port": int(dialog.ui.portTxt.displayText()),
                    "save": True,
                    "local": dialog.ui.localBox.isChecked()
                }
                mkpath(user_data_dir("IDAngr", "IDA Pro"))
                with open(config_file, "w") as f:
                    json.dump(config, f, indent=4)
            
            try:
                if dialog.ui.localBox.isChecked():
                    manage.init(use_pin=dialog.ui.pinBox.isChecked())
                else:
                    manage.init(True, dialog.ui.hostTxt.displayText(), int(dialog.ui.portTxt.displayText()), use_pin=dialog.ui.pinBox.isChecked())
            except Exception as ee:
                QtWidgets.QMessageBox(QtWidgets.QMessageBox.Critical, 'IDAngr init error', str(ee)).exec_()
                return False
            
            return True
        return False