Exemple #1
0
def load_image():
    global image, script_path, log_path, image_count, extension, max_image_count, view_value
    script_path = os.path.dirname(os.path.realpath(__file__))
    log_path = script_path + "\log_folder"

    file_name = filedialog.askopenfilename(
    )  #opens up the file_system for user to select a file. returns file path
    #print(file_name) #prints the entire file path
    #print(os.path.basename(file_name)) #prints only the actual file name with extension

    if (not (file_name
             == "")):  #in case user clicked on cancel or cross button
        if os.path.exists(
                log_path
        ):  #if the log_folder already exists then delete it and create a new one
            shutil.rmtree(log_path, ignore_errors=True)  #remove the log_folder
            os.makedirs(log_path)
            #image_count=0
        else:
            os.makedirs(log_path)
            #image_count=0
        image_count = 0  #as the image was just loaded
        max_image_count = 0  #as no processing has yet happened on original image
        view_value = "000"  #initializing the values
        var.set(
            image_count
        )  #used to call the callback functions so as to set the proper visibility for the menu options
        var2.set(view_value)

        fig.clf()  #clear the current canvas
        fig.add_subplot(111)  #makes a 1x1 image plot
        #some validations in case a 'gif' file or some other non-image file was selected
        try:
            name, extension = os.path.basename(file_name).split(".")
            if (extension == "gif"):
                raise exception
            image = scipy.ndimage.imread(
                file_name, mode='L')  #read the image into an numpy.ndarray
            im = plt.imshow(
                image, vmin=0, vmax=255
            )  #vmin and vmax are required to specify the gray scales.
            plt.set_cmap('gray')  #setting the colormap
            canvas.draw()  #displaying the image on the canvas

            #increment the image_count and store the current image in the log_folder.
            #will be required for undo and redo operations.
            image_count = image_count + 1
            var.set(image_count)

            #save current image in log_folder as 1.extension eg:1.jpg or 1.png
            current_file = log_path + "\\" + str(image_count) + "." + str(
                extension)
            cv2.imwrite(
                current_file, image
            )  #cv2.imwrite() is better compared to Image.fromarray() as it doesn't manipulate the image.
            #selected cv2 for the file write after I found some images getting manipulated by the rescaling required for Image.fromarray().
        except Exception as e:
            messagebox.showerror(
                title="Can't identify file!!!!",
                message="This file format is currently not supported")
Exemple #2
0
def updatestudent():
    sno = w.Entry1.get()
    sname = w.Entry2.get()
    dept = w.Entry3.get()
    major = w.Entry4.get()
    class1 = w.Entry5.get()
    g1 = w.Entry6.get()
    conn = pymysql.connect(host='localhost',
                           user='******',
                           passwd='809144',
                           db='mydb',
                           port=3306)
    cur = conn.cursor()
    values = [sname, dept, major, class1, g1, sno]
    cur.execute('select * from student where sno = %s', sno)
    r = cur.fetchone()
    if r != None:
        cur.execute(
            'update student set sname = %s,sex = %s,sage = %s,dept = %s,class = %s where sno = %s',
            values)
        v.showinfo('successful', sname + '同学信息更新成功')
        conn.commit()
        cur.close()
        conn.close()
        destroy_window()
    else:
        v.showerror('error', sname + '同学信息不存在,请确认')
    sys.stdout.flush()
def daoru():
    f = a.askopenfilename(filetypes=[("XLSX", ".xlsx")])
    book = xlrd.open_workbook(f)
    w.Entry_url.insert(0, f)
    sheet = book.sheet_by_name("Sheet1")
    conn = pymysql.connect(host='localhost',
                           user='******',
                           passwd='809144',
                           db='mydb',
                           port=3306)
    cur = conn.cursor()
    query = 'insert into student(cno,cname,credit) values(%s,%s,%s)'

    for r in range(1, sheet.nrows):
        cno = sheet.cell(r, 0).value
        cname = sheet.cell(r, 1).value
        credit = sheet.cell(r, 2).value
        cur.execute('select sno from class where sno = %s', sno)
        r = cur.fetchone()
        if r == None:
            values = (cno, cname, credit)
            cur.execute(query, values)
        else:
            v.showerror('error', cno + '已经存在,请检查文件重新导入')
        conn.commit()
    cur.close()
    conn.close()
    columns = str(sheet.ncols)
    rows = str(sheet.nrows)
    print("导入 " + columns + " 列 " + rows + " 行数据到MySQL数据库!")
    sys.stdout.flush()
