python类ICON_ERROR的实例源码

request2doc_gui.py 文件源码 项目:request2doc 作者: kongxinchi 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def on_request_transform_button_click(self, event):
        url = self.url_text.GetValue()
        method = self.method_choice.GetStringSelection()
        params_value = self.post_params_text.GetValue()
        headers_value = self.headers_text.GetValue()
        slice_startswith = self.slice_text.GetValue()
        template_path = self.get_template_path()

        request_forms = {k: v[0] for k, v in urlparse.parse_qs(params_value).items()}
        headers = headers_value.split('\n')
        handler = Request2Doc(url, method, request_forms)
        if slice_startswith:
            handler.set_slice_startswith(slice_startswith)
        if headers:
            handler.set_headers(headers)

        try:
            if not handler.validate():
                return wx.MessageDialog(None, handler.error_message(), u"Info", wx.OK | wx.ICON_INFORMATION).ShowModal()

            handler.request()

            if not handler.get_response_data():
                return wx.MessageDialog(None, u'Response body is not legal format', u"Information", wx.OK | wx.ICON_INFORMATION).ShowModal()

            res = handler.render_string(template_path)
            self.GetParent().set_response_content(json.dumps(handler.get_response_data(), indent=2))
            self.GetParent().set_document_content(res)

        except Exception, e:
            return wx.MessageDialog(None, traceback.format_exc(), u"Exception", wx.OK | wx.ICON_ERROR).ShowModal()
common.py 文件源码 项目:pyjam 作者: 10se1ucgo 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def wrap_exceptions(func):
    """Wraps a function with an "exception hook" for threads.

    Args:
        func (function): The function to wrap.

    Returns:
        function: The wrapped function
    """
    @wraps(func)
    def wrapper(*args, **kwargs):
        # args[0] = when wrapping a class method. (IT BETTER BE. WHYDOISUCKATPROGRAMMINGOHGOD)
        # This should really only be used on threads (main thread has a sys.excepthook)
        try:
            return func(*args, **kwargs)
        except (SystemExit, KeyboardInterrupt):
            raise
        except Exception:
            if isinstance(args[0], wx.TopLevelWindow):
                parent = args[0]
            elif hasattr(args[0], "parent") and isinstance(args[0].parent, wx.TopLevelWindow):
                parent = args[0].parent
            else:
                parent = wx.GetApp().GetTopWindow()
            error_message = ''.join(traceback.format_exc())
            error_dialog = wx.MessageDialog(parent=parent,
                                            message="An error has occured\n\n" + error_message,
                                            caption="Error!", style=wx.OK | wx.ICON_ERROR)
            error_dialog.RequestUserAttention()
            error_dialog.ShowModal()
            error_dialog.Destroy()
            logger.critical(error_message)
            raise

    return wrapper
w10config.py 文件源码 项目:wintenApps 作者: josephsl 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def addonUpdateCheck(autoCheck=False):
    global progressDialog
    config.conf["wintenApps"]["updateCheckTime"] = int(time.time()) + config.conf["wintenApps"]["updateCheckTimeInterval"] * addonUpdateCheckInterval
    try:
        info = checkForAddonUpdate()
    except:
        log.debugWarning("Error checking for update", exc_info=True)
        if not autoCheck:
            wx.CallAfter(progressDialog.done)
            progressDialog = None
            # Translators: Error text shown when add-on update check fails.
            wx.CallAfter(gui.messageBox, _("Error checking for update."),
                # Translators: Title of the dialog shown when add-on update check fails.
                _("Windows 10 App Essentials update"), wx.ICON_ERROR)
        return
    if not autoCheck:
        wx.CallAfter(progressDialog.done)
        progressDialog = None
    if info is None:
        if not autoCheck:
            # Translators: Presented when no add-on update is available.
            wx.CallAfter(gui.messageBox, _("No add-on update available."),
                # Translators: Title of the dialog presented when no add-on update is available.
                _("Windows 10 App Essentials update"))
            return
    else:
        # Translators: Text shown if an add-on update is available.
        checkMessage = _("Windows 10 App Essentials {newVersion} is available. Would you like to update?").format(newVersion = info["newVersion"])
        # Translators: Title of the add-on update check dialog.
        wx.CallAfter(getUpdateResponse, checkMessage, _("Windows 10 App Essentials update"), info["path"])
