Python PyQt5.QtWidgets.QMessageBox.question() Examples

The following are 30 code examples of PyQt5.QtWidgets.QMessageBox.question(). 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 PyQt5.QtWidgets.QMessageBox , or try the search function .
Example #1
Source File: DMachineSetup.py    From pyleecan with Apache License 2.0 7 votes vote down vote up
def closeEvent(self, event):
        """Display a message before leaving

        Parameters
        ----------
        self : DMachineSetup
            A DMachineSetup object
        event :
            The closing event
        """

        if self.is_save_needed:
            quit_msg = self.tr(
                "Unsaved changes will be lost.\nDo you want to save the machine?"
            )
            reply = QMessageBox.question(
                self,
                self.tr("Please save before closing"),
                quit_msg,
                QMessageBox.Yes,
                QMessageBox.No,
            )

            if reply == QMessageBox.Yes:
                self.s_save() 
Example #2
Source File: qt.py    From pywebview with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def closeEvent(self, event):
        self.pywebview_window.closing.set()
        if self.confirm_close:
            reply = QMessageBox.question(self, self.title, localization['global.quitConfirmation'],
                                         QMessageBox.Yes, QMessageBox.No)

            if reply == QMessageBox.No:
                event.ignore()
                return

        event.accept()
        BrowserView.instances[self.uid].close()
        del BrowserView.instances[self.uid]

        if self.pywebview_window in windows:
            windows.remove(self.pywebview_window)

        self.pywebview_window.closed.set()

        if len(BrowserView.instances) == 0:
            self.hide()
            _app.exit() 
Example #3
Source File: sparrowdialogs.py    From sparrow-wifi with GNU General Public License v3.0 6 votes vote down vote up
def checkScanAlreadyRunning(self):
        errcode, errmsg, hasBluetooth, hasUbertooth, spectrumScanRunning, discoveryScanRunning =  getRemoteBluetoothRunningServices(self.remoteAgentIP, self.remoteAgentPort)      
        
        if errcode == 0:
            if discoveryScanRunning:
                self.btnScan.setStyleSheet("background-color: rgba(255,0,0,255); border: none;")
                self.btnScan.setText('&Stop scanning')
                self.comboScanType.setEnabled(False)
            else:
                self.btnScan.setStyleSheet("background-color: rgba(2,128,192,255); border: none;")
                self.btnScan.setText('&Scan')
                self.comboScanType.setEnabled(True)
        else:
                QMessageBox.question(self, 'Error',"Error getting remote agent discovery status: " + errmsg, QMessageBox.Ok)

                self.btnScan.setStyleSheet("background-color: rgba(2,128,192,255); border: none;")
                self.btnScan.setText('&Scan')
                self.comboScanType.setEnabled(True) 
Example #4
Source File: main_window.py    From vorta with GNU General Public License v3.0 6 votes vote down vote up
def closeEvent(self, event):
        # Save window state in SettingsModel
        SettingsModel.update({SettingsModel.str_value: str(self.frameGeometry().width())})\
            .where(SettingsModel.key == 'previous_window_width')\
            .execute()
        SettingsModel.update({SettingsModel.str_value: str(self.frameGeometry().height())})\
            .where(SettingsModel.key == 'previous_window_height')\
            .execute()

        if not is_system_tray_available():
            run_in_background = QMessageBox.question(self,
                                                     trans_late("MainWindow QMessagebox",
                                                                "Quit"),
                                                     trans_late("MainWindow QMessagebox",
                                                                "Should Vorta continue to run in the background?"),
                                                     QMessageBox.Yes | QMessageBox.No)
            if run_in_background == QMessageBox.No:
                self.app.quit()
        event.accept() 
Example #5
Source File: pyeditor.py    From Python_editor with The Unlicense 6 votes vote down vote up
def closeEvent(self, event):
        reply = QMessageBox.question(self, 'Exit',
            "Are you sure to quit?", QMessageBox.Yes |
            QMessageBox.No, QMessageBox.No)

        if reply == QMessageBox.Yes:
            print dn
            os.chdir(dn)
            print dn
            os.chdir('../..')
            print dn
            print '''
###################################################
#              Author Storm Shadow                #
#                                                 #
#              Follow me on twitter               #
#                  @zadow28                       #
###################################################
#              Ida pro  python Editor             #
###################################################
'''
            event.accept()
        else:
            event.ignore() 
