Python tkMessageBox.showerror() Examples

The following are 30 code examples of tkMessageBox.showerror(). 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 tkMessageBox , or try the search function .
Example #1
Source File: configHelpSourceEdit.py    From oss-ftp with MIT License 6 votes vote down vote up
def PathOk(self):
        "Simple validity check for menu file path"
        pathOk = True
        path = self.path.get()
        path.strip()
        if not path: #no path specified
            tkMessageBox.showerror(title='File Path Error',
                                   message='No help file path specified.',
                                   parent=self)
            self.entryPath.focus_set()
            pathOk = False
        elif path.startswith(('www.', 'http')):
            pass
        else:
            if path[:5] == 'file:':
                path = path[5:]
            if not os.path.exists(path):
                tkMessageBox.showerror(title='File Path Error',
                                       message='Help file path does not exist.',
                                       parent=self)
                self.entryPath.focus_set()
                pathOk = False
        return pathOk 
Example #2
Source File: pipark_setup.py    From PiPark with GNU General Public License v2.0 6 votes vote down vote up
def clickLoad(self):
        if self.__is_verbose: print "ACTION: Clicked 'Load'"
        
        # turn off toggle buttons
        self.spaces_button.setOff()
        self.cps_button.setOff()
        
        if not self.loadImage(self.SETUP_IMAGE, self.display, 
                s.PICTURE_RESOLUTION[0]/2, s.PICTURE_RESOLUTION[1]/2):
                
                tkMessageBox.showerror(title = "Error!",
                message = "Error loading setup image."
                + " Please ensure setup image exists as ./image/setup_image.jpeg.")
                
                return
        
        # clear all previous data, and activate buttons
        self.clear_button.invoke()
        self.cps_button.config(state = tk.ACTIVE)
        self.spaces_button.config(state = tk.ACTIVE) 
Example #3
Source File: chart.py    From razzy-spinner with GNU General Public License v3.0 6 votes vote down vote up
def print_selection(self, *e):
        if self._root is None: return
        if self._selection is None:
            tkMessageBox.showerror('Print Error', 'No tree selected')
        else:
            c = self._cframe.canvas()
            for widget in self._treewidgets:
                if widget is not self._selection:
                    self._cframe.destroy_widget(widget)
            c.delete(self._selectbox)
            (x1,y1,x2,y2) = self._selection.bbox()
            self._selection.move(10-x1,10-y1)
            c['scrollregion'] = '0 0 %s %s' % (x2-x1+20, y2-y1+20)
            self._cframe.print_to_file()

            # Restore our state.
            self._treewidgets = [self._selection]
            self.clear()
            self.update() 
Example #4
Source File: viewer.py    From networkx_viewer with GNU General Public License v3.0 6 votes vote down vote up
def goto_path(self, event):
        frm = self.node_entry.get()
        to = self.node_entry2.get()
        self.node_entry.delete(0, tk.END)
        self.node_entry2.delete(0, tk.END)

        if frm == '':
            tkm.showerror("No From Node", "Please enter a node in both "
                "boxes to plot a path.  Enter a node in only the first box "
                "to bring up nodes immediately adjacent.")
            return

        if frm.isdigit() and int(frm) in self.canvas.dataG.nodes():
            frm = int(frm)
        if to.isdigit() and int(to) in self.canvas.dataG.nodes():
            to = int(to)

        self.canvas.plot_path(frm, to, levels=self.level) 
Example #5
Source File: pipark_setup.py    From PiPark with GNU General Public License v2.0 6 votes vote down vote up
def loadData(self):
        try:
            # load the setup data, reload to refresh the data
            import setup_data 
            reload(setup_data)
        except:
            if self.__is_verbose: 
                print "ERROR: Problem loading data from ./setup_data.py"
            tkMessageBox.showerror(
                title = "Error!", 
                message = "Problem loading data from setup_data.py"
                )
        self.__is_saved = True
        return setup_data.boxes
        
    # --------------------------------------------------------------------------
    #   Check Data
    # -------------------------------------------------------------------------- 
Example #6
Source File: chart.py    From razzy-spinner with GNU General Public License v3.0 6 votes vote down vote up
def load_chart(self, *args):
        "Load a chart from a pickle file"
        filename = askopenfilename(filetypes=self.CHART_FILE_TYPES,
                                   defaultextension='.pickle')
        if not filename: return
        try:
            chart = pickle.load(open(filename, 'r'))
            self._chart = chart
            self._cv.update(chart)
            if self._matrix: self._matrix.set_chart(chart)
            if self._matrix: self._matrix.deselect_cell()
            if self._results: self._results.set_chart(chart)
            self._cp.set_chart(chart)
        except Exception, e:
            raise
            tkMessageBox.showerror('Error Loading Chart',
                                   'Unable to open file: %r' % filename) 