w10config.py 文件源码 项目:wintenApps 作者: josephsl 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _error(self):
            self._stopped()
            gui.messageBox(
                # Translators: A message indicating that an error occurred while downloading an update to NVDA.
                _("Error downloading add-on update."),
                # Translators: The title of a dialog indicating that an error occurred while downloading an update to NVDA.
                _("Error"),
                wx.OK | wx.ICON_ERROR)
help.py 文件源码 项目:wpkg-gp-client 作者: sonicnkt 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def InitUI(self):
        self.panel = wx.Panel(self, wx.ID_ANY)
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.html = help = wx.html.HtmlWindow(self.panel, -1, style=wx.NO_BORDER)

        # http://wxpython-users.1045709.n5.nabble.com/Open-a-URL-with-the-default-browser-from-an-HtmlWindow-td2326349.html
        # Bind LINK Click Event to own Function
        help.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked)

        #import codecs
        #file = codecs.open(self.help, "r", "utf-8")
        try:
            file = open(self.help, "r")
        except IOError:
            dlgmsg = u"File not found: \"{}\"".format(self.help)
            dlg = wx.MessageDialog(None, dlgmsg, "WPKG-GP Client", wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            self.Destroy()
        else:
            test = file.read().decode("utf-8")
            html = markdown2.markdown(test, extras=["tables"])
            html = '<body bgcolor="#f0f0f5">' + html
            #print html
            help.SetPage(html)
            sizer.Add(help, 1, wx.EXPAND)
            self.panel.SetSizerAndFit(sizer)
            self.Bind(wx.EVT_CLOSE, self.OnClose)
WPKG-GP-Client_phoenix.py 文件源码 项目:wpkg-gp-client 作者: sonicnkt 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def update_check_done(self, result):
        # Update check function ended
        r = result.get()
        self.checking_updates = False
        if isinstance(r, basestring):
            # Error returned
            self.updates_available = False
            if self.upd_error_count < 2 and not self.show_no_updates:
                # only display update errors on automatic check after the third error in a row
                self.upd_error_count += 1
            else:
                error_str = _(u"Could not load updates:") + "\n" + r
                self.ShowBalloon(title=_(u'Update Error'), text=error_str, msec=20*1000, flags=wx.ICON_ERROR)
                # reset update error counter
                self.upd_error_count = 0
        elif r:
            self.upd_error_count = 0
            action_dict = {'update': _(u'UPD:') + '\t',
                           'install': _(u'NEW:') + '\t',
                           'remove': _(u'REM:') + '\t',
                           'downgrade': _(u'DOW:') + '\t'}
            # Updates Found
            self.updates_available = True
            text = ''
            for action, name, version in r:
                text += action_dict[action] + name + ', v. ' + version + '\n'
            self.ShowBalloon(title=_(u"Update(s) available:"), text=text, msec=20*1000, flags=wx.ICON_INFORMATION)
        else:
            # No Updates Found
            self.upd_error_count = 0
            self.updates_available = False
            if self.show_no_updates:
                self.ShowBalloon(title=_(u"No Updates"), text=" ", msec=20 * 1000, flags=wx.ICON_INFORMATION)
                self.show_no_updates = False
dialogs.py 文件源码 项目:objEnhancer 作者: BabbageCom 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def OnAddClick(self, evt):
        with AddCriteriumDialog(self) as entryDialog:
            if entryDialog.ShowModal() != wx.ID_OK:
                return
            identifier = entryDialog.identifierTextCtrl.GetValue()
            if not identifier:
                return
        for index, criterium in enumerate(self.criteriums):
            if identifier == criterium.identifier:
                # Translators: An error reported in the Criterium Pronunciation dialog when adding a criterium that is already present.
                gui.messageBox(_('Criterium "%s" is already present.') % identifier,
                    _("Error"), wx.OK | wx.ICON_ERROR)
                self.criteriumsList.Select(index)
                self.criteriumsList.Focus(index)
                self.criteriumsList.SetFocus()
                return
        addedCriterium = characterProcessing.SpeechCriterium(identifier)
        try:
            del self.pendingRemovals[identifier]
        except KeyError:
            pass
        addedCriterium.displayName = identifier
        addedCriterium.replacement = ""
        addedCriterium.level = characterProcessing.SYMLVL_ALL
        addedCriterium.preserve = characterProcessing.SYMPRES_NEVER
        self.criteriums.append(addedCriterium)
        item = self.criteriumsList.Append((addedCriterium.displayName,))
        self.updateListItem(item, addedCriterium)
        self.criteriumsList.Select(item)
        self.criteriumsList.Focus(item)
        self.criteriumsList.SetFocus()
BrowseValuesLibraryDialog.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def OnOK(self, event):
        selected = self.ValuesLibrary.GetSelection()
        if not selected.IsOk() or self.ValuesLibrary.GetPyData(selected) is None:
            message = wx.MessageDialog(self, _("No valid value selected!"), _("Error"), wx.OK | wx.ICON_ERROR)
            message.ShowModal()
            message.Destroy()
        else:
            self.EndModal(wx.ID_OK)
ProjectDialog.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def OnOK(self, event):
        values = self.ProjectProperties.GetValues()
        error = []
        for param, name in [("projectName", _("Project Name")),
                            ("productName", _("Product Name")),
                            ("productVersion", _("Product Version")),
                            ("companyName", _("Company Name"))]:
            if values[param] == "":
                error.append(name)
        if len(error) > 0:
            text = ""
            for i, item in enumerate(error):
                if i == 0:
                    text += item
                elif i == len(error) - 1:
                    text += _(" and %s") % item
                else:
                    text += ", %s" % item
            dialog = wx.MessageDialog(
                self,
                _("Form isn't complete. %s must be filled!") % text,
                _("Error"), wx.OK | wx.ICON_ERROR)
            dialog.ShowModal()
            dialog.Destroy()
        else:
            self.EndModal(wx.ID_OK)
ForceVariableDialog.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def OnOK(self, event):
        message = None
        value = self.ValueTextCtrl.GetValue()
        if value == "":
            message = _("You must type a value!")
        elif GetTypeValue[self.IEC_Type](value) is None:
            message = _("Invalid value \"{a1}\" for \"{a2}\" variable!").format(a1=value, a2=self.IEC_Type)
        if message is not None:
            dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR)
            dialog.ShowModal()
            dialog.Destroy()
        else:
            self.EndModal(wx.ID_OK)
        event.Skip()
