Python tkMessageBox 模块,showerror() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用tkMessageBox.showerror()

项目:merac-o-matic    作者:RogueAI42    | 项目源码 | 文件源码
def generate():
    global sound
    statement = coremeraco.constructRegularStatement() + os.linesep
    textArea.insert(Tkinter.END, statement)
    textArea.yview(Tkinter.END)
    if readOption and readOutputState.get():
        if sound:
            sound.stop()
        sound = playsnd.playsnd()
        threading.Thread(target=sound.play, args=(procfest.text2wave(statement),)).start()
    if saveOutputState.get():
        try:
            outputFileHandler = open(saveOutputDestination.get(), 'a') # 'a' means append mode
            outputFileHandler.write(statement)
            outputFileHandler.close()
        except IOError as Argument:
            tkMessageBox.showerror(productName, meracolocale.getLocalisedString(localisationFile, "ioErrorMessage") + str(Argument))
        except Exception as Argument:
            tkMessageBox.showerror(productName, meracolocale.getLocalisedString(localisationFile, "genericErrorMessage") + str(Argument))
项目:darkc0de-old-stuff    作者:tuwid    | 项目源码 | 文件源码
def validate(self):

        for key in self.entrydict.keys():
            if key.find("Password") == -1:
                self.settings[self.section][key] = self.entrydict[key].get()
            else:
                self.settings[self.section][key] = myutils.password_obfuscate(self.entrydict[key].get())

        errortext="Some of your input contains errors. Detailed error output below.\n\n"

        val = Validator()
        valresult=self.settings.validate(val, preserve_errors=True)
        if valresult != True:
            if valresult.has_key(self.section):
                sectionval = valresult[self.section]
                for key in sectionval.keys():
                    if sectionval[key] != True:
                        errortext += "Error in item \"" + str(key) + "\": " + str(sectionval[key]) + "\n"
                tkMessageBox.showerror("Erroneous input. Please try again.", errortext)
            return 0
        else:
            return 1
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def view_file(parent, title, filename, encoding=None, modal=True):
    try:
        if encoding:
            import codecs
            textFile = codecs.open(filename, 'r')
        else:
            textFile = open(filename, 'r')
    except IOError:
        tkMessageBox.showerror(title='File Load Error',
                               message='Unable to load file %r .' % filename,
                               parent=parent)
    except UnicodeDecodeError as err:
        showerror(title='Unicode Decode Error',
                  message=str(err),
                  parent=parent)
    else:
        return view_text(parent, title, textFile.read(), modal)
项目:aurora-sdk-win    作者:nanoleaf    | 项目源码 | 文件源码
def play_plugin(self):
        if self.plugin_dir_path.get() == "":
            tkMessageBox.showerror("Error", "No plugin to play")
            return
        if self.ip_addr.get() == "":
            tkMessageBox.showerror("Error", "No IP Address")
            return

        while (not self.test_auth()):
            self.authenticate_with_aurora()
        time.sleep(0.5)

        iprint("Playing plugin")
        self.sound_module.run_music_processor()
        time.sleep(1)
        iprint("Playing music processor")
        self.sound_module.run_thread(self.ip_addr.get(), self.plugin_dir_path.get(), self.palette_path.get(), self.palette_entered)
项目:aurora-sdk-win    作者:nanoleaf    | 项目源码 | 文件源码
def write_palette_for_sdk(self):
        iprint("writing out palette to file")
        self.palette_path.set(self.plugin_dir_path.get() + self.directory_divider + "palette")
        if self.plugin_dir_path.get() == "":
            tkMessageBox.showerror("Error", "Please enter the path to the plugin")
            return;
        try:
            open_file = open(self.plugin_dir_path.get() + self.directory_divider + "palette", "w+")
        except IOError, errinfo:
            tkMessageBox.showerror("Error", "Could not write to directory." + str(errinfo))
            return
        palette_dict = self.palette
        try:
            palette_dict["palette"]
        except TypeError:
            palette_dict = {}
            palette_dict["palette"] = self.palette
        self.palette_entered = (len(self.palette) > 0)

        open_file.write(json.dumps(palette_dict))
        open_file.close()