Example #7
Source File: chart.py    From razzy-spinner with GNU General Public License v3.0 6 votes vote down vote up
def save_grammar(self, *args):
        filename = asksaveasfilename(filetypes=self.GRAMMAR_FILE_TYPES,
                                     defaultextension='.cfg')
        if not filename: return
        try:
            if filename.endswith('.pickle'):
                pickle.dump((self._chart, self._tokens), open(filename, 'w'))
            else:
                file = open(filename, 'w')
                prods = self._grammar.productions()
                start = [p for p in prods if p.lhs() == self._grammar.start()]
                rest = [p for p in prods if p.lhs() != self._grammar.start()]
                for prod in start: file.write('%s\n' % prod)
                for prod in rest: file.write('%s\n' % prod)
                file.close()
        except Exception, e:
            tkMessageBox.showerror('Error Saving Grammar',
                                   'Unable to open file: %r' % filename) 
Example #8
Source File: fisheye.py    From DualFisheye with MIT License 6 votes vote down vote up
def _auto_align_timer(self, *args):
        # Check thread status.
        if self.work_done:
            # Update status message, with popup on error.
            if self.work_status is not None:
                self._set_status(self.work_status)
            if self.work_error is not None:
                self._set_status('Auto-alignment failed.')
                tkMessageBox.showerror('Auto-alignment error', self.work_error)
            # Clear the 'done' flag for future runs.
            self.work_done = False
        else:
            # Update status message and keep hourglass.
            if self.work_status is not None:
                self._set_status(self.work_status, 'wait')
            # Reset timer to be called again.
            self.parent.after(200, self._auto_align_timer)

    # Create panorama object using current settings. 
Example #9
Source File: userInterface.py    From PcapXray with GNU General Public License v2.0 6 votes vote down vote up
def pcap_analyse(self):
        if os.path.exists(self.pcap_file.get()):
            self.progressbar.start()
            result = Queue.Queue()
            packet_read = threading.Thread(target=pcapReader.pcapReader,args=(self.pcap_file.get(),result))
            packet_read.start()
            while packet_read.is_alive():
                self.progressbar.update()
            packet_read.join()
            self.progressbar.stop()
            #packet_read.join()
            self.capture_read = result.get()
            reportThreadpcap = threading.Thread(target=reportGen.reportGen().packetDetails,args=(self.capture_read,))
            reportThreadpcap.start()
            #self.option.set("Tor")
            self.option.trace("w",self.map_select)
            #self.option.set("Tor")
            self.name_servers = ""
        else:
            tkMessageBox.showerror("Error","File Not Found !") 
Example #10
Source File: EditorWindow.py    From BinderFilter with MIT License 6 votes vote down vote up
def open_module(self, event=None):
        # XXX Shouldn't this be in IOBinding or in FileList?
        try:
            name = self.text.get("sel.first", "sel.last")
        except TclError:
            name = ""
        else:
            name = name.strip()
        name = tkSimpleDialog.askstring("Module",
                 "Enter the name of a Python module\n"
                 "to search on sys.path and open:",
                 parent=self.text, initialvalue=name)
        if name:
            name = name.strip()
        if not name:
            return
        # XXX Ought to insert current file's directory in front of path
        try:
            (f, file, (suffix, mode, type)) = _find_module(name)
        except (NameError, ImportError), msg:
            tkMessageBox.showerror("Import error", str(msg), parent=self.text)
            return 
Example #11
Source File: configSectionNameDialog.py    From BinderFilter with MIT License 6 votes vote down vote up
def NameOk(self):
        #simple validity check for a sensible
        #ConfigParser file section name
        nameOk=1
        name=self.name.get()
        name.strip()
        if not name: #no name specified
            tkMessageBox.showerror(title='Name Error',
                    message='No name specified.', parent=self)
            nameOk=0
        elif len(name)>30: #name too long
            tkMessageBox.showerror(title='Name Error',
                    message='Name too long. It should be no more than '+
                    '30 characters.', parent=self)
            nameOk=0
        elif name in self.usedNames:
            tkMessageBox.showerror(title='Name Error',
                    message='This name is already in use.', parent=self)
            nameOk=0
        return nameOk 