Example #6
Source File: sparrowdialogs.py    From sparrow-wifi with GNU General Public License v3.0 6 votes vote down vote up
def getRemoteFile(self, agentIP, agentPort, filename):
        url = "http://" + agentIP + ":" + str(agentPort) + "/system/getrecording/" + filename

        dirname, runfilename = os.path.split(os.path.abspath(__file__))
        recordingsDir = dirname + '/recordings'
        fullPath = recordingsDir + '/' + filename
        
        if os.path.isfile(fullPath):
            reply = QMessageBox.question(self, 'Question',"Local file by that name already exists.  Overwrite?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No)

            if reply == QMessageBox.No:
                return
        
        try:
            # urllib.urlretrieve(url, fullPath)
            urlretrieve(url, fullPath)
            return 0, ""
        except:
            return 1, "Error downloading and saving file." 
Example #7
Source File: uiMainWindow.py    From TradeSim with Apache License 2.0 6 votes vote down vote up
def closeEvent(self, event):
        """关闭事件"""
        reply = QMessageBox.question(self, u'退出',
                                     u'确认退出?', QMessageBox.Yes |
                                     QMessageBox.No, QMessageBox.No)
        
        if reply == QMessageBox.Yes:
            for widget in list(self.widgetDict.values()):
                widget.close()
            
            self.mainEngine.exit()
            event.accept()
        else:
            event.ignore()
    
    # ---------------------------------------------------------------------- 
Example #8
Source File: CompareFrameController.py    From urh with GNU General Public License v3.0 6 votes vote down vote up
def save_protocol(self):
        for msg in self.proto_analyzer.messages:
            if not msg.decoder.is_nrz:
                reply = QMessageBox.question(self, "Saving of protocol",
                                             "You want to save this protocol with an encoding different from NRZ.\n"
                                             "This may cause loss of information if you load it again.\n\n"
                                             "Save anyway?", QMessageBox.Yes | QMessageBox.No)
                if reply != QMessageBox.Yes:
                    return
                else:
                    break

        text = "protocol"
        filename = FileOperator.get_save_file_name("{0}.proto.xml".format(text), caption="Save protocol")

        if not filename:
            return

        if filename.endswith(".bin"):
            self.proto_analyzer.to_binary(filename, use_decoded=True)
        else:
            self.proto_analyzer.to_xml_file(filename=filename, decoders=self.decodings,
                                            participants=self.project_manager.participants, write_bits=True) 
Example #9
Source File: ReceiveDialog.py    From urh with GNU General Public License v3.0 6 votes vote down vote up
def save_before_close(self):
        if not self.already_saved and self.device.current_index > 0:
            reply = QMessageBox.question(self, self.tr("Save data?"),
                                         self.tr("Do you want to save the data you have captured so far?"),
                                         QMessageBox.Yes | QMessageBox.No | QMessageBox.Abort)
            if reply == QMessageBox.Yes:
                self.on_save_clicked()
            elif reply == QMessageBox.Abort:
                return False

        try:
            sample_rate = self.device.sample_rate
        except:
            sample_rate = 1e6

        self.files_recorded.emit(self.recorded_files, sample_rate)
        return True 
Example #10
Source File: centralwidget.py    From autokey with GNU General Public License v3.0 6 votes vote down vote up
def promptToSave(self):
        if cm.ConfigManager.SETTINGS[cm.PROMPT_TO_SAVE]:
            # TODO: i18n
            result = QMessageBox.question(
                self.window(),
                "Save changes?",
                "There are unsaved changes. Would you like to save them?",
                QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel
            )

            if result == QMessageBox.Yes:
                return self.on_save()
            elif result == QMessageBox.Cancel:
                return True
            else:
                return False
        else:
            # don't prompt, just save
            return self.on_save()

    # ---- Signal handlers 
Example #11
Source File: CloudOutputDeviceManager.py    From Cura with GNU Lesser General Public License v3.0 6 votes vote down vote up
def _onRemovedPrintersMessageActionTriggered(self, removed_printers_message: Message, action: str) -> None:
        if action == "keep_printer_configurations_action":
            removed_printers_message.hide()
        elif action == "remove_printers_action":
            machine_manager = CuraApplication.getInstance().getMachineManager()
            remove_printers_ids = {self._um_cloud_printers[i].getId() for i in self.reported_device_ids}
            all_ids = {m.getId() for m in CuraApplication.getInstance().getContainerRegistry().findContainerStacks(type = "machine")}

            question_title = self.I18N_CATALOG.i18nc("@title:window", "Remove printers?")
            question_content = self.I18N_CATALOG.i18nc("@label", "You are about to remove {} printer(s) from Cura. This action cannot be undone. \nAre you sure you want to continue?".format(len(remove_printers_ids)))
            if remove_printers_ids == all_ids:
                question_content = self.I18N_CATALOG.i18nc("@label", "You are about to remove all printers from Cura. This action cannot be undone. \nAre you sure you want to continue?")
            result = QMessageBox.question(None, question_title, question_content)
            if result == QMessageBox.No:
                return

            for machine_cloud_id in self.reported_device_ids:
                machine_manager.setActiveMachine(self._um_cloud_printers[machine_cloud_id].getId())
                machine_manager.removeMachine(self._um_cloud_printers[machine_cloud_id].getId())
            removed_printers_message.hide() 
Example #12
Source File: centralwidget.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def on_delete(self):
        widget_items = self.treeWidget.selectedItems()
        self.window().app.monitor.suspend()

        if len(widget_items) == 1:
            widget_item = widget_items[0]
            data = self.__extractData(widget_item)
            if isinstance(data, model.Folder):
                header = "Delete Folder?"
                msg = "Are you sure you want to delete the '{deleted_folder}' folder and all the items in it?".format(
                    deleted_folder=data.title)
            else:
                entity_type = "Script" if isinstance(data, model.Script) else "Phrase"
                header = "Delete {}?".format(entity_type)
                msg = "Are you sure you want to delete '{element}'?".format(element=data.description)
        else:
            item_count = len(widget_items)
            header = "Delete {item_count} selected items?".format(item_count=item_count)
            msg = "Are you sure you want to delete the {item_count} selected folders/items?".format(
                item_count=item_count)
        result = QMessageBox.question(self.window(), header, msg, QMessageBox.Yes | QMessageBox.No)

        if result == QMessageBox.Yes:
            for widget_item in widget_items:
                self.__removeItem(widget_item)

        self.window().app.monitor.unsuspend()
        if result == QMessageBox.Yes:
            self.window().app.config_altered(False) 
Example #13
Source File: setup.py    From mmvt with GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, event):
        '''
        Shows a message box to confirm the wondow closing
        '''

        reply = QMessageBox.question(self, 'Message',
                                     "Are you sure to quit?", QMessageBox.Yes |
                                     QMessageBox.No, QMessageBox.No)

        if reply == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore() 