项目:pkgdecrypt-frontend    作者:SilicaAndPina    | 项目源码 | 文件源码
def extract():

    try:
        print filename
    except NameError:
        tkMessageBox.showerror(title='File Selection', message='No PKG File Selected.')
    try:
        print outputFolder
    except NameError:
        global outputFolder
        outputFolder = os.path.dirname(filename)
        print outputFolder

    if sys.platform.__contains__("linux"):
        os.system("./pkg_dec '"+filename+"' '"+outputFolder+"/output'")
        os.remove("out.bin")
        tkMessageBox.showinfo(title='File Selection', message='Extraction Complete!')
    if sys.platform.__contains__("win"):
        os.system("pkg_dec.exe '"+filename+"' '"+outputFolder+"/output'")
        os.remove("out.bin")
        tkMessageBox.showinfo(title='File Selection', message='Extraction Complete!')
    sys.stdout.flush()

    openFolder(outputFolder + "/output")
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _UpdateFirmwareCmd(self):
        q = tkMessageBox.showwarning('Update Fimware','Warning! Interrupting firmare update may lead to non functional PiJuice HAT.', parent=self.frame)
        if q:
            print 'Updating fimware'
            inputFile = '/usr/share/pijuice/data/firmware/PiJuice.elf.binary'
            curAdr = pijuice.config.interface.GetAddress()
            if curAdr:
                adr = format(curAdr, 'x')
                ret = 256 - subprocess.call(['pijuiceboot', adr, inputFile])#subprocess.call([os.getcwd() + '/stmboot', adr, inputFile])
                print 'firm res', ret 
                if ret == 256:
                    tkMessageBox.showinfo('Firmware update', 'Finished succesfully!', parent=self.frame)
                else:
                    errorStatus = self.firmUpdateErrors[ret] if ret < 11 else ' UNKNOWN'
                    msg = ''
                    if errorStatus == 'I2C_BUS_ACCESS_ERROR':
                        msg = 'Check if I2C bus is enabled.'
                    elif errorStatus == 'INPUT_FILE_OPEN_ERROR':
                        msg = 'Firmware binary file might be missing or damaged.'
                    elif errorStatus == 'STARTING_BOOTLOADER_ERROR':
                        msg = 'Try to start bootloader manualy. Press and hold button SW3 while powering up RPI and PiJuice.'
                    tkMessageBox.showerror('Firmware update failed', 'Reason: ' + errorStatus + '. ' + msg, parent=self.frame)
            else:
                tkMessageBox.showerror('Firmware update', 'Unknown pijuice I2C address', parent=self.frame)
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _ApplyNewConfig(self, v):
        for i in range(0, len(pijuice.config.leds)):
            ledConfig = {'function':self.ledConfigsSel[i].get(), 'parameter':{'r':self.paramList[i*3].get(), 'g':self.paramList[i*3+1].get(), 'b':self.paramList[i*3+2].get()}}
            if ( self.configs[i] == None
                or ledConfig['function'] != self.configs[i]['function']
                or ledConfig['parameter']['r'] != self.configs[i]['parameter']['r']
                or ledConfig['parameter']['g'] != self.configs[i]['parameter']['g']
                or ledConfig['parameter']['b'] != self.configs[i]['parameter']['b']
                ):
                status = pijuice.config.SetLedConfiguration(pijuice.config.leds[i], ledConfig)
                #event.widget.set('')
                if status['error'] == 'NO_ERROR':
                    self.applyBtn.configure(state="disabled")
                    #time.sleep(0.2)
                    #config = pijuice.config.GetLedConfiguration(pijuice.config.leds[i])
                    #if config['error'] == 'NO_ERROR':
                    #   event.widget.current(pijuice.config.ledFunctions.index(config['data']['function']))
                    #else:
                    #   event.widget.set(config['error'])
                else:
                    tkMessageBox.showerror('Apply LED Configuration', status['error'], parent=self.frame)
                    #event.widget.set(status['error'])
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _UpdateFirmwareCmd(self):
        q = tkMessageBox.showwarning('Update Fimware','Warning! Interrupting firmare update may lead to non functional PiJuice HAT.', parent=self.frame)
        if q:
            print 'Updating fimware'
            inputFile = '/usr/share/pijuice/data/firmware/PiJuice.elf.binary'
            curAdr = pijuice.config.interface.GetAddress()
            if curAdr:
                adr = format(curAdr, 'x')
                ret = 256 - subprocess.call(['pijuiceboot', adr, inputFile])#subprocess.call([os.getcwd() + '/stmboot', adr, inputFile])
                print 'firm res', ret 
                if ret == 256:
                    tkMessageBox.showinfo('Firmware update', 'Finished succesfully!', parent=self.frame)
                else:
                    errorStatus = self.firmUpdateErrors[ret] if ret < 11 else ' UNKNOWN'
                    msg = ''
                    if errorStatus == 'I2C_BUS_ACCESS_ERROR':
                        msg = 'Check if I2C bus is enabled.'
                    elif errorStatus == 'INPUT_FILE_OPEN_ERROR':
                        msg = 'Firmware binary file might be missing or damaged.'
                    elif errorStatus == 'STARTING_BOOTLOADER_ERROR':
                        msg = 'Try to start bootloader manualy. Press and hold button SW3 while powering up RPI and PiJuice.'
                    tkMessageBox.showerror('Firmware update failed', 'Reason: ' + errorStatus + '. ' + msg, parent=self.frame)
            else:
                tkMessageBox.showerror('Firmware update', 'Unknown pijuice I2C address', parent=self.frame)
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _UpdateFirmwareCmd(self):
        q = tkMessageBox.showwarning('Update Fimware','Warning! Interrupting firmare update may lead to non functional PiJuice HAT.', parent=self.frame)
        if q:
            print 'Updating fimware'
            inputFile = '/usr/share/pijuice/data/firmware/PiJuice.elf.binary'
            curAdr = pijuice.config.interface.GetAddress()
            if curAdr:
                adr = format(curAdr, 'x')
                ret = 256 - subprocess.call(['pijuiceboot', adr, inputFile])#subprocess.call([os.getcwd() + '/stmboot', adr, inputFile])
                print 'firm res', ret 
                if ret == 256:
                    tkMessageBox.showinfo('Firmware update', 'Finished succesfully!', parent=self.frame)
                else:
                    errorStatus = self.firmUpdateErrors[ret] if ret < 11 else ' UNKNOWN'
                    msg = ''
                    if errorStatus == 'I2C_BUS_ACCESS_ERROR':
                        msg = 'Check if I2C bus is enabled.'
                    elif errorStatus == 'INPUT_FILE_OPEN_ERROR':
                        msg = 'Firmware binary file might be missing or damaged.'
                    elif errorStatus == 'STARTING_BOOTLOADER_ERROR':
                        msg = 'Try to start bootloader manualy. Press and hold button SW3 while powering up RPI and PiJuice.'
                    tkMessageBox.showerror('Firmware update failed', 'Reason: ' + errorStatus + '. ' + msg, parent=self.frame)
            else:
                tkMessageBox.showerror('Firmware update', 'Unknown pijuice I2C address', parent=self.frame)
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _ApplyNewConfig(self, v):
        for i in range(0, len(pijuice.config.leds)):
            ledConfig = {'function':self.ledConfigsSel[i].get(), 'parameter':{'r':self.paramList[i*3].get(), 'g':self.paramList[i*3+1].get(), 'b':self.paramList[i*3+2].get()}}
            if ( self.configs[i] == None
                or ledConfig['function'] != self.configs[i]['function']
                or ledConfig['parameter']['r'] != self.configs[i]['parameter']['r']
                or ledConfig['parameter']['g'] != self.configs[i]['parameter']['g']
                or ledConfig['parameter']['b'] != self.configs[i]['parameter']['b']
                ):
                status = pijuice.config.SetLedConfiguration(pijuice.config.leds[i], ledConfig)
                #event.widget.set('')
                if status['error'] == 'NO_ERROR':
                    self.applyBtn.configure(state="disabled")
                    #time.sleep(0.2)
                    #config = pijuice.config.GetLedConfiguration(pijuice.config.leds[i])
                    #if config['error'] == 'NO_ERROR':
                    #   event.widget.current(pijuice.config.ledFunctions.index(config['data']['function']))
                    #else:
                    #   event.widget.set(config['error'])
                else:
                    tkMessageBox.showerror('Apply LED Configuration', status['error'], parent=self.frame)
                    #event.widget.set(status['error'])
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _UpdateFirmwareCmd(self):
        q = tkMessageBox.showwarning('Update Fimware','Warning! Interrupting firmare update may lead to non functional PiJuice HAT.', parent=self.frame)
        if q:
            print 'Updating fimware'
            inputFile = '/usr/share/pijuice/data/firmware/PiJuice.elf.binary'
            curAdr = pijuice.config.interface.GetAddress()
            if curAdr:
                adr = format(curAdr, 'x')
                ret = 256 - subprocess.call(['pijuiceboot', adr, inputFile])#subprocess.call([os.getcwd() + '/stmboot', adr, inputFile])
                print 'firm res', ret 
                if ret == 256:
                    tkMessageBox.showinfo('Firmware update', 'Finished succesfully!', parent=self.frame)
                else:
                    errorStatus = self.firmUpdateErrors[ret] if ret < 11 else ' UNKNOWN'
                    msg = ''
                    if errorStatus == 'I2C_BUS_ACCESS_ERROR':
                        msg = 'Check if I2C bus is enabled.'
                    elif errorStatus == 'INPUT_FILE_OPEN_ERROR':
                        msg = 'Firmware binary file might be missing or damaged.'
                    elif errorStatus == 'STARTING_BOOTLOADER_ERROR':
                        msg = 'Try to start bootloader manualy. Press and hold button SW3 while powering up RPI and PiJuice.'
                    tkMessageBox.showerror('Firmware update failed', 'Reason: ' + errorStatus + '. ' + msg, parent=self.frame)
            else:
                tkMessageBox.showerror('Firmware update', 'Unknown pijuice I2C address', parent=self.frame)
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _ApplyNewConfig(self, v):
        for i in range(0, len(pijuice.config.leds)):
            ledConfig = {'function':self.ledConfigsSel[i].get(), 'parameter':{'r':self.paramList[i*3].get(), 'g':self.paramList[i*3+1].get(), 'b':self.paramList[i*3+2].get()}}
            if ( self.configs[i] == None
                or ledConfig['function'] != self.configs[i]['function']
                or ledConfig['parameter']['r'] != self.configs[i]['parameter']['r']
                or ledConfig['parameter']['g'] != self.configs[i]['parameter']['g']
                or ledConfig['parameter']['b'] != self.configs[i]['parameter']['b']
                ):
                status = pijuice.config.SetLedConfiguration(pijuice.config.leds[i], ledConfig)
                #event.widget.set('')
                if status['error'] == 'NO_ERROR':
                    self.applyBtn.configure(state="disabled")
                    #time.sleep(0.2)
                    #config = pijuice.config.GetLedConfiguration(pijuice.config.leds[i])
                    #if config['error'] == 'NO_ERROR':
                    #   event.widget.current(pijuice.config.ledFunctions.index(config['data']['function']))
                    #else:
                    #   event.widget.set(config['error'])
                else:
                    tkMessageBox.showerror('Apply LED Configuration', status['error'], parent=self.frame)
                    #event.widget.set(status['error'])
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _UpdateFirmwareCmd(self):
        q = tkMessageBox.showwarning('Update Fimware','Warning! Interrupting firmare update may lead to non functional PiJuice HAT.', parent=self.frame)
        if q:
            print 'Updating fimware'
            inputFile = '/usr/share/pijuice/data/firmware/PiJuice.elf.binary'
            curAdr = pijuice.config.interface.GetAddress()
            if curAdr:
                adr = format(curAdr, 'x')
                ret = 256 - subprocess.call(['pijuiceboot', adr, inputFile])#subprocess.call([os.getcwd() + '/stmboot', adr, inputFile])
                print 'firm res', ret 
                if ret == 256:
                    tkMessageBox.showinfo('Firmware update', 'Finished succesfully!', parent=self.frame)
                else:
                    errorStatus = self.firmUpdateErrors[ret] if ret < 11 else ' UNKNOWN'
                    msg = ''
                    if errorStatus == 'I2C_BUS_ACCESS_ERROR':
                        msg = 'Check if I2C bus is enabled.'
                    elif errorStatus == 'INPUT_FILE_OPEN_ERROR':
                        msg = 'Firmware binary file might be missing or damaged.'
                    elif errorStatus == 'STARTING_BOOTLOADER_ERROR':
                        msg = 'Try to start bootloader manualy. Press and hold button SW3 while powering up RPI and PiJuice.'
                    tkMessageBox.showerror('Firmware update failed', 'Reason: ' + errorStatus + '. ' + msg, parent=self.frame)
            else:
                tkMessageBox.showerror('Firmware update', 'Unknown pijuice I2C address', parent=self.frame)