Example #12
Source File: FileList.py    From BinderFilter with MIT License 6 votes vote down vote up
def open(self, filename, action=None):
        assert filename
        filename = self.canonize(filename)
        if os.path.isdir(filename):
            # This can happen when bad filename is passed on command line:
            tkMessageBox.showerror(
                "File Error",
                "%r is a directory." % (filename,),
                master=self.root)
            return None
        key = os.path.normcase(filename)
        if key in self.dict:
            edit = self.dict[key]
            edit.top.wakeup()
            return edit
        if action:
            # Don't create window, perform 'action', e.g. open in same window
            return action(filename)
        else:
            return self.EditorWindow(self, filename, key) 
Example #13
Source File: configHelpSourceEdit.py    From BinderFilter with MIT License 6 votes vote down vote up
def MenuOk(self):
        "Simple validity check for a sensible menu item name"
        menuOk = True
        menu = self.menu.get()
        menu.strip()
        if not menu:
            tkMessageBox.showerror(title='Menu Item Error',
                                   message='No menu item specified',
                                   parent=self)
            self.entryMenu.focus_set()
            menuOk = False
        elif len(menu) > 30:
            tkMessageBox.showerror(title='Menu Item Error',
                                   message='Menu item too long:'
                                           '\nLimit 30 characters.',
                                   parent=self)
            self.entryMenu.focus_set()
            menuOk = False
        return menuOk 
Example #14
Source File: configHelpSourceEdit.py    From BinderFilter with MIT License 6 votes vote down vote up
def PathOk(self):
        "Simple validity check for menu file path"
        pathOk = True
        path = self.path.get()
        path.strip()
        if not path: #no path specified
            tkMessageBox.showerror(title='File Path Error',
                                   message='No help file path specified.',
                                   parent=self)
            self.entryPath.focus_set()
            pathOk = False
        elif path.startswith(('www.', 'http')):
            pass
        else:
            if path[:5] == 'file:':
                path = path[5:]
            if not os.path.exists(path):
                tkMessageBox.showerror(title='File Path Error',
                                       message='Help file path does not exist.',
                                       parent=self)
                self.entryPath.focus_set()
                pathOk = False
        return pathOk 
Example #15
Source File: WmDefault.py    From oss-ftp with MIT License 6 votes vote down vote up
def setup(root, wm=''):
    """1) find the files and/or settings (::wm_default::setup).
    Takes one optional argument: wm, the name of the window manager
    as a string, if known. One of: windows gnome kde1 kde2 cde kde.
    """
    try:
        try:
            # Make sure Tcl/Tk knows wm_default is installed
            root.tk.eval("package require wm_default")
        except:
            # Try again with this directory on the Tcl/Tk path
            dir = os.path.dirname (self.__file__)
            root.tk.eval('global auto_path; lappend auto_path {%s}' % dir)
            root.tk.eval("package require wm_default")
    except:
        t, v, tb = sys.exc_info()
        text = "Error loading WmDefault\n"
        for line in traceback.format_exception(t,v,tb): text = text + line + '\n'
        try:
            tkMessageBox.showerror ('WmDefault Error', text)
        except:
            sys.stderr.write( text )

    return root.tk.call('::wm_default::setup', wm) 
Example #16
Source File: configSectionNameDialog.py    From oss-ftp with MIT License 6 votes vote down vote up
def name_ok(self):
        ''' After stripping entered name, check that it is a  sensible
        ConfigParser file section name. Return it if it is, '' if not.
        '''
        name = self.name.get().strip()
        if not name: #no name specified
            tkMessageBox.showerror(title='Name Error',
                    message='No name specified.', parent=self)
        elif len(name)>30: #name too long
            tkMessageBox.showerror(title='Name Error',
                    message='Name too long. It should be no more than '+
                    '30 characters.', parent=self)
            name = ''
        elif name in self.used_names:
            tkMessageBox.showerror(title='Name Error',
                    message='This name is already in use.', parent=self)
            name = ''
        return name 
Example #17
Source File: FileList.py    From oss-ftp with MIT License 6 votes vote down vote up
def open(self, filename, action=None):
        assert filename
        filename = self.canonize(filename)
        if os.path.isdir(filename):
            # This can happen when bad filename is passed on command line:
            tkMessageBox.showerror(
                "File Error",
                "%r is a directory." % (filename,),
                master=self.root)
            return None
        key = os.path.normcase(filename)
        if key in self.dict:
            edit = self.dict[key]
            edit.top.wakeup()
            return edit
        if action:
            # Don't create window, perform 'action', e.g. open in same window
            return action(filename)
        else:
            return self.EditorWindow(self, filename, key) 
