コード例 #1
0
 def OnLinkClicked(self, linkinfo):
     href = linkinfo.GetHref()
     if href == 'show_license':
         if config.license_file:
             from wx.lib.dialogs import ScrolledMessageDialog
             try:
                 license_file = codecs.open(
                     config.license_file, encoding='UTF-8')
                 dlg = ScrolledMessageDialog(
                     self,
                     license_file.read(),
                     _("wxGlade - License")
                     )
                 license_file.close()
                 dlg.ShowModal()
                 dlg.Destroy()
             except IOError:
                 wx.MessageBox(
                     _('License file "LICENSE.txt" not found!\n'
                       'You can get a copy at \n'
                       'http://www.opensource.org/licenses/'
                       'mit-license.php'),
                     _('Error'),
                     wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION)
         else:
             wx.MessageBox(
                 _('License file "LICENSE.txt" not found!\n'
                   'You can get a copy at \n'
                   'http://www.opensource.org/licenses/'
                   'mit-license.php'),
                 _('Error'),
                 wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION)
     elif href == 'show_credits':
         if config.credits_file:
             from wx.lib.dialogs import ScrolledMessageDialog
             try:
                 credits_file = codecs.open(
                     config.credits_file, encoding='UTF-8')
                 dlg = ScrolledMessageDialog(
                     self,
                     credits_file.read(),
                     _("wxGlade - Credits")
                     )
                 credits_file.close()
                 dlg.ShowModal()
                 dlg.Destroy()
             except IOError:
                 wx.MessageBox(
                     _('Credits file "CREDITS.txt" not found!'),
                     _('Error'),
                     wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION)
         else:
             wx.MessageBox(
                 _('Credits file "CREDITS.txt" not found!'),
                 _('Error'),
                 wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION)
     else:
         import webbrowser
         webbrowser.open(linkinfo.GetHref(), new=True)
コード例 #2
0
    def OnErrScrolledDialog(self, event=None):
        if not isDarwin():
            Warn(None, 'aborting: functionality only available on mac',
                 'Error')
            return

        ok = False
        import os.path
        fname = self.getLogFileName(pidoffset=-1)
        if os.path.isfile(fname):
            ok = True
        else:
            fname = self.getLogFileName(pidoffset=0)
            if os.path.isfile(fname):
                ok = True
            else:
                Warn(
                    None, 'aborting: cannot find log file, tried %s and %s' %
                    (self.getLogFileName(pidoffset=-1),
                     self.getLogFileName(pidoffset=0)))
        if ok:
            with open(fname, "r") as f:
                txt = "\n".join(f.readlines())
                dlg = ScrolledMessageDialog(self.visFr,
                                            txt,
                                            "VisGUI Error Output",
                                            size=(900, 400),
                                            style=wx.RESIZE_BORDER
                                            | wx.DEFAULT_DIALOG_STYLE)
                dlg.ShowModal()
                dlg.Destroy()
コード例 #3
0
ファイル: wxpython.py プロジェクト: randomchars42/Sortingshop
    def display_dialog(self, message, caption='Info', dialog_type='yesno',
            callbacks={}, scrollable=None):
        """Display a configurable dialog."""
        style = None

        if dialog_type == 'yesno':
            style = wx.ICON_QUESTION|wx.YES_NO|wx.CANCEL
        elif dialog_type == 'okcancel':
            style = wx.ICON_QUESTION|wx.OK|wx.CANCEL
        else:
            style = wx.ICON_INFORMATION|wx.OK

        if scrollable is None:
            scrollable = message.count("\n") > 4

        if scrollable:
            dialog = ScrolledMessageDialog(
                    self.__frame, message, caption = caption, style =  style)
        else:
            dialog = wx.MessageDialog(
                    self.__frame, message, caption = caption, style =  style)

        clicked = dialog.ShowModal()

        # find and execute the apropriate callback:
        # map wx.ID_??? against the dictionary passed as param to this function
        # if any key is not defined "do" will become an empty lambda expression
        do = {
                wx.ID_YES: callbacks.get('yes', lambda: None),
                wx.ID_NO: callbacks.get('no', lambda: None),
                wx.ID_CANCEL: callbacks.get('cancel', lambda: None),
                wx.ID_OK: callbacks.get('ok', lambda: None)
                }.get(clicked, lambda: None)()

        dialog.Destroy()