项目:pymod    作者:pymodproject    | 项目源码 | 文件源码
def show_popup_message(self, popup_type="warning", title_to_show="ALLERT", message_to_show="THIS IS AN ALLERT MESSAGE", parent_window=None, refresh=True):
        """
        Displays error or warning messages and refreshes the sequence window.
        """
        # show_error_message
        # show_warning_message
        if parent_window == None:
            parent_window = self.main_window

        if popup_type == "error":
            tkMessageBox.showerror(title_to_show, message_to_show, parent=parent_window)
        elif popup_type == "info":
            tkMessageBox.showinfo(title_to_show, message_to_show, parent=parent_window)
        elif popup_type == "warning":
            tkMessageBox.showwarning(title_to_show, message_to_show, parent=parent_window)

        if refresh:
            self.gridder()
项目:pymod    作者:pymodproject    | 项目源码 | 文件源码
def startup_pymod(app):
    """
    Checks if NumPy and Biopython (PyMod core Python dependencies) are present before launching
    PyMod.
    """
    if not numpy_found:
        title = "Import Error"
        message = "NumPy is not installed on your system. Please install it in order to use PyMod."
        tkMessageBox.showerror(title, message)
        return False
    if not biopython_found:
        title = "Import Error"
        message = "Biopython is not installed on your system. Please install it in order to use PyMod."
        tkMessageBox.showerror(title, message)
        return False
    import pymod_main
    pymod_main.pymod_launcher(app, pymod_plugin_name, __version__, __revision__)