def snofind():
    global f
    f = 2
    delButton()
    sno = w.fsno.get()
    conn = pymysql.connect(host='localhost',
                           user='******',
                           passwd='809144',
                           db='mydb',
                           port=3306)
    cur = conn.cursor()
    cur.execute('select student.*,class.cname,grade.grade FROM student,class'\
                ',grade where student.sno = grade.sno and class.cno = grade.cno and student.sno = %s', sno)
    r = cur.fetchall()
    i = 0
    if r != ():
        for r1 in r:
            w.Scrolledtreeview1.insert('',
                                       i,
                                       values=(r1[0], r1[1], r1[2], r1[3],
                                               r1[4], r1[5], r1[6], r1[7]))
            i += 1
    else:
        v.showerror('error', sno + '不存在,请检查后重新输入')
    sys.stdout.flush()
Exemple #5
0
def signup():
    user = Username.get()
    passw = Password.get()
    if user.strip() == '' or passw.strip == '':
        messagebox.showerror("Error", "Please fill username and password")
    else:
        data = insert(Username.get(), Password.get())
Exemple #6
0
    def submitReportCheck(self):
        rand = random.randint(1111,9999)

        #find latitude & longitude using current IP address
        d = datetime.datetime.now().strftime("%m/%d/%y %I:%M%p")
        send_url = 'http://freegeoip.net/json'
        r = requests.get(send_url)
        j = json.loads(r.text)
        lat = j['latitude']
        lon = j['longitude']

        submitPayload = {"key":rand, "date":d, "location_type": self.locationVar.get(),
                        "zip":self.zipcode.get(), "address": self.streetName.get(),
                        "city":self.city.get(), "borough":self.boroughVar.get(),
                        "latitude": lat, "logitude":lon}
        submitRequest = requests.post('http://ec2-54-174-96-216.compute-1.amazonaws.com:9000/addRecord',
                                     data=submitPayload)

        requestStatus = submitRequest.status_code
        print(requestStatus)
        if requestStatus == 200:
            self.submitReportView.destroy()
            self.mainPageView.deiconify()
        else:
            messagebox.showerror(
                "Submit Error",
                "No entries may be left blank. Please try again."
            )
Exemple #7
0
def histogram_equalize():
    global image, extension, image_count, log_path, max_image_count, max_image_count
    if (image.max() != 0):
        image = fun.histeq_im(
            image)  #call the function with the current image in canvas

        ###
        #Some general steps being followed in a image processing functions:
        #(1)clear the canvas
        #(2)draw the image on the canvas
        #(3)increment the image count as this is a new image and store this new image based on image_count to log_folder
        #(4)increment max_image_count which will be used for redo and undo functionalities
        #(5)remove_files() will remove all the images with count greater than the current image_count in the log_folder.
        #this is required in case I have 5 images say, 1,2,3,4,5 I undo and go to 2. Then I do a processing task.
        #then the new processed image will be stored as 3, and 4,5 will be removed from log_folder.
        ###
        fig.clf()
        fig.add_subplot(111)
        im = plt.imshow(image, vmin=0, vmax=255)
        plt.set_cmap('gray')
        canvas.draw()

        max_image_count = image_count + 1
        image_count = image_count + 1
        var.set(image_count)

        #store the image in log_folder

        current_file = log_path + "\\" + str(image_count) + "." + str(
            extension)
        cv2.imwrite(current_file, image)
        remove_files()
    else:
        messagebox.showerror("Error", "Please load an image first.")
Exemple #8
0
def histogram_plot():
    global image, extension, image_count, log_path, max_image_count, view_value, plot_number
    if (image.max() != 0):
        if (
                plot_number == 121
        ):  #because this function will be called two times in display_original()
            fig.clf()
        fig.add_subplot(plot_number)  #dynamically changing the grid plot
        im = plt.imshow(image, vmin=0, vmax=255)
        plt.set_cmap('gray')

        image_histogram = np.zeros(256)  #contains histogram of image
        #create the image histogram
        for i in range(image.shape[0]):
            for j in range(image.shape[1]):
                intensity_value = int(
                    abs(image[i][j])
                )  #abs() is taken in case of negative image intensities
                image_histogram[
                    intensity_value] = image_histogram[intensity_value] + 1
        fig.add_subplot(plot_number + 1)
        plt.stem(np.arange(256), image_histogram,
                 markerfmt=' ')  #plots a stem image of histogram

        canvas.draw()
        view_value = "100"  #set the callback so that the display image option is enabled
        var2.set(view_value)
    else:
        messagebox.showerror("Error", "Please load an image first.")
