Python PySide.QtGui.QMessageBox() Examples

The following are 30 code examples of PySide.QtGui.QMessageBox(). 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 PySide.QtGui , or try the search function .
Example #1
Source File: IsoCurve2.py    From CurvesWB with GNU Lesser General Public License v2.1 6 votes vote down vote up
def run():
    sel = Gui.Selection.getSelectionEx()
    try:
        if len(sel) != 1:
            raise Exception("Select one face only.")
        try:
            App.ActiveDocument.openTransaction("Macro IsoCurve")
            selfobj = makeIsoCurveFeature()
            so = sel[0].SubObjects[0]
            p = sel[0].PickedPoints[0]
            poe = so.distToShape(Part.Vertex(p))
            par = poe[2][0][2]
            selfobj.Face = [sel[0].Object,sel[0].SubElementNames]
            selfobj.Parameter = par[0]
            selfobj.Proxy.execute(selfobj)
        finally:
            App.ActiveDocument.commitTransaction()
    except Exception as err:
        from PySide import QtGui
        mb = QtGui.QMessageBox()
        mb.setIcon(mb.Icon.Warning)
        mb.setText("{0}".format(err))
        mb.setWindowTitle("Macro IsoCurve")
        mb.exec_() 
Example #2
Source File: app.py    From shortcircuit with MIT License 6 votes vote down vote up
def version_check_done(self, version):
        self.version_thread.quit()

        if version and __version__ != version:
            version_box = QtGui.QMessageBox(self)
            version_box.setWindowTitle("New version available!")
            version_box.setText(
                "You have version '{}', but there's a new version available: '{}'.".format(__version__, version)
            )
            version_box.addButton("Download now", QtGui.QMessageBox.AcceptRole)
            version_box.addButton("Remind me later", QtGui.QMessageBox.RejectRole)
            ret = version_box.exec_()

            if ret == QtGui.QMessageBox.AcceptRole:
                QtGui.QDesktopServices.openUrl(
                    QtCore.QUrl("https://github.com/farshield/shortcircuit/releases/tag/{}".format(version))
                )

    # event: QCloseEvent 
Example #3
Source File: libAsm4.py    From FreeCAD_Assembly4 with GNU Lesser General Public License v2.1 6 votes vote down vote up
def confirmBox( text ):
    msgBox = QtGui.QMessageBox()
    msgBox.setWindowTitle('FreeCAD Warning')
    msgBox.setIcon(QtGui.QMessageBox.Warning)
    msgBox.setText(text)
    msgBox.setInformativeText('Are you sure you want to proceed ?')
    msgBox.setStandardButtons(QtGui.QMessageBox.Cancel | QtGui.QMessageBox.Ok)
    msgBox.setEscapeButton(QtGui.QMessageBox.Cancel)
    msgBox.setDefaultButton(QtGui.QMessageBox.Ok)
    retval = msgBox.exec_()
    # Cancel = 4194304
    # Ok = 1024
    if retval == 1024:
        # user confirmed
        return True
    # anything else than OK
    return False 
Example #4
Source File: terminal.py    From autopilot with Mozilla Public License 2.0 6 votes vote down vote up
def update_protocols(self):
        """
        If we change the protocol file, update the stored version in subject files
        """
        #
        # get list of protocol files
        protocols = os.listdir(prefs.PROTOCOLDIR)
        protocols = [p for p in protocols if p.endswith('.json')]


        subjects = self.list_subjects()
        for subject in subjects:
            if subject not in self.subjects.keys():
                self.subjects[subject] = Subject(subject)

            protocol_bool = [self.subjects[subject].protocol_name == p.rstrip('.json') for p in protocols]
            if any(protocol_bool):
                which_prot = np.where(protocol_bool)[0][0]
                protocol = protocols[which_prot]
                self.subjects[subject].assign_protocol(os.path.join(prefs.PROTOCOLDIR, protocol), step_n=self.subjects[subject].step)

        msgbox = QtGui.QMessageBox()
        msgbox.setText("Subject Protocols Updated")
        msgbox.exec_() 