BlockPreviewDialog.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def ShowErrorMessage(self, message):
        """
        Show an error message dialog over this dialog
        @param message: Error message to display
        """
        dialog = wx.MessageDialog(self, message,
                                  _("Error"),
                                  wx.OK | wx.ICON_ERROR)
        dialog.ShowModal()
        dialog.Destroy()
BrowseLocationsDialog.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def OnOK(self, event):
        selected = self.LocationsTree.GetSelection()
        var_infos = None
        if selected.IsOk():
            var_infos = self.LocationsTree.GetPyData(selected)
        if var_infos is None or var_infos["type"] in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP]:
            dialog = wx.MessageDialog(self, _("A location must be selected!"), _("Error"), wx.OK | wx.ICON_ERROR)
            dialog.ShowModal()
            dialog.Destroy()
        else:
            self.EndModal(wx.ID_OK)
PouTransitionDialog.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def OnOK(self, event):
        error = []
        transition_name = self.TransitionName.GetValue()
        if self.TransitionName.GetValue() == "":
            error.append(_("Transition Name"))
        if self.Language.GetSelection() == -1:
            error.append(_("Language"))
        message = None
        if len(error) > 0:
            text = ""
            for i, item in enumerate(error):
                if i == 0:
                    text += item
                elif i == len(error) - 1:
                    text += _(" and %s") % item
                else:
                    text += _(", %s") % item
            message = _("Form isn't complete. %s must be filled!") % text
        elif not TestIdentifier(transition_name):
            message = _("\"%s\" is not a valid identifier!") % transition_name
        elif transition_name.upper() in IEC_KEYWORDS:
            message = _("\"%s\" is a keyword. It can't be used!") % transition_name
        elif transition_name.upper() in self.PouNames:
            message = _("A POU named \"%s\" already exists!") % transition_name
        elif transition_name.upper() in self.PouElementNames:
            message = _("\"%s\" element for this pou already exists!") % transition_name
        if message is not None:
            dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR)
            dialog.ShowModal()
            dialog.Destroy()
        else:
            self.EndModal(wx.ID_OK)