コード例 #4
0
ファイル: OpioidInterface.py プロジェクト: bcorfman/pug
    def reload_project_files(self,
                             doReload=True,
                             errors=None,
                             show_dialog=True,
                             save_reload=True):
        """reload_project_files(doReload=True, errors=None, show_dialog=True, 
                                reload_scene=True)

doReload: force reload of all files
errors: dict of errors. Will be filled with file errors. Errors can be provided
    in one of two forms... 1)module: sys.exc_info() or 2)*header: sys.exc_info()
show_dialog: show a dialog displaying all file errors found
save_reload: if True, save the working file before reloading project files, then
    reload the scene when done
"""
        if save_reload:
            if not self.check_save():
                return
        if errors is None:
            errors = {}
        self.reload_components(doReload=doReload, errors=errors)
        self.reload_object_list(doReload=doReload, errors=errors)
        self.reload_scene_list(doReload=doReload, errors=errors)
        if show_dialog and errors:
            keys = errors.keys()
            top_keys = []  # *'d keys with specific error headers
            mod_keys = []  # standard keys with error module
            for key in keys:
                if key[0] == '*':
                    top_keys.append(key)
                else:
                    mod_keys.append(key)
            keys.sort()
            top_keys.sort()
            msg = 'The following errors were found in the project files:\n\n'
            for header in top_keys:
                info = errors[header]
                header = header[1:]
                msg += header + ':\n\n'
                msg += ''.join(traceback.format_exception(*info))
                msg += '_' * 90 + '\n\n'
            for mod in mod_keys:
                msg += 'Error in module ' + mod + ':\n\n'
                info = errors[mod]
                msg += ''.join(traceback.format_exception(*info))
                msg += '_' * 90 + '\n\n'
            err = ScrolledMessageDialog(self.frame,
                                        msg,
                                        'Project File Errors',
                                        size=(640, 320),
                                        style=wx.DEFAULT_DIALOG_STYLE
                                        | wx.RESIZE_BORDER)
            err.ShowModal()
            err.Destroy()
        if save_reload:
            Opioid2D.ResourceManager.clear_cache()
            self.set_scene(self.scene.__class__.__name__, True)
コード例 #5
0
 def OnLinkClicked(self, event):
     href = event.GetLinkInfo().GetHref()
     if href == 'show_license':
         if config.license_file:
             from wx.lib.dialogs import ScrolledMessageDialog
             try:
                 license_file = codecs.open(config.license_file,
                                            encoding='UTF-8')
                 dlg = ScrolledMessageDialog(self, license_file.read(),
                                             "wxGlade - License")
                 license_file.close()
                 dlg.ShowModal()
                 dlg.Destroy()
             except EnvironmentError as inst:
                 bugdialog.ShowEnvironmentError(
                     _('''Can't read the file "LICENSE.txt".\n\nYou can get a license copy at\n'''
                       '''http://www.opensource.org/licenses/mit-license.php'''
                       ), inst)
         else:
             wx.MessageBox(
                 _('File "LICENSE.txt" not found!\nYou can get a license copy at\n'
                   'http://www.opensource.org/licenses/mit-license.php'),
                 _('Error'), wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION)
     elif href == 'show_credits':
         if config.credits_file:
             from wx.lib.dialogs import ScrolledMessageDialog
             try:
                 credits_file = codecs.open(config.credits_file,
                                            encoding='UTF-8')
                 dlg = ScrolledMessageDialog(self, credits_file.read(),
                                             _("wxGlade - Credits"))
                 credits_file.close()
                 dlg.ShowModal()
                 dlg.Destroy()
             except EnvironmentError as inst:
                 bugdialog.ShowEnvironmentError(
                     _('''Can't read the file "CREDITS.txt"'''), inst)
         else:
             wx.MessageBox(_('File "CREDITS.txt" not found!'), _('Error'),
                           wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION)
     else:
         import webbrowser
         webbrowser.open(href, new=True)
コード例 #6
0
ファイル: DlgHelp.py プロジェクト: hasii2011/PyUt
    def __OnViewSource(self, event):
        """
        View document source

        @since 1.1
        @author C.Dutoit
        """
        source = self.html.GetParser().GetSource()
        dlg = ScrolledMessageDialog(self, source, _('HTML Source'))
        dlg.ShowModal()
        dlg.Destroy()
コード例 #7
0
 def give_scrolled_message(self, title, msg):
     dlg = ScrolledMessageDialog(self,
                                 msg,
                                 title,
                                 size=(1000, 600),
                                 style=wx.DEFAULT_DIALOG_STYLE
                                 | wx.RESIZE_BORDER)
     points = dlg.text.GetFont().GetPointSize()  # get the current size
     f = wx.Font(points, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL,
                 wx.FONTWEIGHT_NORMAL)
     dlg.text.SetFont(f)
     dlg.ShowModal()
     dlg.Destroy()