Example #5
Source File: terminal.py    From autopilot with Mozilla Public License 2.0 6 votes vote down vote up
def calibrate_ports(self):

        calibrate_window = Calibrate_Water(self.pilots)
        calibrate_window.exec_()

        if calibrate_window.result() == 1:
            for pilot, p_widget in calibrate_window.pilot_widgets.items():
                p_results = p_widget.volumes
                # p_results are [port][dur] = {params} so running the same duration will
                # overwrite a previous run. unnest here so pi can keep a record
                unnested_results = {}
                for port, result in p_results.items():
                    unnested_results[port] = []
                    # result is [dur] = {params}
                    for dur, inner_result in result.items():
                        inner_result['dur'] = dur
                        unnested_results[port].append(inner_result)

                # send to pi
                self.node.send(to=pilot, key="CALIBRATE_RESULT",
                               value = unnested_results)

            msgbox = QtGui.QMessageBox()
            msgbox.setText("Calibration results sent!")
            msgbox.exec_() 
Example #6
Source File: gui.py    From autopilot with Mozilla Public License 2.0 6 votes vote down vote up
def remove_subject(self):
        """
        Remove the currently selected subject in :py:attr:`Pilot_Panel.subject_list`,
        and calls the :py:meth:`Control_Panel.update_db` method.
        """

        current_subject = self.subject_list.currentItem().text()
        msgbox = QtGui.QMessageBox()
        msgbox.setText("\n(only removes from pilot_db.json, data will not be deleted)".format(current_subject))

        msgBox = QtGui.QMessageBox()
        msgBox.setText("Are you sure you would like to remove {}?".format(current_subject))
        msgBox.setInformativeText("'Yes' only removes from pilot_db.json, data will not be deleted")
        msgBox.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
        msgBox.setDefaultButton(QtGui.QMessageBox.No)
        ret = msgBox.exec_()

        if ret == QtGui.QMessageBox.Yes:

            self.subject_list.takeItem(self.subject_list.currentRow())
            # the drop fn updates the db
            self.subject_list.drop_fn() 
Example #7
Source File: gui.py    From autopilot with Mozilla Public License 2.0 6 votes vote down vote up
def save(self):
        """
        Select save file location for test results (csv) and then save them there

        """

        fileName, filtr = QtGui.QFileDialog.getSaveFileName(self,
                "Where should we save these results?",
                prefs.DATADIR,
                "CSV files (*.csv)", "")

        # make and save results df
        try:
            res_df = pd.DataFrame.from_records(self.results,
                                               columns=['rate', 'payload_size', 'message_size', 'n_messages', 'confirm',
                                                        'n_pilots', 'mean_delay', 'drop_rate',
                                                        'actual_rate', 'send_jitter', 'delay_jitter'])

            res_df.to_csv(fileName)
            reply = QtGui.QMessageBox.information(self,
                                                  "Results saved!", "Results saved to {}".format(fileName))

        except Exception as e:
            reply = QtGui.QMessageBox.critical(self, "Error saving",
                                               "Error while saving your results:\n{}".format(e)) 
Example #8
Source File: universal_tool_template_1112.py    From universal_tool_template.py with MIT License 6 votes vote down vote up
def quickMsg(self, msg, block=1):
        tmpMsg = QtWidgets.QMessageBox(self) # for simple msg that no need for translation
        tmpMsg.setWindowTitle("Info")
        lineCnt = len(msg.split('\n'))
        if lineCnt > 25:
            scroll = QtWidgets.QScrollArea()
            scroll.setWidgetResizable(1)
            content = QtWidgets.QWidget()
            scroll.setWidget(content)
            layout = QtWidgets.QVBoxLayout(content)
            layout.addWidget(QtWidgets.QLabel(msg))
            tmpMsg.layout().addWidget(scroll, 0, 0, 1, tmpMsg.layout().columnCount())
            tmpMsg.setStyleSheet("QScrollArea{min-width:600 px; min-height: 400px}")
        else:
            tmpMsg.setText(msg)
        if block == 0:
            tmpMsg.setWindowModality( QtCore.Qt.NonModal )
        tmpMsg.addButton("OK",QtWidgets.QMessageBox.YesRole)
        if block:
            tmpMsg.exec_()
        else:
            tmpMsg.show() 