Example #18
Source File: configHelpSourceEdit.py    From oss-ftp with MIT License 6 votes vote down vote up
def MenuOk(self):
        "Simple validity check for a sensible menu item name"
        menuOk = True
        menu = self.menu.get()
        menu.strip()
        if not menu:
            tkMessageBox.showerror(title='Menu Item Error',
                                   message='No menu item specified',
                                   parent=self)
            self.entryMenu.focus_set()
            menuOk = False
        elif len(menu) > 30:
            tkMessageBox.showerror(title='Menu Item Error',
                                   message='Menu item too long:'
                                           '\nLimit 30 characters.',
                                   parent=self)
            self.entryMenu.focus_set()
            menuOk = False
        return menuOk 
Example #19
Source File: PyShell.py    From BinderFilter with MIT License 5 votes vote down vote up
def open_stack_viewer(self, event=None):
        if self.interp.rpcclt:
            return self.interp.remote_stack_viewer()
        try:
            sys.last_traceback
        except:
            tkMessageBox.showerror("No stack trace",
                "There is no stack trace yet.\n"
                "(sys.last_traceback is not defined)",
                master=self.text)
            return
        from idlelib.StackViewer import StackBrowser
        sv = StackBrowser(self.root, self.flist) 
Example #20
Source File: PyShell.py    From BinderFilter with MIT License 5 votes vote down vote up
def display_port_binding_error(self):
        tkMessageBox.showerror(
            "Port Binding Error",
            "IDLE can't bind to a TCP/IP port, which is necessary to "
            "communicate with its Python execution server.  This might be "
            "because no networking is installed on this computer.  "
            "Run IDLE with the -n command line switch to start without a "
            "subprocess and refer to Help/IDLE Help 'Running without a "
            "subprocess' for further details.",
            master=self.tkconsole.text) 
Example #21
Source File: chart.py    From razzy-spinner with GNU General Public License v3.0 5 votes vote down vote up
def load_chart_dialog(self, *args):
        filename = askopenfilename(filetypes=self.CHART_FILE_TYPES,
                                   defaultextension='.pickle')
        if not filename: return
        try: self.load_chart(filename)
        except Exception, e:
            tkMessageBox.showerror('Error Loading Chart',
                                   'Unable to open file: %r\n%s' %
                                   (filename, e)) 
Example #22
Source File: OutputWindow.py    From oss-ftp with MIT License 5 votes vote down vote up
def goto_file_line(self, event=None):
        if self.file_line_progs is None:
            l = []
            for pat in self.file_line_pats:
                l.append(re.compile(pat, re.IGNORECASE))
            self.file_line_progs = l
        # x, y = self.event.x, self.event.y
        # self.text.mark_set("insert", "@%d,%d" % (x, y))
        line = self.text.get("insert linestart", "insert lineend")
        result = self._file_line_helper(line)
        if not result:
            # Try the previous line.  This is handy e.g. in tracebacks,
            # where you tend to right-click on the displayed source line
            line = self.text.get("insert -1line linestart",
                                 "insert -1line lineend")
            result = self._file_line_helper(line)
            if not result:
                tkMessageBox.showerror(
                    "No special line",
                    "The line you point at doesn't look like "
                    "a valid file name followed by a line number.",
                    master=self.text)
                return
        filename, lineno = result
        edit = self.flist.open(filename)
        edit.gotoline(lineno) 
Example #23
Source File: IOBinding.py    From BinderFilter with MIT License 5 votes vote down vote up
def decode(self, chars):
        """Create a Unicode string

        If that fails, let Tcl try its best
        """
        # Check presence of a UTF-8 signature first
        if chars.startswith(BOM_UTF8):
            try:
                chars = chars[3:].decode("utf-8")
            except UnicodeError:
                # has UTF-8 signature, but fails to decode...
                return chars
            else:
                # Indicates that this file originally had a BOM
                self.fileencoding = BOM_UTF8
                return chars
        # Next look for coding specification
        try:
            enc = coding_spec(chars)
        except LookupError, name:
            tkMessageBox.showerror(
                title="Error loading the file",
                message="The encoding '%s' is not known to this Python "\
                "installation. The file may not display correctly" % name,
                master = self.text)
            enc = None 
Example #24
Source File: PyShell.py    From BinderFilter with MIT License 5 votes vote down vote up
def display_no_subprocess_error(self):
        tkMessageBox.showerror(
            "Subprocess Startup Error",
            "IDLE's subprocess didn't make connection.  Either IDLE can't "
            "start a subprocess or personal firewall software is blocking "
            "the connection.",
            master=self.tkconsole.text) 