Example #14
Source File: testing2.py    From mmvt with GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, event):
        '''
        Shows a message box to confirm the wondow closing
        '''

        reply = QMessageBox.question(self, 'Message',
                                     "Are you sure to quit?", QMessageBox.Yes |
                                     QMessageBox.No, QMessageBox.No)

        if reply == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore() 
Example #15
Source File: testing.py    From mmvt with GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, event):
        '''
        Shows a message box to confirm the wondow closing
        '''

        reply = QMessageBox.question(self, 'Message',
                                     "Are you sure to quit?", QMessageBox.Yes |
                                     QMessageBox.No, QMessageBox.No)

        if reply == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore() 
Example #16
Source File: Editor_x64dbg.py    From X64dbg_script_editor with The Unlicense 5 votes vote down vote up
def closeEvent(self, event):
        reply = QMessageBox.question(self, 'Exit',
            "Are you sure to quit?", QMessageBox.Yes |
            QMessageBox.No, QMessageBox.No)

        if reply == QMessageBox.Yes:
            print dn
            os.chdir(dn)
            print dn
            #os.chdir('../..')
            print dn
            print '''
###################################################
#              Author Storm Shadow                #
#                   Thx To                        #
#                  Tomer Zait                     #
#                   mrexodia                      #
#      Follow x64dbg python project on Github     #
###################################################
#              x64dbg python Editor               #
###################################################
'''
            event.accept()
            os.chdir(dn)
        else:
            event.ignore()
            os.chdir(dn) 
