tkinter 连接数据库的可视化界面---二

直接代码

# -*- coding: utf-8 -*-
"""
Created on Wed Nov  6 08:56:57 2019

@author: 01
"""

# -*- coding:utf-8 -*-

import MySQLdb
from hashlib import sha1
import tkinter
import tkinter.filedialog
import os
from PIL import ImageGrab
from time import sleep
from tkinter import *
import cv2
from PIL import Image,ImageTk
from tkinter.filedialog import askopenfilename
import json
import codecs
from tkinter.filedialog import askdirectory
import tkinter.messagebox
import sys,time

root1 = tkinter.Tk()
root1.title('登录')
root1.geometry('400x400+100+50')
      #name = input("请输入用户名:")
      # pwd = input("请输入密码:")
aa = StringVar()
aa.set('用户名')
aaa = tkinter.Label(root1, textvariable=aa)
aaa.place(x=200, y=150)
      
      
name = tkinter.Entry(root1,width=12,name="ss")
name.place(x =100 , y=100,width = 250, height=40,anchor = NW)
      
       
bb = StringVar()
bb.set('登录密码')
bbb = tkinter.Label(root1, textvariable=bb)
bbb.place(x=200, y=250)  
      
     
pwd =tkinter.Entry(root1,width=12)
pwd.place(x =100 , y=200,width = 250, height=40,anchor = NW)
      

#登录界面===============================================
def jiunu():      
        global root1
        db = MySQLdb.connect(host='192.168.2.41',port=3306,user='root',passwd='newpassword',db='photo',charset='utf8')

# 使用cursor()方法获zhoua取操作游标 
        cursor = db.cursor()
            # 判断用户名是否存在
        sql = 'select user_password from user where user_name=%s'
            # params = [uname]
        cursor.execute(sql, (name.get(),))
        a=name.get()
        data = cursor.fetchone()
        db.close()

        words = pwd.get()
        print("a",words)
        root1.destroy()
        while(words!=data[0]): #如果密码正确,摧毁登陆界面
          return 0
        
        def cv_imread(filePath):  
            cv_img=cv2.imdecode(np.fromfile(filePath,dtype=np.uint8),-1)  
            ## imdecode读取的是rgb,如果后续需要opencv处理的话,需要转换成bgr,转换后图片颜色会变化    ##cv_img=cv2.cvtColor(cv_img,cv2.COLOR_RGB2BGR)   
            return cv_img
        # 创建tkinter主窗口
        root = tkinter.Tk()
        
        root.title('图片处理')
        
        # 指定主窗口位置与大小
        root.geometry('1300x800+100+50')   # width x height + widthoffset + heightoffset
        
        # 不允许改变窗口大小
        root.resizable(False, False)
        root.focusmodel()
        
        def buttonCaptureClick():   
            #xy_text.set(str(file_entry.get()))
            xy_text.set(str(file_entry.get()).split('/')[-1][0:-4])
            
        def checkid():   
            #xy_text.set(str(file_entry.get()))
            print("name.get()",a)
            xy_text1.set(str(a))
        
        #获取输入的标注内容
        def getstr():
            if input_valueText.get() != '':
                words = input_valueText.get()
                get_label["text"] = words
        
        def selectPath1():
             db = MySQLdb.connect(host='192.168.2.41',port=3306,user='root',passwd='newpassword',db='photo',charset='utf8')
             db.autocommit(True)
# 使用cursor()方法获zhoua取操作游标 
             cursor = db.cursor()       
             path_ = askdirectory()            
             #sql = 'select user_password from user where user_name=%s'       
             j=0                           
             for i in os.listdir(path_):
                 print("as",i)
                 create_time = time.strftime('%y%m%d%H%M%S',time.localtime())+str(j)
                 sql = "INSERT INTO photo(source, photo_id, save_path,upload_name) VALUES(%d,\'%s\',\'%s\',\'%s\')" %(1,create_time,i,a)
            # params = [uname]
                 j=j+1
                 cursor.execute(sql)
             db.close()
             result = tkinter.messagebox.askokcancel(title = '提示',message='数据全部导入数据库')
             print(result)
             
        def save_jsonfile():
            print("list_content",list_content)
        
        # 定义坐标显示位置
        xy_text = StringVar()
        xy_text1 = StringVar()
        
        #打开图片文件并显示
        def choosepic():
            path_ = askopenfilename()
            path.set(path_)
            img_open = Image.open(file_entry.get())
            img_open=img_open.resize((600, 650))
            img = ImageTk.PhotoImage(img_open)
            image_label.config(image=img)
            image_label.image = img  # keep a reference
        def database_choosepic():
            db = MySQLdb.connect(host='192.168.2.41',port=3306,user='root',passwd='newpassword',db='photo',charset='utf8')
            db.autocommit(True)