Example #25
Source File: PyncheWidget.py    From oss-ftp with MIT License 5 votes vote down vote up
def __load(self, event=None):
        while 1:
            idir, ifile = os.path.split(self.__sb.colordb().filename())
            file = tkFileDialog.askopenfilename(
                filetypes=[('Text files', '*.txt'),
                           ('All files', '*'),
                           ],
                initialdir=idir,
                initialfile=ifile)
            if not file:
                # cancel button
                return
            try:
                colordb = ColorDB.get_colordb(file)
            except IOError:
                tkMessageBox.showerror('Read error', '''\
Could not open file for reading:
%s''' % file)
                continue
            if colordb is None:
                tkMessageBox.showerror('Unrecognized color file type', '''\
Unrecognized color file type in file:
%s''' % file)
                continue
            break
        self.__sb.set_colordb(colordb) 
Example #26
Source File: ScriptBinding.py    From oss-ftp with MIT License 5 votes vote down vote up
def errorbox(self, title, message):
        # XXX This should really be a function of EditorWindow...
        tkMessageBox.showerror(title, message, master=self.editwin.text)
        self.editwin.text.focus_set() 
Example #27
Source File: EditorWindow.py    From oss-ftp with MIT License 5 votes vote down vote up
def python_docs(self, event=None):
        if sys.platform[:3] == 'win':
            try:
                os.startfile(self.help_url)
            except WindowsError as why:
                tkMessageBox.showerror(title='Document Start Failure',
                    message=str(why), parent=self.text)
        else:
            webbrowser.open(self.help_url)
        return "break" 
Example #28
Source File: EditorWindow.py    From oss-ftp with MIT License 5 votes vote down vote up
def open_module(self, event=None):
        # XXX Shouldn't this be in IOBinding or in FileList?
        try:
            name = self.text.get("sel.first", "sel.last")
        except TclError:
            name = ""
        else:
            name = name.strip()
        name = tkSimpleDialog.askstring("Module",
                 "Enter the name of a Python module\n"
                 "to search on sys.path and open:",
                 parent=self.text, initialvalue=name)
        if name:
            name = name.strip()
        if not name:
            return
        # XXX Ought to insert current file's directory in front of path
        try:
            (f, file_path, (suffix, mode, mtype)) = _find_module(name)
        except (NameError, ImportError) as msg:
            tkMessageBox.showerror("Import error", str(msg), parent=self.text)
            return
        if mtype != imp.PY_SOURCE:
            tkMessageBox.showerror("Unsupported type",
                "%s is not a source module" % name, parent=self.text)
            return
        if f:
            f.close()
        if self.flist:
            self.flist.open(file_path)
        else:
            self.io.loadfile(file_path)
        return file_path 
Example #29
Source File: EditorWindow.py    From oss-ftp with MIT License 5 votes vote down vote up
def update_recent_files_list(self, new_file=None):
        "Load and update the recent files list and menus"
        rf_list = []
        if os.path.exists(self.recent_files_path):
            with  open(self.recent_files_path, 'r') as rf_list_file:
                rf_list = rf_list_file.readlines()
        if new_file:
            new_file = os.path.abspath(new_file) + '\n'
            if new_file in rf_list:
                rf_list.remove(new_file)  # move to top
            rf_list.insert(0, new_file)
        # clean and save the recent files list
        bad_paths = []
        for path in rf_list:
            if '\0' in path or not os.path.exists(path[0:-1]):
                bad_paths.append(path)
        rf_list = [path for path in rf_list if path not in bad_paths]
        ulchars = "1234567890ABCDEFGHIJK"
        rf_list = rf_list[0:len(ulchars)]
        try:
            with open(self.recent_files_path, 'w') as rf_file:
                rf_file.writelines(rf_list)
        except IOError as err:
            if not getattr(self.root, "recentfilelist_error_displayed", False):
                self.root.recentfilelist_error_displayed = True
                tkMessageBox.showerror(title='IDLE Error',
                    message='Unable to update Recent Files list:\n%s'
                        % str(err),
                    parent=self.text)
        # for each edit window instance, construct the recent files menu
        for instance in self.top.instance_dict.keys():
            menu = instance.recent_files_menu
            menu.delete(0, END)  # clear, and rebuild:
            for i, file_name in enumerate(rf_list):
                file_name = file_name.rstrip()  # zap \n
                # make unicode string to display non-ASCII chars correctly
                ufile_name = self._filename_to_unicode(file_name)
                callback = instance.__recent_file_callback(file_name)
                menu.add_command(label=ulchars[i] + " " + ufile_name,
                                 command=callback,
                                 underline=0) 
Example #30
Source File: backend_tkagg.py    From Computable with MIT License 5 votes vote down vote up
def error_msg_tkpaint(msg, parent=None):
    import tkMessageBox
    tkMessageBox.showerror("matplotlib", msg)