Example #9
Source File: universal_tool_template_1115.py    From universal_tool_template.py with MIT License 6 votes vote down vote up
def quickMsg(self, msg, block=1):
        tmpMsg = QtWidgets.QMessageBox(self) # for simple msg that no need for translation
        tmpMsg.setWindowTitle("Info")
        lineCnt = len(msg.split('\n'))
        if lineCnt > 25:
            scroll = QtWidgets.QScrollArea()
            scroll.setWidgetResizable(1)
            content = QtWidgets.QWidget()
            scroll.setWidget(content)
            layout = QtWidgets.QVBoxLayout(content)
            tmpLabel = QtWidgets.QLabel(msg)
            tmpLabel.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
            layout.addWidget(tmpLabel)
            tmpMsg.layout().addWidget(scroll, 0, 0, 1, tmpMsg.layout().columnCount())
            tmpMsg.setStyleSheet("QScrollArea{min-width:600 px; min-height: 400px}")
        else:
            tmpMsg.setText(msg)
        if block == 0:
            tmpMsg.setWindowModality( QtCore.Qt.NonModal )
        tmpMsg.addButton("OK",QtWidgets.QMessageBox.YesRole)
        if block:
            tmpMsg.exec_()
        else:
            tmpMsg.show() 
Example #10
Source File: SheetMetalBend.py    From FreeCAD_SheetMetal with GNU General Public License v3.0 5 votes vote down vote up
def smWarnDialog(msg):
    diag = QtGui.QMessageBox(QtGui.QMessageBox.Warning, 'Error in macro MessageBox', msg)
    diag.setWindowModality(QtCore.Qt.ApplicationModal)
    diag.exec_() 
Example #11
Source File: universal_tool_template_v8.1.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def default_message(self, ui_name):
        msgName = ui_name[:-7]+"_msg"
        msg_txt = msgName + " is not defined in uiList."
        if msgName in self.uiList:
            msg_txt = self.uiList[msgName]
        tmpMsg = QtWidgets.QMessageBox()
        tmpMsg.setWindowTitle("Info")
        tmpMsg.setText(msg_txt)
        tmpMsg.addButton("OK",QtWidgets.QMessageBox.YesRole)
        tmpMsg.exec_() 
Example #12
Source File: universal_tool_template_1010.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def quickMsg(self, msg, block=1):
        tmpMsg = QtWidgets.QMessageBox(self) # for simple msg that no need for translation
        tmpMsg.setWindowTitle("Info")
        tmpMsg.setText(msg)
        if block == 0:
            tmpMsg.setWindowModality( QtCore.Qt.NonModal )
        tmpMsg.addButton("OK",QtWidgets.QMessageBox.YesRole)
        if block:
            tmpMsg.exec_()
        else:
            tmpMsg.show() 
Example #13
Source File: test_version_mover.py    From anima with MIT License 5 votes vote down vote up
def setUpClass(cls):
        """set up once
        """
        # patch QMessageBox
        cls.original_message_box = QtGui.QMessageBox
        QtGui.QMessageBox = PatchedMessageBox 
Example #14
Source File: test_version_mover.py    From anima with MIT License 5 votes vote down vote up
def tearDownClass(cls):
        """clean up once
        """
        QtGui.QMessageBox = cls.original_message_box 
Example #15
Source File: test_edl_importer.py    From anima with MIT License 5 votes vote down vote up
def test_send_pushButton_will_warn_the_user_to_set_the_media_files_path_if_it_is_not_set_before(self):
        """testing if send_pushButton will warn the user to set the media files
        path in preferences if it is not set before
        """
        # set a proper EDL file
        edl_path = os.path.abspath('../previs/test_data/test_v001.edl')
        self.dialog.edl_path_lineEdit.setText(edl_path)

        # patch QMessageBox.critical method
        original = QtGui.QMessageBox.critical
        QtGui.QMessageBox = PatchedMessageBox

        self.assertEqual(PatchedMessageBox.called_function, '')
        self.assertEqual(PatchedMessageBox.title, '')
        self.assertEqual(PatchedMessageBox.message, '')

        # now hit it
        QTest.mouseClick(self.dialog.send_pushButton, Qt.LeftButton)

        # restore QMessageBox.critical
        QtGui.QMessageBox.critical = original

        self.assertEqual(PatchedMessageBox.called_function, 'critical')
        self.assertEqual(PatchedMessageBox.title, 'Error')

        self.assertEqual(
            "Media path doesn't exists",
            PatchedMessageBox.message
        ) 