# 使用cursor()方法获zhoua取操作游标 
            cursor = db.cursor()
            sql = """select
 a.photo_id,
 a.save_path,
 b.label_id,
 b.label_name
from
 photo.photo a
cross join photo.label b
left join photo.photo_label c on
 a.photo_id = c.photo_id
 and b.label_id = c.label_id
where
 a.is_delete = 0
 and b.is_delete = 0
 and a.is_lock = 0
 and c.id is null
order by
 a.create_time asc,
 b.`order` asc
limit 25"""
            cursor.execute(sql)
            photo_nsddame=cursor.fetchall();
           # print("photo_ndsdame",photo_nsddame[1:5][1:5])
            #计算未打标签的个数。    
            name_labeal=[]
            shuzu=[]
            for i in photo_nsddame:
                name_labeal.append(i[3])
                #print(i[3])
                shuzu.append(i[0])
            user_dict = {}
            for user in shuzu:
                if user not in user_dict:
                   user_dict[user] = 1
                else:
                   user_dict[user] +=1
            id_name_a=shuzu[0]
            NO_label_number=user_dict[id_name_a]

            for i in range(NO_label_number):
              #print(i)
               
              label_name_1=name_labeal[i] 
              print("label_name_1",label_name_1)
              if (label_name_1=='头发遮眉毛'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_1) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
              if (label_name_1=='头发遮耳朵'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_2) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
            
              if (label_name_1=='头发遮肩膀'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_3) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
              if (label_name_1=='头发蓬散'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_4) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)      
            if (label_name_1=='染发'):            
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_5) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
            if (label_name_1=='聚焦不清'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_6) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
            
            if (label_name_1=='佩戴项链'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_7) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
            if (label_name_1=='佩戴耳环'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_8) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
            if (label_name_1=='头歪'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_9) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)  
            if (label_name_1=='坐姿不正'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_10) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
            
            if (label_name_1=='眼睛没看镜头'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_11) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
            if (label_name_1=='衣着不当'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_12) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)     
            if (label_name_1=='佩戴眼镜'):            
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_13) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
            if (label_name_1=='曝光不足'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_14) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
            
            if (label_name_1=='曝光过度'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_15) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
            if (label_name_1=='化妆'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_16) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)            
              
            if (label_name_1=='表情不自然'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_17) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
            if (label_name_1=='浅色衣服'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_18) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)  
            if (label_name_1=='有异物'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_19) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
            
            if (label_name_1=='衣领过高'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_20) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
            if (label_name_1=='衣领过低'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_21) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)     
            if (label_name_1=='脸部反光'):             
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_22) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
            if (label_name_1=='脸部有阴影'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_23) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
            
            if (label_name_1=='眼镜过低'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_24) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z)
            if (label_name_1=='镜片反光'):               
                sd=tkinter.Checkbutton(root, text=label_name_1, command=click_25) 
                if (i<=5):
                    z=120+30*i
                    sd.place(x =720 , y=z)
                if (5<i<=11):
                    z=120+30*(i-6)
                    sd.place(x =840 , y=z)
                if (11<i<=17):
                    z=120+30*(i-12)
                    sd.place(x =960 , y=z)
                if (17<i<=24):
                    z=120+30*(i-18)
                    sd.place(x =1080 , y=z)
                if (24<i<=25):
                    z=120
                    sd.place(x =1200 , y=z) 
                                                                                      
            path_ = askopenfilename()
            path.set(path_)
            
            img_open = Image.open(file_entry.get())
            img_open=img_open.resize((600, 650))
            img = ImageTk.PhotoImage(img_open)
            image_label.config(image=img)
            image_label.image = img  # keep a reference

            
        path = StringVar()
        tkinter.Button(root, text = '导入图像' ,command=choosepic,bg='blue',fg="white").place(x = 200, y = 720,w = 100, h = 40)
        file_entry = Entry(root, state='readonly', text=path)
        file_entry.pack()
        image_label = Label(root, bg = 'gray')
        image_label.place(x=0, y=0,width = 650, height = 650)
        
        
        #添加截图按钮功能
        buttonCapture = tkinter.Button(root, text='图像ID', command=buttonCaptureClick,bg='red',fg="white")
        check_people = tkinter.Button(root, text='检测人员ID', command=checkid,bg='red',fg="white")
        #坐标名称及显示坐标
        label_xytitle = tkinter.Label(root,text ='标签类别:')
        label_xytitle.place(x=720, y=400)
        label = tkinter.Label(root, textvariable=xy_text,fg = 'blue')
        label.place(x=790, y=570)
        
        
        label1 = tkinter.Label(root, textvariable=xy_text1,fg = 'blue')
        label1.place(x=1130, y=570)
        # 输入标注内容
        input_valueTitle = StringVar()
        input_valueTitle.set('增加评语标签:')
        label_inputTitle = tkinter.Label(root, textvariable=input_valueTitle)
        label_inputTitle.place(x=720, y=350)
        #输入框
        input_youvalueTitle = StringVar()
        input_youvalueTitle.set('数据已有标签:')
        label_youinputTitle = tkinter.Label(root, textvariable=input_youvalueTitle)
        label_youinputTitle.place(x=1020, y=350)
        input_valueText = tkinter.Entry(root,width=12)
        input_valueText.place(x =720 , y=400,width = 250, height=40,anchor = NW)
        
        #获取输入内容
        comand = tkinter.Button(root, text="获取标签内容" ,command=getstr, width=10, height=2)
        comand.place(x =720 , y=470,width = 250, height=40,anchor = NW)
        get_label = tkinter.Label(root, fg = 'blue')
        get_label.place(x =720 , y=530)
        
        buttonCapture.place(x=730, y=570, width=60, height=20)
        check_people.place(x=1030, y=570, width=70, height=20)
        
        quit_button = tkinter.Button(root,text="退出",command=root.quit,activebackground="blue",bg='red',fg="white")
        quit_button.place(x =0 , y=720,width = 100, height=40,anchor = NW)
        #保存数据
        save = tkinter.Button(root, text="数据库导入", command=selectPath1, width=10, height=2,bg='blue',fg="white")
        save.place(x =400 , y=720,width = 100, height=40,anchor = NW)
        
        
        daoru_data = tkinter.Button(root, text="打标签", command=database_choosepic, width=10, height=2,bg='blue',fg="white")
        daoru_data.place(x =600 , y=720,width = 100, height=40,anchor = NW)
        check_daoru_data = tkinter.Button(root, text="审核", command=database_choosepic, width=10, height=2,bg='blue',fg="white")
        check_daoru_data.place(x =800 , y=720,width = 100, height=40,anchor = NW)
        
        tijiao = tkinter.Button(root, text="提交", command=save_jsonfile, width=10, height=2,bg='red',fg="white")
        tijiao.place(x =1000 , y=720,width = 100, height=40,anchor = NW)
        
        
        #建立复选框界面
        
      
        list_content = ['评语标签:']
        hobby_list = ['头发遮眉毛', '头发遮耳朵', '头发遮肩膀','头发蓬散', '染发', '聚焦不清','佩戴项链', '佩戴耳环', '头歪','坐姿不正', '眼睛没看镜头', '衣着不当',
                      '佩戴眼镜', '曝光不足', '曝光过度','化妆', '表情不自然', '浅色衣服','有异物'
                      , '衣领过高', '衣领过低','脸部反光', '脸部有阴影', '眼镜过低','镜片反光']
        
    
        def click_1():
            flag_1 = False                 
            flag_1 = not flag_1
            if flag_1:
                if ("头发遮眉毛" in list_content ):
                    list_content.remove(hobby_list[0])
                else:                        
                     list_content.append(hobby_list[0])
            else:
                list_content.remove(hobby_list[0])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content
           
        
        
        def click_2():
            flag_2 = False
            flag_2 = not flag_2
            if flag_2:
                if ("头发遮耳朵" in list_content ):
                    list_content.remove(hobby_list[1])
                else:
                        
                     list_content.append(hobby_list[1])
            else:
                list_content.remove(hobby_list[1])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content
            
        
        
        def click_3():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("头发遮肩膀" in list_content ):
                    list_content.remove(hobby_list[2])
                else:
                        
                     list_content.append(hobby_list[2])
            else:
                list_content.remove(hobby_list[2])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content
        def click_4():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("头发蓬散" in list_content ):
                    list_content.remove(hobby_list[3])
                else:
                        
                     list_content.append(hobby_list[3])
            else:
                list_content.remove(hobby_list[3])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content
        def click_5():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("染发" in list_content ):
                    list_content.remove(hobby_list[4])
                else:
                        
                     list_content.append(hobby_list[4])
            else:
                list_content.remove(hobby_list[4])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content           
       
        def click_6():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("聚焦不清" in list_content ):
                    list_content.remove(hobby_list[5])
                else:
                        
                     list_content.append(hobby_list[5])
            else:
                list_content.remove(hobby_list[5])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content  
        def click_7():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("佩戴项链" in list_content ):
                    list_content.remove(hobby_list[6])
                else:
                        
                     list_content.append(hobby_list[6])
            else:
                list_content.remove(hobby_list[6])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content  
        def click_8():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("佩戴耳环" in list_content ):
                    list_content.remove(hobby_list[7])
                else:
                        
                     list_content.append(hobby_list[7])
            else:
                list_content.remove(hobby_list[7])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content  
        def click_9():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("头歪" in list_content ):
                    list_content.remove(hobby_list[8])
                else:
                        
                     list_content.append(hobby_list[8])
            else:
                list_content.remove(hobby_list[8])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content  
        def click_10():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("坐姿不正" in list_content ):
                    list_content.remove(hobby_list[9])
                else:
                        
                     list_content.append(hobby_list[9])
            else:
                list_content.remove(hobby_list[9])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content  
        def click_11():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("眼睛没看镜头" in list_content ):
                    list_content.remove(hobby_list[10])
                else:
                        
                     list_content.append(hobby_list[10])
            else:
                list_content.remove(hobby_list[10])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content  
            
        def click_12():
            flag_1 = False                 
            flag_1 = not flag_1
            if flag_1:
                if ("衣着不当" in list_content ):
                    list_content.remove(hobby_list[11])
                else:                        
                     list_content.append(hobby_list[11])
            else:
                list_content.remove(hobby_list[11])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content
           
        
      
                      
        def click_13():
            flag_2 = False
            flag_2 = not flag_2
            if flag_2:
                if ("佩戴眼镜" in list_content):
                    list_content.remove(hobby_list[12])
                else:
                        
                     list_content.append(hobby_list[12])
            else:
                list_content.remove(hobby_list[12])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content
            
        
        
        def click_14():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("曝光不足" in list_content ):
                    list_content.remove(hobby_list[13])
                else:
                        
                     list_content.append(hobby_list[13])
            else:
                list_content.remove(hobby_list[13])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content
            
            
        def click_15():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("曝光过度" in list_content ):
                    list_content.remove(hobby_list[14])
                else:
                        
                     list_content.append(hobby_list[14])
            else:
                list_content.remove(hobby_list[14])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content
        def click_16():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("化妆" in list_content ):
                    list_content.remove(hobby_list[15])
                else:
                        
                     list_content.append(hobby_list[15])
            else:
                list_content.remove(hobby_list[15])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content           
    
        def click_17():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("表情不自然" in list_content ):
                    list_content.remove(hobby_list[16])
                else:
                        
                     list_content.append(hobby_list[16])
            else:
                list_content.remove(hobby_list[16])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content  
        def click_18():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("浅色衣服" in list_content ):
                    list_content.remove(hobby_list[17])
                else:
                        
                     list_content.append(hobby_list[17])
            else:
                list_content.remove(hobby_list[17])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content  
        def click_19():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("有异物" in list_content ):
                    list_content.remove(hobby_list[18])
                else:
                        
                     list_content.append(hobby_list[18])
            else:
                list_content.remove(hobby_list[18])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content  
         
        def click_20():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("衣领过高" in list_content ):
                    list_content.remove(hobby_list[19])
                else:
                        
                     list_content.append(hobby_list[19])
            else:
                list_content.remove(hobby_list[19])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content  
        def click_21():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("衣领过低" in list_content ):
                    list_content.remove(hobby_list[20])
                else:
                        
                     list_content.append(hobby_list[20])
            else:
                list_content.remove(hobby_list[9])
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content  
         
        def click_22():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("脸部反光" in list_content ):
                    list_content.remove(hobby_list[21])
                else:
                        
                     list_content.append(hobby_list[21])
            else:
                list_content.remove(hobby_list[21])
                
            # print('你的爱好是:', list_content)
            lab_msg['text'] = list_content 
        def click_23():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("脸部有阴影" in list_content ):
                    list_content.remove(hobby_list[22])
                else:
                        
                     list_content.append(hobby_list[22])
            else:
                list_content.remove(hobby_list[22])
            lab_msg['text'] = list_content
        def click_24():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("眼镜过低" in list_content ):
                    list_content.remove(hobby_list[23])
                else:
                        
                     list_content.append(hobby_list[23])
            else:
                list_content.remove(hobby_list[23])
            lab_msg['text'] = list_content
        def click_25():
            flag_3 = False
            flag_3 = not flag_3
            if flag_3:
                if ("镜片反光" in list_content ):
                    list_content.remove(hobby_list[24])
                else:
                        
                     list_content.append(hobby_list[24])
            else:
                list_content.remove(hobby_list[24])
            lab_msg['text'] = list_content
        
            
    

        lab = tkinter.Label(root, text='常用标签:')
        lab.place(x =720 , y=90)



        
        
        lab_msg = tkinter.Label(root, text='')
        lab_msg.place(x =720 , y=300)

# 启动消息主循环
buff=Button(root1,text="登录",command=jiunu,fg="red")
buff.place(x =170 , y=300,width = 100, height=40,anchor = NW)
root1.mainloop()



  • 界面展示

 

点击进入登录界面:

 

登录的密码是查询数据库的密码的,如果错误会直接退出。如果正确会,弹出下一个界面

 

  • 3
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值