Exemple #9
0
def update():
    username = w.Entryusername.get()
    password = w.Entrypwd.get()
    password1 = w.Entrypwd1.get()
    qx1 = w.Entryqx.get()
    try:
        conn = pymysql.connect(host='localhost',
                               user='******',
                               passwd='809144',
                               db='mydb',
                               port=3306)
        cur = conn.cursor()
        cur.execute('select password from user where username = %s', username)
        r = cur.fetchone()
        if r != None:
            if r[0] != password:
                v.showerror('error', '旧密码输入错误')
            else:
                values = [password1, qx1, username]
                cur.execute(
                    'update user set password = %s,qx = %s where username = %s',
                    values)
                conn.commit()
                v.showinfo('successful', username + '信息已更新')
                cur.close()
        else:
            v.showerror('error', '不存在此用户')
            conn.close()
    except pymysql.Error as e:
        print('mysql error %d : %s' % (e.args[0], e.args[1]))
    sys.stdout.flush()
def View_Project(proj_data):
    #Check a project has been selected
    if(proj_data == ''):
        messagebox.showerror("Error", "No project selected.")
        return

    proj_ID = str(proj_data[0])

    global projID
    projID = proj_ID

    #Open project window
    global project_window
    project_window = Toplevel()
    project_window.geometry("755x425")
    project_window.title("View Project")
    project_window.state("zoomed")

    #conenct to conn
    conn = sqlite3.connect('info.db')
    #create cursor
    c = conn.cursor()

    c.execute("SELECT * FROM Tickets")
    records = c.fetchall()

    global info
    c.execute("SELECT * FROM Projects WHERE project_ID=?", projID)
    info = c.fetchone()
    projectName = info[1]
    projectDescription = info[2]

    #make labels
    projName = Label(project_window, text=str(projectName))
    projName.config(font=("", 24, "bold"))
    projName.grid(row=0, column=0, columnspan=2)
    projDescription = Label(project_window, text=str(projectDescription))
    projDescription.grid(row=1, column=0, columnspan=2)
    ticketTitle = Label(project_window, text="Project Tickets")
    ticketTitle.config(font="TkDefaultFont 9 underline")
    ticketTitle.grid(row=2, column=0, pady=5, padx=10, sticky=W)
	
    Display_Tickets()

    manage_tick_btn = Button(project_window, text="Manage Ticket", command=lambda: tickMan(ticket_table.item(ticket_table.focus())['values']))
    manage_tick_btn.grid(row=5, column=0, columnspan=2, pady=5)

    #Place "Create New Ticket" button
    create_ticket_btn = Button(project_window, text="Create New Ticket", command=tickNew)
    create_ticket_btn.grid(row=6, column=0, columnspan=2)

    #Place "Back" button
    back_btn = Button(project_window, text="Back", command=Close_Window)
    back_btn.grid(row=7, column=1, sticky=E, padx=10, pady=5)

    #Close connection
    conn.close()

    return
Exemple #11
0
    def __put_issue(self, iss):
        if self.__storage.getIssueById(self.__selected, iss.id) is not None:
            messagebox.showerror("Error", "Issue #%d already exists." % iss.id)
            return

        self.__storage.addIssue(self.__selected, iss)
        issues = self.__storage.getIssues(self.__selected)
        self.__issues.insert(END, ('#%d - %s') % (iss.id, iss.description))