Example #16
Source File: universal_tool_template_1000.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def quickMsg(self, msg):
        tmpMsg = QtWidgets.QMessageBox() # for simple msg that no need for translation
        tmpMsg.setWindowTitle("Info")
        tmpMsg.setText(msg)
        tmpMsg.addButton("OK",QtWidgets.QMessageBox.YesRole)
        tmpMsg.exec_() 
Example #17
Source File: SheetMetalJunction.py    From FreeCAD_SheetMetal with GNU General Public License v3.0 5 votes vote down vote up
def smWarnDialog(msg):
    diag = QtGui.QMessageBox(QtGui.QMessageBox.Warning, 'Error in macro MessageBox', msg)
    diag.setWindowModality(QtCore.Qt.ApplicationModal)
    diag.exec_() 
Example #18
Source File: SheetMetalFoldCmd.py    From FreeCAD_SheetMetal with GNU General Public License v3.0 5 votes vote down vote up
def smWarnDialog(msg):
    diag = QtGui.QMessageBox(QtGui.QMessageBox.Warning, 'Error in macro MessageBox', msg)
    diag.setWindowModality(QtCore.Qt.ApplicationModal)
    diag.exec_() 
Example #19
Source File: SheetMetalUnfolder.py    From FreeCAD_SheetMetal with GNU General Public License v3.0 5 votes vote down vote up
def SMErrorBox(* args):
    message = ""
    for x in args:
        message += str(x)
    # Error boxes mostly use HTML tags to format. Strip the HTML tags for 
    # better console readability. 
    stripped_message = re.sub('<[^<]+?>', '', message)
    SMError(stripped_message) 
    mw = FreeCADGui.getMainWindow()
    msg_box = QtGui.QMessageBox(mw)
    msg_box.setTextFormat(QtCore.Qt.TextFormat.RichText)
    msg_box.setText(message)
    msg_box.setWindowTitle("Error")
    msg_box.setIcon(QtGui.QMessageBox.Critical)
    msg_box.exec_() 
Example #20
Source File: SheetMetalRelief.py    From FreeCAD_SheetMetal with GNU General Public License v3.0 5 votes vote down vote up
def smWarnDialog(msg):
    diag = QtGui.QMessageBox(QtGui.QMessageBox.Warning, 'Error in macro MessageBox', msg)
    diag.setWindowModality(QtCore.Qt.ApplicationModal)
    diag.exec_() 
Example #21
Source File: SheetMetalCmd.py    From FreeCAD_SheetMetal with GNU General Public License v3.0 5 votes vote down vote up
def smWarnDialog(msg):
    diag = QtGui.QMessageBox(QtGui.QMessageBox.Warning, 'Error in macro MessageBox', msg)
    diag.setWindowModality(QtCore.Qt.ApplicationModal)
    diag.exec_() 
Example #22
Source File: Animation.py    From Animation with GNU General Public License v2.0 5 votes vote down vote up
def errorDialog(msg):
    diag = QtGui.QMessageBox(QtGui.QMessageBox.Critical,u"Error Message",msg )
    diag.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint)
    diag.exec_() 
Example #23
Source File: Animation.py    From Animation with GNU General Public License v2.0 5 votes vote down vote up
def showVersion(self):
		cl=self.Object.Proxy.__class__.__name__
		PySide.QtGui.QMessageBox.information(None, "About ", "Animation" + cl +" Node\nVersion " + self.vers) 
Example #24
Source File: say.py    From Animation with GNU General Public License v2.0 5 votes vote down vote up
def errorDialog(msg):
    diag = QtGui.QMessageBox(QtGui.QMessageBox.Critical,u"Error Message",msg )
    diag.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint)
    diag.exec_() 
Example #25
Source File: exportPartToVRML.py    From kicad-3d-models-in-freecad with GNU General Public License v2.0 5 votes vote down vote up
def infoDialog(msg):
    #QtGui.qFreeCAD.setOverrideCursor(QtCore.Qt.WaitCursor)
    QtGui.qApp.restoreOverrideCursor()
    diag = QtGui.QMessageBox(QtGui.QMessageBox.Information,u"Info Message",msg )
    diag.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
    diag.exec_()
    QtGui.qApp.restoreOverrideCursor()