Example #17
Source File: welcome.py    From mmvt with GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, event):
        '''
        Shows a message box to confirm the wondow closing
        '''

        reply = QMessageBox.question(self, 'Message',
                                     "Are you sure to quit?", QMessageBox.Yes |
                                     QMessageBox.No, QMessageBox.No)

        if reply == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore() 
Example #18
Source File: kalkulator05.py    From python101 with MIT License 5 votes vote down vote up
def closeEvent(self, event):

        odp = QMessageBox.question(
            self, 'Komunikat',
            "Czy na pewno koniec?",
            QMessageBox.Yes | QMessageBox.No, QMessageBox.No)

        if odp == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore() 
Example #19
Source File: 猜数游戏.py    From Python-Application with GNU General Public License v3.0 5 votes vote down vote up
def guess(self):
        # text 接受文本框中的文本
        text = self.lineEdit.text()
        # 异常处理
        # 可处理数值型字符串,其他输入提示错误
        try:
            text = float(text)
        except:
            self.label.setText('     输入不合法')
            self.label_2.setText('数值的范围:{}-{}'.format(self.left, self.right))
            self.lineEdit.clear()
            text = ''
        # 文本不为空继续执行文件
        if text:
            num = math.floor(text)
            if self.guess_num == num:
                QMessageBox.question(self, '胜利', '恭喜你猜中了:{}'.format(self.guess_num), QMessageBox.Yes)
                self.reset()

            elif self.guess_num > num:
                if num > self.left:
                    self.left = num
                self.label.setText('数值的范围:{}-{}'.format(self.left, self.right))
                self.label_2.setText('      猜小了')

            elif self.guess_num < num:
                if num < self.right:
                    self.right = num
                self.label.setText('数值的范围:{}-{}'.format(self.left, self.right))
                self.label_2.setText('       猜大了')
            self.lineEdit.clear() 
Example #20
Source File: testing1.py    From mmvt with GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, event):
        '''
        Shows a message box to confirm the wondow closing
        '''

        reply = QMessageBox.question(self, 'Message',
                                     "Are you sure to quit?", QMessageBox.Yes |
                                     QMessageBox.No, QMessageBox.No)

        if reply == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore() 
Example #21
Source File: kalkulator04.py    From python101 with MIT License 5 votes vote down vote up
def closeEvent(self, event):

        odp = QMessageBox.question(
            self, 'Komunikat',
            "Czy na pewno koniec?",
            QMessageBox.Yes | QMessageBox.No, QMessageBox.No)

        if odp == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore() 
Example #22
Source File: pyeditor.py    From Python_editor with The Unlicense 5 votes vote down vote up
def closeEvent(self, event):
        reply = QMessageBox.question(self, 'Exit',
            "Are you sure to quit?", QMessageBox.Yes |
            QMessageBox.No, QMessageBox.No)

        if reply == QMessageBox.Yes:
#            print dn
            os.chdir(dn)
 #           print dn
            #os.chdir('../..')
  #          print dn
            print '''
###################################################
#              Author Storm Shadow                #
#                                                 #
#              Follow me on twitter               #
#                  @zadow28                       #
###################################################
#              Ida pro  python Editor             #
###################################################
'''
            event.accept()
            os.chdir(dn)
        else:
            event.ignore()
            os.chdir(dn) 