def daoru():
    f = a.askopenfilename(filetypes=[("XLSX", ".xlsx")])
    book = xlrd.open_workbook(f)
    w.Entry_url.insert(0, f)
    sheet = book.sheet_by_name("Sheet1")
    conn = pymysql.connect(host='localhost',
                           user='******',
                           passwd='809144',
                           db='mydb',
                           port=3306)
    cur = conn.cursor()
    query2 = 'insert into class(cno,cname,credit) values(%s,%s,%s)'
    query1 = 'insert into student(sno,sname,sex,sage,dept,class) values(%s,%s,%s,%s,%s,%s)'
    query3 = 'insert into grade(sno,cno,grade) values(%s,%s,%s)'
    for r in range(1, sheet.nrows):
        sno = sheet.cell(r, 0).value
        sname = sheet.cell(r, 1).value
        sex = sheet.cell(r, 2).value
        sage = sheet.cell(r, 3).value
        dept = sheet.cell(r, 4).value
        class1 = sheet.cell(r, 5).value
        cno = sheet.cell(r, 6).value
        cname = sheet.cell(r, 7).value
        credit = sheet.cell(r, 8).value
        grade = sheet.cell(r, 9).value
        cur.execute('select cno from class where cno = %s', cno)
        r2 = cur.fetchone()
        cur.execute('select sno from student where sno = %s', sno)
        r1 = cur.fetchone()
        if r1 == None and r2 == None:
            values2 = (cno, cname, credit)
            cur.execute(query2, values2)
            values1 = (sno, sname, sex, sage, dept, class1)
            cur.execute(query1, values1)
            values3 = (sno, cno, grade)
            cur.execute(query3, values3)
        elif r1 == None and r2 != None:
            values1 = (sno, sname, sex, sage, dept, class1)
            cur.execute(query1, values1)
            values3 = (sno, cno, grade)
            cur.execute(query3, values3)
            v.showerror('提示', cname + '课程已经存在,无需再添加')
        elif r1 != None and r2 == None:
            values2 = (cno, cname, credit)
            cur.execute(query2, values2)
            values3 = (sno, cno, grade)
            cur.execute(query3, values3)
            v.showerror('提示', sno + '学生信息已经存在,无需再添加')
        else:
            values3 = (sno, cno, grade)
            cur.execute(query3, values3)
    conn.commit()
    cur.close()
    conn.close()
    columns = str(sheet.ncols)
    rows = str(sheet.nrows)
    print("导入 " + columns + " 列 " + rows + " 行数据到MySQL数据库!")
    sys.stdout.flush()
Exemple #13
0
def Manage_Project(proj_data):
    #Check a project has been selected
    if (proj_data == ''):
        messagebox.showerror("Error", "No project selected.")
        return

    proj_ID = str(proj_data[0])

    #Connect to database info file
    conn = sqlite3.connect("info.db")
    #Create database cursor
    c = conn.cursor()

    c.execute("SELECT * FROM Projects WHERE project_ID=?", proj_ID)
    data = c.fetchone()

    #Close connection
    conn.close()

    #Open new window
    proj_manage_window = Toplevel()
    proj_manage_window.geometry("300x300")
    proj_manage_window.title("Manage Project")

    #Place entry box and label for "name" attribute
    name_label = Label(proj_manage_window, text="Project Name*")
    name_label.grid(row=1, column=0, sticky=W, padx=5, pady=5)
    name_box = Entry(proj_manage_window, width=30)
    name_box.insert(END, data[1])
    name_box.grid(row=2, column=0, columnspan=2, padx=5)

    #Place entry box and label for "description" attribute
    description_label = Label(proj_manage_window, text="Description")
    description_label.grid(row=3, column=0, sticky=W, padx=5, pady=5)
    description_box = Entry(proj_manage_window, width=30)
    description_box.insert(END, data[2])
    description_box.grid(row=4, column=0, columnspan=2, padx=5)

    #Place buttons for saving changes, cancelling process, and deleting project
    save_btn = Button(
        proj_manage_window,
        text="Save Changes",
        command=lambda: Save_Changes(proj_ID, name_box, description_box,
                                     proj_manage_window))
    save_btn.grid(row=5, column=0, pady=5)
    cancel_btn = Button(proj_manage_window,
                        text="Cancel",
                        command=lambda: Cancel_Edit(proj_manage_window))
    cancel_btn.grid(row=5, column=1, pady=5)
    delete_btn = Button(
        proj_manage_window,
        text="Delete Project",
        command=lambda: Delete_Project(proj_ID, proj_manage_window))
    delete_btn.grid(row=6, column=0, columnspan=2, pady=5)

    return
Exemple #14
0
def display_2():
    try:
        num = n_ent.get()
        num = int(num)
    except ValueError:
        showerror('Non-Int Error', 'Please enter an integer')
    else:
        for c in range(1, num + 1):
            #window = tk.Toplevel(root)
            create_window()
Exemple #15
0
def submit_label():
    lab = var3.get()
    per = var2.get()
    try:
        num = n_ent.get()
        num = int(num)
    except ValueError:
        showerror('Non-Int Error', 'Please enter an integer')
    else:
        ar.append(lab)
        ar2.append(per)