项目:firesave    作者:kactusken    | 项目源码 | 文件源码
def OpenSave():
    global f

    # Attempt to Extract the
    try:
        z = ZipFile(ent_SaveFile.get())
        DebugPrint(" + Successfully opened save file archive")
        x = z.extract('savedata', os.getcwd(), 'w#qjH_xaZ~Fm')
        DebugPrint(" + Successfully extracted save contents")
        f = open(x, 'r+b')
        DebugPrint(" + Successfully opened save file data")
        return 1

    except:
        f = None
        DebugPrint(" + Unable to open save file data")
        tkMessageBox.showerror("FireGUI Error", "Unable to open savedata.dat file")
        return 0

# Function to close the save file
项目:firesave    作者:kactusken    | 项目源码 | 文件源码
def ValidateConfig():
    global val_Stable
    err_message = ""

    if ent_SaveFile.get() == "":
        err_message = "\nSaveData.dat location is empty"

    if ent_OutputFile.get() == "":
        err_message = err_message + "\nOutput file location is empty"

    if val_Stable.get() == 1:
        if lst_Stables.index(ACTIVE) == 0:
            err_message = err_message + "\nStable not selected"

    if err_message != "":
        tkMessageBox.showerror("FireGUI Error", "Unable to process: \n%s" % err_message)
        return 0
    else:
        return 1

