python类showerror()的实例源码

display.py 文件源码 项目:data-analysis 作者: ymohanty 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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 ###
display.py 文件源码 项目:data-analysis 作者: ymohanty 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:data-analysis 作者: ymohanty 项目源码 文件源码 阅读 41 收藏 0 点赞 0 评论 0
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
GUI.py 文件源码 项目:bemoss_gui2.1 作者: bemoss 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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.')
configSectionNameDialog.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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
configHelpSourceEdit.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
configHelpSourceEdit.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
FileList.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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)
gui.py 文件源码 项目:cms-dl 作者: nikhil-97 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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
gui.py 文件源码 项目:maze-pathfinder 作者: ivan-ristovic 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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_gui.py 文件源码 项目:PIEFACE 作者: jcumby 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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_gui.py 文件源码 项目:PIEFACE 作者: jcumby 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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)
gui_main.py 文件源码 项目:Farmbot_GeneralAP 作者: SpongeYao 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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.")
gui_main.py 文件源码 项目:Farmbot_GeneralAP 作者: SpongeYao 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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()
        '''
class_CameraMntr.py 文件源码 项目:Farmbot_GeneralAP 作者: SpongeYao 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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
class_ArduinoSerMntr.py 文件源码 项目:Farmbot_GeneralAP 作者: SpongeYao 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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!")
main_GUI.py 文件源码 项目:image-copy-move-detection 作者: rahmatnazali 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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
appjar.py 文件源码 项目:SceneDensity 作者: ImOmid 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def errorBox(self, title, message):
        self.topLevel.update_idletasks()
        MessageBox.showerror(title, message)
        self.__bringToFront()
message.py 文件源码 项目:AWS-SSL-Manager 作者: adaranutsa 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def error(self, title, message):
        messagebox.showerror(title, message)

    # Display an info box pop up
recipe-510395.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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())


问题


面经


文章

微信
公众号

扫码关注公众号