Exemple #16
0
def button_process(root):
    #create message box
    messagebox.askokcancel('Python Tkinter',
                           'Are you sure to create a window?')
    messagebox.askquestion('Python Tkinter',
                           "Are you sure to create a window?")
    messagebox.askyesno('Python Tkinter', 'Are you sure to create a window?')
    messagebox.showerror('Python Tkinter', 'Unknown Error')
    messagebox.showinfo('Python Tkinter', 'hello world')
    messagebox.showwarning('Python Tkinter', 'Leave now')
    root1 = Toplevel(root)
Exemple #17
0
def signin():
    data = search(Username.get(), Password.get())
    if data == ():
        Username.set('')
        Password.set('')
        messagebox.showerror("Error",
                             "Invalid Username or Password\nTry Again!!")
    else:
        destroy_window()
        import os
        os.system('python admin_dashboard.py')
Exemple #18
0
 def add_log_data_to_listbox(self):
     log_list = [] 
     try:
         with open('log.txt', 'r') as f:
             for file in f.readlines():
                 log_list.append(file)
     except Exception:
         destroy_this_window()
         messagebox.showerror('404 File Not Found : (', 'You Might Deleted \"log.txt\", which contains\nlist of files which gets encrypted!')
     
     for file in log_list:
         self.Scrolledlistbox1.insert(tk.END, file)    
Exemple #19
0
    def zeigeLösung(self):
        """ Methode zum Aufzeigen einer Lösung mithilfe der Methode zeigeLösung des Spiel-Objekts, 
            die die Spielsituation erstellt hat.
        """
        # falls schon ein Spiel erstellt wurde
        if self.spiel:
            self.spiel.zeigeLösung()

        # Fehlermeldung falls der Button zu früh betätigt wurde
        else:
            messagebox.showerror("Fehler!",
                                 "Spielsituation wurde noch nicht erzeugt!")
Exemple #20
0
def save_image():
    if (image.max() !=
            0):  #i.e an image is actually present on the canvas for saving
        exportFile = filedialog.asksaveasfile(mode='w',
                                              defaultextension=".png",
                                              filetypes=(("PNG file", "*.png"),
                                                         ("All Files", "*.*")))
        #print(exportFile.name) #prints the entire file path
        if exportFile:
            cv2.imwrite(exportFile.name, image)
    else:
        messagebox.showerror(title="Can't save!!!!",
                             message="Please load an image first")
Exemple #21
0
    def _ok(self, _=None):
        f = None
        try:
            f = int(self.__iss.get())
        except ValueError:
            messagebox.showerror("Invalid Issue",
                                 "Please input a valid issue number.")
            return

        if callable(self.__cbk):
            self.__cbk(Issue(f, self.__desc.get()))

        self.destroy()
Exemple #22
0
    def attemptRandomize(self):
        global optionalRulesetsList
        global optRulesetValues

        optionalRulesetsList = [("", 0)] * len(optRulesetValues)
        for i in range(len(optRulesetValues)):
            optionalRulesetsList[i] = (Optional_Rulesets[i].name,
                                       int(optRulesetValues[i].get()))
        results = randomize()
        print("\n")
        if results[0]:
            showinfo("Success!", results[1])
        else:
            showerror("Error", results[1])
Exemple #23
0
    def __put_namespace(self, ns):
        if self.__storage.namespaceExists(ns):
            messagebox.showerror("Error", "That namespace already exists!")
            return

        self.__storage.addNamespace(ns)
        nslist = self.__storage.namespaces
        names = []
        for ns in nslist:
            names.append(ns.getAsURL())

        if self.__selected_ns.get() == '':
            self.select(ns)

        self.__spaces.configure(values=names)
Exemple #24
0
 def loginCheck(self):
     #requesting API
     loginPayload = {"username": self.userEntry.get(), "password":self.passwdEntry.get()}
     loginRequest = requests.post('http://ec2-54-174-96-216.compute-1.amazonaws.com:9000/checkUser',
                                  data=loginPayload)
     
     requestStatus = loginRequest.status_code
     if requestStatus == 200:
         self.root.withdraw()
         self.mainPage()
     else:
         messagebox.showerror(
             "Login Error",
             "Username or password incorrect."
         )