コード例 #8
0
 def OnLinkClicked(self, linkinfo):
     href = linkinfo.GetHref()
     if href == 'show_license':
         from wx.lib.dialogs import ScrolledMessageDialog
         try:
             license = open(
                 os.path.join(common.wxglade_path, 'license.txt'))
             dlg = ScrolledMessageDialog(self, license.read(),
                                         _("wxGlade - License"))
             license.close()
             dlg.ShowModal()
             dlg.Destroy()
         except IOError:
             wx.MessageBox(
                 _("Can't find the license!\n"
                   "You can get a copy at \n"
                   "http://www.opensource.org/licenses/"
                   "mit-license.php"), _("Error"),
                 wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION)
     elif href == 'show_credits':
         from wx.lib.dialogs import ScrolledMessageDialog
         try:
             credits = open(
                 os.path.join(common.wxglade_path, 'credits.txt'))
             dlg = ScrolledMessageDialog(self, credits.read(),
                                         _("wxGlade - Credits"))
             credits.close()
             dlg.ShowModal()
             dlg.Destroy()
         except IOError:
             wx.MessageBox(_("Can't find the credits file!\n"),
                           _("Oops!"),
                           wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION)
     else:
         import webbrowser
         webbrowser.open(linkinfo.GetHref(), new=True)
コード例 #9
0
 def _show_alert_dialog(self, text, details, severity='error'):
     if __debug__: log('showing message dialog')
     frame = self._current_frame()
     if severity == 'fatal':
         short = text
         style = wx.OK | wx.ICON_ERROR
         extra_text = 'fatal '
     else:
         short = text + '\n\nWould you like to try to continue?\n(Click "no" to quit now.)'
         style = wx.YES_NO | wx.YES_DEFAULT | wx.ICON_EXCLAMATION
         extra_text = ''
     if details:
         style |= wx.HELP
     caption = "Check It! has encountered a {}problem".format(extra_text)
     dlg = wx.MessageDialog(frame,
                            message=short,
                            style=style,
                            caption=caption)
     clicked = dlg.ShowModal()
     if clicked == wx.ID_HELP:
         body = ("Check It! has encountered a problem:\n" + "─" * 30 +
                 "\n{}\n".format(details or text) + "─" * 30 +
                 "\nIf the problem is due to a network timeout or " +
                 "similar transient error, then please quit and try again "
                 + "later. If you don't know why the error occurred or " +
                 "if it is beyond your control, please also notify the " +
                 "developers. You can reach the developers via email:\n\n" +
                 "    Email: [email protected]\n")
         info = ScrolledMessageDialog(frame, body, "Error")
         info.ShowModal()
         info.Destroy()
         frame.Destroy()
         self._queue.put(True)
         if 'fatal' in severity:
             if __debug__: log('sending stop message to UI')
             wx.CallAfter(pub.sendMessage, 'stop')
     elif clicked in [wx.ID_NO, wx.ID_OK]:
         dlg.Destroy()
         frame.Destroy()
         self._queue.put(True)
         if __debug__: log('sending stop message to UI')
         wx.CallAfter(pub.sendMessage, 'stop')
     else:
         dlg.Destroy()
         self._queue.put(True)
コード例 #10
0
    def OnLogScrolledDialog(self, event=None, type='worker', mode='stderr'):
        if type == 'worker':
            filename = self.getLogFileNameWorker(0, mode)
        elif type == 'server':
            filename = self.getLogFileNameServer(mode)
        else:
            raise RuntimeError('invalid type %s' % type)

        with open(filename, "r") as f:
            txt = "\n".join(f.readlines())
        dlg = ScrolledMessageDialog(self,
                                    txt,
                                    "%s %s" % (type, mode),
                                    size=(900, 400),
                                    style=wx.RESIZE_BORDER
                                    | wx.DEFAULT_DIALOG_STYLE)
        dlg.ShowModal()
        dlg.Destroy()
コード例 #11
0
    def OnWorkerFileDialog(self, event=None):
        import tempfile
        tmpdir = tempfile.gettempdir()
        filename = wx.FileSelector(
            'load worker stdout or stderr...',
            wildcard=
            "Stdout files (PYMEworker*.stdout)|*.stdout|Stderr files (PYMEworker*.stderr)|*.stderr",
            flags=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST,
            default_path=tmpdir)
        logging.info('loading %s' % filename)

        with open(filename, "r") as f:
            txt = "\n".join(f.readlines())
        dlg = ScrolledMessageDialog(self,
                                    txt,
                                    os.path.basename(filename),
                                    size=(900, 400),
                                    style=wx.RESIZE_BORDER
                                    | wx.DEFAULT_DIALOG_STYLE)
        dlg.ShowModal()
        dlg.Destroy()
コード例 #12
0
ファイル: CVSExplorer.py プロジェクト: aricsanders/boa
 def showMessage(self, cmd, msg):
     dlg = ScrolledMessageDialog(self.list, msg, cmd)
     try:
         dlg.ShowModal()
     finally:
         dlg.Destroy()
コード例 #13
0
 def exception_hook(self, etype, value, trace):
     dlg = ScrolledMessageDialog(
         self, ''.join(traceback.format_exception(etype, value, trace)),
         "Error")
     dlg.ShowModal()
     dlg.Destroy()