# Function to update all the missions to rank S
项目:History-Generator    作者:ReedOei    | 项目源码 | 文件源码
def run_to(self):
        try:
            advance_amount = int(self.years_box.get())

            if advance_amount > 0:
                self.advancing = True
                self.end_year = self.year + advance_amount

                self.after_id = self.parent.after(self.delay.get(), self.main_loop)
            else:
                self.end_year = self.year
                tkMessageBox.showerror('Negative Years', 'Cannot advance a negative or zero amount of time.')
        except ValueError:
            self.end_year = self.year
            tkMessageBox.showerror('Invalid Year', '"{}" is not a valid integer'.format(self.years_box.get()))
            return
项目:JoeyJoebags    作者:rebbTRSi    | 项目源码 | 文件源码
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)
项目:data-analysis    作者:ymohanty    | 项目源码 | 文件源码
def handlePlotData(self):

        print "Getting headers!"
        if self.data is not None:
            d = ChooseAxesDialog(self.root, self.data.get_headers())

        else:
            tkMessageBox.showerror("No Open File", "Please open a file first!")
            print "First Open a Data File!!"
            return
        if d.result is not None:
            self.x_label_name.set(d.result[0][0])
            self.y_label_name.set(d.result[0][1])
            self.z_label_name.set(d.result[0][2])
            self.reset()
            spatial_headers = [h for h in d.result[0] if h != "None"]
            other_headers = d.result[1:]
            self.buildPoints(spatial_headers, other_headers, self.data)
项目:data-analysis    作者:ymohanty    | 项目源码 | 文件源码
def handleLinearRegression(self):
        if self.data is None:
            tkMessageBox.showerror("No Open File", "Please open a file first!")
            return
        d = LinearRegressionDialog(self.root, self.data.get_headers())
        if d.result is not None:
            if d.result[0] == "None" or d.result[1] == "None":
                tkMessageBox.showwarning(title="Incorrect Parameters", message="Option cannot be 'None'")
            else:
                self.objects = []
                self.linreg_endpoints = None
                self.linreg_line_objects = []
                self.reset()
                self.updateAxes()
                self.regression_mode = True
                self.buildLinearRegression(headers=d.result)

    # build and display the regression on the plot