Exemple #25
0
    def registerCheck(self):
        #requesting API
        registerPayload = {"name": self.nameEntry2.get(), "username": self.userEntry2.get(),
                   "password":self.passwdEntry2.get(), "isAdmin": registerVar.get()}
        registerRequest = requests.post('http://ec2-54-174-96-216.compute-1.amazonaws.com:9000/addUser',
                                        data=registerPayload)

        requestStatus = json.loads(registerRequest.text)["status"]
        if requestStatus == 1:
            self.mainPageView.withdraw()
            self.root.deiconify()
        else:
            messagebox.showerror(
                "Registration Error",
                "No entries may be left blank. Please try again."
            )
def check_user(users=""):
    try:
        stdout = run_query(
            "SELECT username FROM dba_users WHERE username IN (%s);" % (users))
        invalid_users = []
        for res in users.split(","):
            if res.strip("'") not in stdout[0]:
                invalid_users.append(res.strip("'"))

        if invalid_users:
            messagebox.showerror(
                "Error", "Invalid Users = %s" % (",".join(invalid_users)))
            raise ValueError('stuff is not in content')
        return True
    except Exception as e:
        print "---error check user--", e
        return False
def cnofind():
    global f
    f = 2
    delButton()
    cno = w.cno.get()
    conn = pymysql.connect(host='localhost', user='******', passwd='809144', db='mydb', port=3306)
    cur = conn.cursor()
    cur.execute('select * from class where cno = %s', cno)
    r = cur.fetchall()
    i = 0
    if r != ():
        for r1 in r:
            w.Scrolledtreeview1.insert('', i, values=(r1[0], r1[1], r1[2]))
            i += 1
    else:
        v.showerror('error', cno + '不存在,请检查后重新输入')
    sys.stdout.flush()
Exemple #28
0
    def get_list_to_compare(self):
        '''Busca todos os arquivos de tomadas na pasta atual
		'''
        folder_to_show = list()

        try:
            my_folders = [x[0] for x in os.walk(".\\")]
            for i in my_folders:
                for j in i.split('\\'):
                    if 'tomada' in j:
                        folder_to_show.append(j)
        except:
            messagebox.showerror("Error",
                                 "Erro ao buscar arquivos para comparar")

        folder_to_show.sort(key=self.natural_keys)

        return folder_to_show
Exemple #29
0
def butterworth_sharpen():
    global image, extension, image_count, log_path, max_image_count, lab_5_data, lab_6_data, lab_7_data, error_flag_1, error_flag_2, error_flag_3, butter_width, butter_order, butter_a, popup_true
    if (image.max() != 0):
        #ask the user if he wishes to use the default parameter values
        answer = messagebox.askyesno(
            "Settings", "Do you want to use default settings?\n" +
            "width=3, order=2, a=0.5")
        if (answer == True):
            image = fun.butterworth_highpass_filter(image, 3, 2, 0.5)
            #general steps
            fig.clf()
            fig.add_subplot(111)
            im = plt.imshow(image, vmin=0, vmax=255)
            plt.set_cmap('gray')
            canvas.draw()

            max_image_count = image_count + 1
            image_count = image_count + 1
            var.set(image_count)

            #store the image in log_folder

            current_file = log_path + "\\" + str(image_count) + "." + str(
                extension)
            cv2.imwrite(current_file, image)
            remove_files()
        else:
            ###initialize the variables before calling popup
            lab_5_data.set("")
            lab_6_data.set("")
            lab_7_data.set("")

            error_flag_1 = 0
            error_flag_2 = 0
            error_flag_3 = 0

            butter_width = ""
            butter_order = ""
            butter_a = ""
            popup_true = 0
            ###
            popupmsg()
    else:
        messagebox.showerror("Error", "Please load an image first.")
Exemple #30
0
    def _searchCity(self):
        self.info.delete(u'1.0', tk.END)

        _cityName = self.cityName.get()
        if len(_cityName) == 0:
            messagebox.showwarning(u'Please input a city name',
                                   u'Please input a city name for search.')
            return

        cities = self.api.queryCityInfo(_cityName)
        # print(cities)
        if len(cities) == 0:
            messagebox.showerror(u'没有查询到城市', u'没有查询到城市,请检查输入!')
            return
        elif len(cities) == 1:
            self._showWeather(cities[0])

        else:
            self._askForSelect(cities)
 def showErrorBox(self):
     messagebox.showerror("Error", "You can't do that")