DurationEditorDialog.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def GetControlValueTestFunction(self, control):
        def OnValueChanged(event):
            try:
                value = float(control.GetValue())
            except ValueError, e:
                message = wx.MessageDialog(self, _("Invalid value!\nYou must fill a numeric value."), _("Error"), wx.OK | wx.ICON_ERROR)
                message.ShowModal()
                message.Destroy()
            event.Skip()
            self.OnCloseDialog()
        return OnValueChanged
SearchInProjectDialog.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def OnFindButton(self, event):
        message = None
        infos = {
            "find_pattern": self.Pattern.GetValue(),
            "case_sensitive": self.CaseSensitive.GetValue(),
            "regular_expression": self.RegularExpression.GetValue(),
        }
        if self.WholeProject.GetValue():
            infos["filter"] = "all"
        elif self.OnlyElements.GetValue():
            infos["filter"] = []
            for index, (name, label) in enumerate(GetElementsChoices()):
                if self.ElementsList.IsChecked(index):
                    infos["filter"].append(name)

        if self.infosPrev != infos:
            try:
                self.criteria = infos
                CompilePattern(self.criteria)
                self.infosPrev = infos
            except Exception:
                self.criteria.clear()
                message = _("Syntax error in regular expression of pattern to search!")

        if message is not None:
            dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR)
            dialog.ShowModal()
            dialog.Destroy()
        else:
            self.EndModal(wx.ID_OK)
IDEFrame.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def ShowErrorMessage(self, message):
        """Function displaying an Error dialog in editor.

        :param message: The message to display.
        """
        dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR)
        dialog.ShowModal()
        dialog.Destroy()
VariablePanel.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def ShowMessage(self, message):
        message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK | wx.ICON_ERROR)
        message.ShowModal()
        message.Destroy()


# -------------------------------------------------------------------------------
#                               Variable Panel
# -------------------------------------------------------------------------------
DebugVariablePanel.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def ShowMessage(self, message):
        """
        Show error message in Error Dialog
        @param message: Error message to display
        """
        dialog = wx.MessageDialog(self.ParentWindow,
                                  message,
                                  _("Error"),
                                  wx.OK | wx.ICON_ERROR)
        dialog.ShowModal()
        dialog.Destroy()
ResourceEditor.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def ShowErrorMessage(self, message):
        dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR)
        dialog.ShowModal()
        dialog.Destroy()
Viewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def ShowMessage(self, message):
        message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK | wx.ICON_ERROR)
        message.ShowModal()
        message.Destroy()


问题


面经


文章

微信
公众号

扫码关注公众号