# points: [Vector, Vector, ...]
# faces: [(pi, pi, pi), ], pi: point index
# color: (Red, Green, Blue), values range from 0 to 1.0 or color name as defined within this document. 
Example #26
Source File: exportPartToVRML.py    From kicad-3d-models-in-freecad with GNU General Public License v2.0 5 votes vote down vote up
def infoDialog(msg):
    #QtGui.qFreeCAD.setOverrideCursor(QtCore.Qt.WaitCursor)
    QtGui.qApp.restoreOverrideCursor()
    diag = QtGui.QMessageBox(QtGui.QMessageBox.Information,u"Info Message",msg )
    diag.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
    diag.exec_()
    QtGui.qApp.restoreOverrideCursor()


# points: [Vector, Vector, ...]
# faces: [(pi, pi, pi), ], pi: point index
# color: (Red, Green, Blue), values range from 0 to 1.0 or color name as defined within this document. 
Example #27
Source File: universal_tool_template_v7.3.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def default_message(self, ui_name):
        msgName = ui_name[:-7]+"_msg"
        msg_txt = msgName + " is not defined in uiList."
        if msgName in self.uiList:
            msg_txt = self.uiList[msgName]
        tmpMsg = QtGui.QMessageBox()
        tmpMsg.setWindowTitle("Info")
        tmpMsg.setText(msg_txt)
        tmpMsg.addButton("OK",QtGui.QMessageBox.YesRole)
        tmpMsg.exec_()
    
    #=======================================
    #- UI and RAM content update functions (optional)
    #======================================= 
Example #28
Source File: IsoCurve.py    From CurvesWB with GNU Lesser General Public License v2.1 5 votes vote down vote up
def run():
    f = Gui.Selection.Filter("SELECT Part::Feature SUBELEMENT Face COUNT 1..1000")
    try:
        if not f.match():
            raise Exception("Select at least one face.")
        try:
            App.ActiveDocument.openTransaction("Macro IsoCurve")
            r = f.result()
            for e in r:
                for s in e:
                    for f in s.SubElementNames:
                        #App.ActiveDocument.openTransaction("Macro IsoCurve")
                        selfobj = makeIsoCurveFeature()
                        #so = sel[0].SubObjects[0]
                        #p = sel[0].PickedPoints[0]
                        #poe = so.distToShape(Part.Vertex(p))
                        #par = poe[2][0][2]
                        #selfobj.Face = [sel[0].Object,sel[0].SubElementNames]
                        selfobj.Face = [s.Object,f]
                        #selfobj.Parameter = par[0]
                        selfobj.Proxy.execute(selfobj)
        finally:
            App.ActiveDocument.commitTransaction()
    except Exception as err:
        from PySide import QtGui
        mb = QtGui.QMessageBox()
        mb.setIcon(mb.Icon.Warning)
        mb.setText("{0}".format(err))
        mb.setWindowTitle("Macro IsoCurve")
        mb.exec_() 
Example #29
Source File: CommandsPolar.py    From flamingo with GNU Lesser General Public License v3.0 5 votes vote down vote up
def Activated(self):
    import polarUtilsCmd as puc
    import FreeCAD, FreeCADGui
    from PySide import QtGui as qg
    if (FreeCADGui.Selection.countObjectsOfType('Sketcher::SketchObject')==0):
      qg.QMessageBox().information(None,'Incorrect input','First select at least one sketch.')
    else:
      n=int(qg.QInputDialog.getText(None,"draw a Polygon","Number of sides?")[0])
      R=float(qg.QInputDialog.getText(None,"draw a Polygon","Radius of circumscribed circle?")[0])
      for sk in FreeCADGui.Selection.getSelection():
        if sk.TypeId=="Sketcher::SketchObject":
          puc.disegna(sk,puc.cerchio(R,n)) 
Example #30
Source File: app.py    From shortcircuit with MIT License 5 votes vote down vote up
def _message_box(self, title, text):
        msg_box = QtGui.QMessageBox(self)
        msg_box.setWindowTitle(title)
        msg_box.setText(text)
        return msg_box.exec_()