Example #23
Source File: pyeditor.py    From Python_editor with The Unlicense 5 votes vote down vote up
def closeEvent(self, event):
        reply = QMessageBox.question(self, 'Exit',
            "Are you sure to quit?", QMessageBox.Yes |
            QMessageBox.No, QMessageBox.No)

        if reply == QMessageBox.Yes:
#            print dn
            os.chdir(dn)
 #           print dn
            #os.chdir('../..')
  #          print dn
            print '''
###################################################
#              Author Storm Shadow                #
#                                                 #
#              Follow me on twitter               #
#                  @zadow28                       #
###################################################
#              Ida pro  python Editor             #
###################################################
'''
            event.accept()
            os.chdir(dn)
        else:
            event.ignore()
            os.chdir(dn) 
Example #24
Source File: Messages.py    From DownloaderForReddit with GNU General Public License v3.0 5 votes vote down vote up
def unsaved_close_message(self):
        text = "Save changes to Downloader For Reddit?"
        reply = message.question(self, "Save Changes?", text, message.Yes | message.No | message.Cancel, message.Cancel)
        if reply == message.Yes:
            return "SAVE"
        elif reply == message.No:
            return "CLOSE"
        else:
            return "CANCEL" 
Example #25
Source File: gui.py    From pbtk with GNU General Public License v3.0 5 votes vote down vote up
def delete_endpoint(self):
        if QMessageBox.question(self.view, ' ', 'Delete this endpoint?') == QMessageBox.Yes:
            path = str(BASE_PATH / 'endpoints' / (urlparse(self.base_url).netloc + '.json'))
            
            with open(path) as fd:
                json = load(fd, object_pairs_hook=OrderedDict)
            json.remove(self.endpoint)
            
            with open(path, 'w') as fd:
                dump(json, fd, ensure_ascii=False, indent=4)
            if not json:
                remove(path)
            
            self.load_endpoints() 
Example #26
Source File: tab_datasets.py    From CvStudio with MIT License 5 votes vote down vote up
def btn_delete_dataset_on_slot(self, vo: DatasetVO):
        reply = QMessageBox.question(self, 'Confirmation', "Are you sure?", QMessageBox.Yes | QMessageBox.No,
                                     QMessageBox.No)
        if reply == QMessageBox.Yes:
            self._ds_dao.delete(vo.id)
            usr_folder = FileUtilities.get_usr_folder()
            ds_folder = os.path.join(usr_folder, vo.folder)
            FileUtilities.delete_folder(ds_folder)
            self.load() 
Example #27
Source File: click_and_show.py    From You-are-Pythonista with GNU General Public License v3.0 5 votes vote down vote up
def on_click(self):
        '''
        点击事件
        '''
        # 获取文本框中输入的值
        textboxValue = self.textbox.text()
        # 弹出对话框
        QMessageBox.question(self, "这里是消息框", '你输入了这些内容:' + textboxValue,
                             QMessageBox.Ok, QMessageBox.Ok)
        # 点击以后清空文本框
        self.textbox.setText('') 
Example #28
Source File: Message_Box.py    From python with Apache License 2.0 5 votes vote down vote up
def closeEvent(self, event):

        reply = QMessageBox.question(self, 'Message',
            "Are you sure to quit?", QMessageBox.Yes | 
            QMessageBox.No, QMessageBox.No)

        if reply == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore() 
Example #29
Source File: Messages.py    From DownloaderForReddit with GNU General Public License v3.0 5 votes vote down vote up
def overwrite_save_file_question(self):
        text = 'A save file is already present in the data directory.\nDo you want to overwrite the save file(s)?\n' \
               'This action cannot be undone'
        reply = message.question(self, 'Overwrite File?', text, message.Yes, message.No)
        return reply == message.Yes 
Example #30
Source File: Messages.py    From DownloaderForReddit with GNU General Public License v3.0 5 votes vote down vote up
def remove_reddit_object(self, name):
        text = 'Are you sure you sure you want to remove %s from the list along with all associated information?' % name
        reply = message.question(self, 'Remove %s' % name, text, message.Yes, message.No)
        return reply == message.Yes