项目:data-analysis    作者:ymohanty    | 项目源码 | 文件源码
def saveRegressionImage(self, event=None):
        if not self.regression_mode:
            tkMessageBox.showerror("Can't Save Image", "This feature only works for regression analysis currently.")
            return
        else:
            x = analysis.normalize_columns_separately(self.data, [self.x_label_name.get()]).T.tolist()[0]
            y = analysis.normalize_columns_separately(self.data, [self.y_label_name.get()]).T.tolist()[0]

            plt.plot(x, y, 'o')
            plt.plot([min(x), max(x)], [self.linreg_endpoints[0, 1], self.linreg_endpoints[1, 1]])
            plt.ylabel(self.y_label_name.get())
            plt.xlabel(self.x_label_name.get())

            plt.show()

    ### BEGIN PCA STUFF ###
项目:data-analysis    作者:ymohanty    | 项目源码 | 文件源码
def handlePCA(self, event=None):
        if self.data is None:
            tkMessageBox.showerror("No File Open", "Please open a file first!")
            return
        d = PCADialog(self.root, self.data.get_headers())
        if d.result is None:
            return
        if d.result[2] in self.pca_data.keys():
            tkMessageBox.showwarning("Replacing Saved Analysis",
                                     "Please delete old analysis before creating another with the same name.")
            return
        if d.result[0] == 1:
            self.pca_data[d.result[2]] = analysis.pca(self.data, d.result[1])
            self.pca_data[d.result[2]].write_to_file(d.result[2], self.pca_data[d.result[2]].get_headers())
            print "Normalizing: True"
        else:
            self.pca_data[d.result[2]] = analysis.pca(self.data, d.result[1], False)
            self.pca_data[d.result[2]].write_to_file(d.result[2], self.pca_data[d.result[2]].get_headers())
            print "Normalizing: False"
        if not self.pca_controls_built:
            self.buildPCAControls()

        self.pca_lbox.insert(tk.END, d.result[2])
项目:data-analysis    作者:ymohanty    | 项目源码 | 文件源码
def __init__(self, filename=None):
        self.raw_data = []
        self.raw_headers = []
        self.raw_types = []
        self.header2raw = {}
        self.matrix_data = np.matrix([])
        self.header2matrix = {}
        self.enum_dicts = {}

        if filename is not None:
            try:

                if filename.split('.')[1] == "csv":
                    self.read_csv(filename)
                elif filename.split('.')[1] == "xls":
                    self.read_xls(filename)

                else:
                    return
            except IndexError:
               # tkMessageBox.showerror(title="Unknown Error", message="An unknown error occured. Please try again.")
               print "something fucked up"

    # opens and reads a csv file
项目:bemoss_gui2.1    作者:bemoss    | 项目源码 | 文件源码
def pwconfirm(self):
        self.passwd = self.pswd.get()
        if self.passwd is not None:
            output = volttronFunc.agent_status(self.passwd)
            try:
                if output == '':
                    # pop up a window: remind the user to check his password.
                    tkMessageBox.showerror(title="Notification", message='Sorry, the password is incorrect, please try again.', parent=self.passwd_window)
                    self.passwd = None
                    self.passwd_window.state('withdrawn')
                else:
                    self.passwd_window.state('withdrawn')
                    self.VOL_text.configure(state='normal')
                    self.VOL_text.delete('1.0', Tkinter.END)
                    self.VOL_text.insert('1.0', output)
                    self.VOL_text.configure(state='disabled')
                    self.passwd_window.withdraw()
            except Exception as er:
                print er
                print('Error @ pwconfirm.')
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
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
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
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
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
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
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
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)
项目:cms-dl    作者:nikhil-97    | 项目源码 | 文件源码
def login_to_cms(self):
        if (not cms.init()):
            tkMessageBox.showerror("Connection Error", "Unable to connect to CMS now. Please try again later.")
            self.statusbar.config(bg="firebrick2",text="  Cannot connect to CMS  ")
            return False
            # global data_file

        self.user_details = self.load_details(Gui.data_file)
        # print user_details
        if (self.user_details != None):
            self.website = cms.submit_form(self.user_details)
            if (self.website == False):
                tkMessageBox.showerror("User details Error",
                                       "Looks like there is an error in your user details. Please check them again")
                return False
        return True
项目:maze-pathfinder    作者:ivan-ristovic    | 项目源码 | 文件源码
def btn_solve_on_click(self):

        if self.grp is None or self.img is None:
            tkMessageBox.showerror("Error", "Please load a maze first!")
            return

        self.perform_process(lambda: self.traverse_graph(), "Traversing graph...")
        self.perform_process(lambda: self.write_to_file(), "Writing to file...")

        tkMessageBox.showinfo("Info",
            "Solved the maze in " + str(self.steps) + " steps!\n" +
            "Path length:\t\t%d\n" % self.graph_traverser.path_length +
            "Graph loading time:\t\t%.5lfs\n" % self.exec_time +
            "Graph traverse time:\t\t%.5lfs\n" % (self.traverse_time_end - self.traverse_time_start) +
            "File writing time:\t\t%.5lfs\n" % (self.imgwrite_time_end - self.imgwrite_time_start) +
            "Total execution time:\t\t%.5lfs" % (self.exec_time + (self.imgwrite_time_end - self.traverse_time_start))
        )

        if self.show_solution.get() == True:
            # Showing solution in new window
            if sys.platform.startswith('linux'):
                subprocess.call(["xdg-open", self.output_path])
            else:
                os.startfile(self.output_path)
项目:PIEFACE    作者:jcumby    | 项目源码 | 文件源码
def check_update(self):
        """ Check if a newer version of PIEFACE has been released """

        try:
            u = urllib2.urlopen('https://api.github.com/repos/jcumby/PIEFACE/releases/latest').read()
            ujson = json.loads(u)

        except:
            # Problem reading url (perhaps no internet)?
            tkMessageBox.showerror("Update Error", "Failed to check for updates")
            return False

        newversion = ujson['tag_name'][1:].split('.')
        #currversion = pkg_resources.get_distribution('pieface').version.split('.')
        currversion = pieface.__version__.split('.')
        assert len(newversion) == len(currversion)


        for i, num in enumerate(currversion):
            if int(newversion[i]) > int(num):
                return True
        return False
项目:PIEFACE    作者:jcumby    | 项目源码 | 文件源码
def raise_message(log):
    if "Label(s) %s are not present" in log.msg:
        box = tk.Toplevel(root)
        box.title('Error')
        message = ttk.Label(box, text = log.msg % log.args)
        labels = {}
        for f in app.filenames:
            labels[os.path.basename(f)] = " ".join(sorted(multiCIF._alllabels(f)))
        advice = ttk.Label(box, text = "Valid labels are:\n{0}".format( "".join( ["{0:40s}: {1:30s}\n".format(p, labels[p]) for p in labels] )))
        tip = ttk.Label(box, text="[ Tip: Regular expressions can also be used to centre labels ]")
        button = ttk.Button(box, text='OK', command= lambda: box.destroy())
        message.grid(row = 0, padx = 5, pady = 5)
        advice.grid(row = 1, padx = 5, pady = 5)
        tip.grid(row=2, padx=5, pady=5)
        button.grid(row = 3, padx = 5, pady = 5)
        root.wait_window(window=box)
    else:
        pass

    #tkMessageBox.showerror('Error',log.msg)
项目:Farmbot_GeneralAP    作者:SpongeYao    | 项目源码 | 文件源码
def set_Motor(self):
        if self.ArdMntr.connect:
            Var= MotorSetting(self.root, self.MaxSpeed, self.Acceleration)
            if Var.result is not None:
                print 'result: ',Var.result
                #self.MaxSpeed= [Var.result[0], Var.result[2]]
                #self.Acceleration= [Var.result[1], Var.result[3]]
                self.MaxSpeed= [Var.result[0], Var.result[2], Var.result[4]]
                self.Acceleration= [Var.result[1], Var.result[3], Var.result[5]]
                self.ArdMntr.set_MaxSpeed(self.MaxSpeed[0],'x')
                self.ArdMntr.set_MaxSpeed(self.MaxSpeed[1],'y')
                self.ArdMntr.set_MaxSpeed(self.MaxSpeed[2],'z')
                self.ArdMntr.set_Acceleration(self.Acceleration[0],'x')
                self.ArdMntr.set_Acceleration(self.Acceleration[1],'y')
                self.ArdMntr.set_Acceleration(self.Acceleration[2],'z')
            #self.ArdMntr.set_MaxSpeed()
        else:
            tkMessageBox.showerror("Error", "Arduino connection refused!\n Please check its connection.")
项目:Farmbot_GeneralAP    作者:SpongeYao    | 项目源码 | 文件源码
def btn_loadscript_click(self):
        #self.scriptPath= self.entry_scriptPath.get()
        tmpPath= self.entry_scriptPath.get()
        if utils_tool.check_file(tmpPath):
            #self.txtbox_script.delete('1.0', END)
            self.txtbox_script.clear()
            self.txtbox_script.importfile(tmpPath)
            self.txtbox_script.configure(label_text= "- "+ tmpPath.split("/")[-1]+" -")
        else:
            tkMessageBox.showerror("Error", "'%s' dost not exist !" % tmpPath)
        '''
        cmd_file = open(self.scriptPath, "r")
        lines = cmd_file.readlines()
        for line in lines:
            cmd = line.strip()
            if len(cmd)>0:
                self.txtbox_script.insert(END, cmd+'\n')
        cmd_file.close()
        '''
项目:Farmbot_GeneralAP    作者:SpongeYao    | 项目源码 | 文件源码
def connect_camera(self, arg_camera_id):
        if (self.connect):
            self.cap.release()
            print 'RELEASE...'
        self.camera_id= arg_camera_id
        print '>>> Cam ID ',self.camera_id
        self.cap= cv2.VideoCapture(self.camera_id)
        print 'cap.isOpened:', self.cap.isOpened()
        if not (self.cap.isOpened()):
            for tmp_id in self.__camera_idMatrix:
                try:
                    self.cap= cv2.VideoCapture(tmp_id)
                    print 'Cam ID ',tmp_id,': connected successfully!'
                    self.connect= True
                    self.camera_id= tmp_id
                    break
                except:
                    print 'Cam ID ',tmp_id,': connection Refused!'
                    self.connect= False
            if not(self.connect):
                tkMessageBox.showerror("Error","Connection of Camera refused!")
        else:
            self.connect= True
项目:Farmbot_GeneralAP    作者:SpongeYao    | 项目源码 | 文件源码
def connect_serial(self):
        if not(self.connect):
            try:
                for tmp_channel in self.channel:
                    try:
                        self.ser = Serial(tmp_channel, 115200, timeout=1) #FIXME, cha    nge device id to your system device
                        print tmp_channel,': connected successfully!'
                        self.connect= True
                        break
                    except:
                        print tmp_channel,': connection Refused!'
            except:
                print 'Connection of Arduino refused!'
                tkMessageBox.showerror("Error","Connection of Arduino refused!")
        else: 
            tkMessageBox.showerror("Error","Connection of Arduino is already built!")
项目:image-copy-move-detection    作者:rahmatnazali    | 项目源码 | 文件源码
def onDetect(self):
        if self.imageName == "":
            mbox.showerror("Error", 'Citra masukan belum terisi\nSilakan pilih dengan menekan tombol "Open File"')
        else:

            self.textBoxLog.config(state='normal')
            self.textBoxLog.insert(END, "Mendeteksi: "+self.imageName+"\n")
            self.textBoxLog.see(END)
            self.textBoxLog.config(state='disabled')

            imageResultPath = CopyMoveDetection.detect(self.imagePath, self.imageName, '../testcase_result/', blockSize=32)
            newImageRight = Image.open(imageResultPath)
            imageRightLabel = ImageTk.PhotoImage(newImageRight)
            self.labelRight = Label(self, image=imageRightLabel)
            self.labelRight.image = imageRightLabel
            self.labelRight.place(x=525, y=100)

            self.textBoxLog.config(state='normal')
            self.textBoxLog.insert(END, "Selesai.")
            self.textBoxLog.see(END)
            self.textBoxLog.config(state='disabled')
            pass
        pass
项目:SceneDensity    作者:ImOmid    | 项目源码 | 文件源码
def errorBox(self, title, message):
        self.topLevel.update_idletasks()
        MessageBox.showerror(title, message)
        self.__bringToFront()
项目:AWS-SSL-Manager    作者:adaranutsa    | 项目源码 | 文件源码
def error(self, title, message):
        messagebox.showerror(title, message)

    # Display an info box pop up
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def main(key):
    'Delete key and all empty parent keys.'
    Tkinter.Tk().withdraw()
    try:
        key, parent = delete(*key.rsplit('\\', 1))
        while empty(parent):
            key, parent = delete(*key.rsplit('\\', 1))
        tkMessageBox.showinfo('Info', 'Uninstall passed!')
    except:
        tkMessageBox.showerror('Error', traceback.format_exc())