Example #1
0
 def to_mysql(self):
     self.my = Mysql_demo()
     self.sql = 'insert into user values ("{0}","{1}","{2}","{3}","{4}")'.format(self.tel,self.pwd,self.name,self.gender,3)
     self.my.insert(self.sql)
     #提示框
     self.hnt = tkinter.messagebox.showinfo('提示', '注册成功,前往登录')
     self.base.destroy()
Example #2
0
 def borrow(self):
     #查询是否还有借书条件
     self.my_is = Mysql_demo()
     sql = 'select borrow from user where id="{0}";'.format(self.acount)
     data = self.my_is.search(sql)[0][0]
     if data > 0:
         #获取当前时间戳
         time1 = time.time()
         #获取20天后的时间戳
         time2 = time.time() + 20 * 24 * 60 * 60
         time_b = time.strftime("%Y/%m/%d %H:%M", time.localtime(time1))
         time_r = time.strftime("%Y/%m/%d %H:%M", time.localtime(time2))
         self.my = Mysql_demo()
         sql = 'insert into bor_book values ("{0}","{1}","{2}","{3}","{4}");'.format(
             self.acount, self.name, time_b, time_r, self.bor_name)
         self.my.insert(sql)
         # 修改自己借书数目
         self.my_g = Mysql_demo()
         sql = 'update user set borrow={0} where id="{1}";'.format(
             data - 1, self.acount)
         self.my_g.update(sql)
         self.hnn = tkinter.messagebox.showinfo(
             '提示', '借书成功,请在{0}之前归还'.format(time_r))
         #修改书的剩余量
         my = Mysql_demo()
         sql = 'update book set re_qu=re_qu-1 where title={0};'.format(
             self.book_name)
         my.update(sql)
         self.base.destroy()
     else:
         self.hnt = tkinter.messagebox.showinfo('提示', '您借书已超过上限,无法再次借书!')
         self.base.destroy()
Example #3
0
 def button_1(self):
     my = Mysql_demo()
     sql = 'insert into book(title,author,publisher,recolagu,href,drop_type) values ("{0}","{1}","{2}","{3}","{4}","{5}");'.format(
         self.entry1.get(), self.entry2.get(), self.entry3.get(),
         self.entry4.get(), self.entry5.get(), self.entry6.get())
     my.insert(sql)
     hnt = tkinter.messagebox.showinfo('提示',
                                       '{0} 插入成功'.format(self.entry1.get()))
Example #4
0
 def __init__(self, acount, name, book_name, drop_type):
     self.acount = acount
     self.name = name[0][0]
     self.book_name = book_name
     a = Mysql_demo()
     sql = 'insert into book_dian(book_name,drop_type) values ("{0}","{1}")'.format(
         self.book_name, drop_type)
     a.insert(sql)
Example #5
0
 def root_bor(self):
     datas = list()
     a = Mysql_demo()
     sql = 'select acount,b_date,book_name from bor_book;'
     data = a.search(sql)
     for i in range(len(data)):
         datas.append(data[i][0] + ' ' + data[i][1] + ' ' + str(data[i][2]))
     datas = tuple(datas)
     return datas
Example #6
0
 def root_user(self):
     datas = list()
     a = Mysql_demo()
     sql = 'select id,borrow from user;'
     data = a.search(sql)
     for i in range(len(data)):
         datas.append(data[i][0] + '    ' + str(data[i][1]))
     datas = tuple(datas)
     return datas
Example #7
0
 def type_book_list(self, type_name):
     datas = list()
     a = Mysql_demo()
     sql = 'select title,author from book where drop_type="{0}";'.format(
         type_name)
     data = a.search(sql)
     for i in range(len(data)):
         datas.append(data[i][0] + '       ' + data[i][1])
     datas = tuple(datas)
     return datas
Example #8
0
 def first_book_list(self):
     datas = list()
     self.rand_num = [random.randint(830, 100000) for _ in range(0, 30)]
     a = Mysql_demo()
     for i in self.rand_num:
         self.sql = 'select title,author from book where _id={0};'.format(i)
         data = a.search(self.sql)
         datas.append(data[0][0] + '       ' + data[0][1])
     datas = tuple(datas)
     return datas
Example #9
0
 def print_item(self, event):
     # try:
     self.book_name = ((self.lb.get(
         self.lb.curselection())).split('       ')[0]).replace('\n',
                                                               '').strip()
     print(self.book_name)
     #根据book_name查找
     self.my_s = Mysql_demo()
     self.sql_s = 'select title,author,publisher,recolagu,href,drop_type from book where title="{0}";'.format(
         self.book_name)
     self.book_data = self.my_s.search(self.sql_s)
     print(self.book_data)
     self.bde = Book_det(self.id, self.name, self.book_name,
                         self.book_data[0][5])
     self.bde.start(self.book_data)
Example #10
0
class T_root_book_num():
    def __init__(self):
        # 数据分析跟数据可视化
        self.my = Mysql_demo()
        sql = 'select book_name,count(*) from bor_book GROUP BY book_name;'
        datas = self.my.search(sql)
        data1 = list()
        data2 = list()
        if len(datas) > 5:
            for i in range(5):
                data1.append(datas[i][0])
                data2.append(datas[i][1])
        else:
            for i in range(len(datas)):
                data1.append(datas[i][0])
                data2.append(datas[i][1])
        data = {"书名": data1, "数量": data2}
        data = json.dumps(data)
        student = pd.read_json(data)
        # print(student)
        student.plot.line(x='书名', y='数量')
        plt.savefig('D:\\pythonproject\\MySQL_project\\data_a\\test2.jpg')

    def start(self):
        self.base = tkinter.Toplevel()
        self.base.geometry("640x480")
        self.base.geometry('+500+100')
        self.base.wm_title('书籍借阅')
        # 图片显示
        img = Image.open('D:\\pythonproject\\MySQL_project\\data_a\\test2.jpg')
        self.book_photo = ImageTk.PhotoImage(img)
        self.lable = tkinter.Label(self.base, image=self.book_photo)
        self.lable.pack()

        self.base.mainloop()
Example #11
0
class T_root_bor():
    def __init__(self):
        pass

    def start(self):
        self.base = tkinter.Tk()
        self.base.geometry("500x300")
        self.base.geometry('+500+100')
        self.base.wm_title('借阅表')
        #列表
        self.var = tkinter.StringVar()
        self.lb = tkinter.Listbox(self.base,
                                  listvariable=self.var,
                                  font=("隶书", 12))
        self.book = Book()
        for item in self.book.root_bor():
            self.lb.insert(tkinter.END, item)
        # 设置list的值
        self.lb.bind('<ButtonRelease-1>', self.print_item)
        self.scrl = tkinter.Scrollbar(self.base)
        self.scrl.place(x=485, y=10, height=340)
        self.lb.configure(yscrollcommand=self.scrl.set)
        self.lb.place(x=20, y=10, width=500, height=340)
        self.scrl['command'] = self.lb.yview
        self.base.mainloop()

    #列表点击事件
    def print_item(self, event):
        pass

    def my_sql(self):
        self.b = Mysql_demo()
        self.sql = 'select id from user'
        self.data = self.b.search(self.sql)
        return len(self.data)
Example #12
0
    def to_mysql(self):
        if self.id == '' or self.pwd == '':
            self.hnt = tkinter.messagebox.showerror('错误', '请输入账号密码')
        else:
            self.my = Mysql_demo()
            self.sql = 'select name from user where id="{0}" and pwd="{1}";'.format(
                self.id, self.pwd)
            self.name = self.my.search(self.sql)
            if self.name != False:
                self.hnt = tkinter.messagebox.showinfo(
                    '提示', '登录成功,欢迎,{0}'.format(self.name[0][0]))
                self.bases.destroy()
                #登录后变化
                self.lable.destroy()
                self.Button_submit.destroy()
                self.Button_register.destroy()
                self.lable = tkinter.Label(self.base,
                                           text='欢迎,{0}'.format(
                                               self.name[0][0]),
                                           font=("微软雅黑", 18))
                self.lable_title = tkinter.Label(self.base,
                                                 text='Welcome Book World',
                                                 font=("微软雅黑", 18),
                                                 fg='orange')
                self.Button_per = tkinter.Button(self.base,
                                                 text="退出登录",
                                                 font=("隶书", 18),
                                                 bg='cyan',
                                                 command=self.person)
                self.Button_per.place(x=550, y=0)
                self.Button_huan = tkinter.Button(self.base,
                                                  text="还书系统",
                                                  font=("隶书", 18),
                                                  bg='lawngreen',
                                                  command=self.return_boo)
                self.Button_huan.place(x=680, y=0)
                self.lable_title.place(x=0, y=0)
                self.lable.place(x=300, y=0, width=200, height=40)

            else:
                self.hnt = tkinter.messagebox.showerror('错误', '账号或密码出错了')
Example #13
0
 def __init__(self):
     # 数据分析跟数据可视化
     self.my = Mysql_demo()
     sql = 'select book_name,count(*) from bor_book GROUP BY book_name;'
     datas = self.my.search(sql)
     data1 = list()
     data2 = list()
     if len(datas) > 5:
         for i in range(5):
             data1.append(datas[i][0])
             data2.append(datas[i][1])
     else:
         for i in range(len(datas)):
             data1.append(datas[i][0])
             data2.append(datas[i][1])
     data = {"书名": data1, "数量": data2}
     data = json.dumps(data)
     student = pd.read_json(data)
     # print(student)
     student.plot.line(x='书名', y='数量')
     plt.savefig('D:\\pythonproject\\MySQL_project\\data_a\\test2.jpg')
Example #14
0
 def __init__(self):
     # 数据分析跟数据可视化
     try:
         self.my = Mysql_demo()
         sql = 'select drop_type,count(*) from book_dian GROUP BY drop_type ORDER BY count(*) desc;'
         datas = self.my.search(sql)
         data1 = list()
         data2 = list()
         if len(datas) > 10:
             for i in range(10):
                 data1.append(datas[i][0])
                 data2.append(datas[i][1])
         else:
             for i in range(len(datas)):
                 data1.append(datas[i][0])
                 data2.append(datas[i][1])
         data = {"书名": data1, "数量": data2}
         data = json.dumps(data)
         student = pd.read_json(data)
         # print(student)
         student.plot.pie(x='书名', y='数量', labels=data1)
         plt.savefig('D:\\pythonproject\\MySQL_project\\data_a\\test1.jpg')
     except Exception as ex:
         print(ex)
Example #15
0
class T_root_ty():
    def __init__(self):
        # 数据分析跟数据可视化
        try:
            self.my = Mysql_demo()
            sql = 'select drop_type,count(*) from book_dian GROUP BY drop_type ORDER BY count(*) desc;'
            datas = self.my.search(sql)
            data1 = list()
            data2 = list()
            if len(datas) > 10:
                for i in range(10):
                    data1.append(datas[i][0])
                    data2.append(datas[i][1])
            else:
                for i in range(len(datas)):
                    data1.append(datas[i][0])
                    data2.append(datas[i][1])
            data = {"书名": data1, "数量": data2}
            data = json.dumps(data)
            student = pd.read_json(data)
            # print(student)
            student.plot.pie(x='书名', y='数量', labels=data1)
            plt.savefig('D:\\pythonproject\\MySQL_project\\data_a\\test1.jpg')
        except Exception as ex:
            print(ex)

    def start(self):
        self.base = tkinter.Toplevel()
        self.base.geometry("640x480")
        self.base.geometry('+500+100')
        self.base.wm_title('类型关注度')
        # 图片显示
        img = Image.open('D:\\pythonproject\\MySQL_project\\data_a\\test1.jpg')
        self.book_photo = ImageTk.PhotoImage(img)
        self.lable = tkinter.Label(self.base, image=self.book_photo)
        self.lable.pack()

        self.base.mainloop()
Example #16
0
class T_register():
    def __init__(self):
        self.base = tkinter.Tk()
        self.base.geometry("300x400")
        self.base.geometry('+500+100')
        self.base.wm_title('注册')
        self.gender = ''
    def register(self):
        # 提示
        self.lable1 = tkinter.Label(self.base, text='电 话', font=("微软雅黑", 18))
        self.lable1.place(x=0, y=10, width=70, height=50)
        # 手机号输入框
        self.entry1 = tkinter.Entry(self.base, font=("隶书", 22), width=20)
        self.entry1.place(x=70, y=15, width=220, height=40)
        # 提示
        self.lable2 = tkinter.Label(self.base, text='密 码', font=("微软雅黑", 18))
        self.lable2.place(x=0, y=65, width=70, height=50)
        # 密码输入框
        self.entry2 = tkinter.Entry(self.base, font=("隶书", 22), width=20, show="*")
        self.entry2.place(x=70, y=65, width=220, height=40)
        # 提示
        self.lable3 = tkinter.Label(self.base, text='姓 名', font=("微软雅黑", 18))
        self.lable3.place(x=0, y=110, width=70, height=50)
        #姓名输入框
        self.entry3 = tkinter.Entry(self.base, font=("隶书", 22), width=20)
        self.entry3.place(x=70, y=115, width=220, height=40)
        # 提示
        self.lable4 = tkinter.Label(self.base, text='性 别', font=("微软雅黑", 18))
        self.lable4.place(x=0, y=155, width=70, height=50)
        #单选框
        self.r = tkinter.IntVar()
        self.radio1 = tkinter.Radiobutton(self.base, text="男",variable=self.r, value='男', font=("微软雅黑", 15), command=self.nan)
        self.radio1.place(x=100,y=160)
        self.radio2 = tkinter.Radiobutton(self.base, text="女", variable=self.r,value='女', font=("微软雅黑", 15),command=self.nv)
        self.radio2.place(x=160,y=160)
        #注册按钮
        self.Button1 = tkinter.Button(self.base, text="注册", font=("隶书", 18), bg='cyan', command=self.reg)
        self.Button1.place(x=50, y=250,width=200)
        #用户注册按钮
        self.Button2 = tkinter.Button(self.base, text="用户注册", font=("隶书", 10),	state=tkinter.DISABLED)
        self.Button2.place(x=30, y=350,width=55)
        # 学生注册按钮
        self.Button3 = tkinter.Button(self.base, text="学生注册", font=("隶书", 10), command=self.t_std_reg)
        self.Button3.place(x=200, y=350, width=55)

        self.base.mainloop()
    def nan(self):
        self.gender = self.radio1['value']

    def nv(self):
        self.gender = self.radio2['value']

    #学生注册
    def t_std_reg(self):
        self.lable1.destroy()
        self.lable2.destroy()

        # 提示
        self.lable1 = tkinter.Label(self.base, text='学 号', font=("微软雅黑", 18))
        self.lable1.place(x=0, y=10, width=70, height=50)
        # 提示
        self.lable2 = tkinter.Label(self.base, text='密 码', font=("微软雅黑", 18))
        self.lable2.place(x=0, y=65, width=70, height=50)
        self.Button2['state'] = tkinter.NORMAL
        self.Button3['state'] = tkinter.DISABLED
        self.Button2['command'] = self.register
    #注册
    def reg(self):
        # print(self.gender)
        self.tel = self.entry1.get()
        self.pwd = self.entry2.get()
        self.name = self.entry3.get()
        self.gender = self.gender
        # print(self.tel,self.pwd,self.name,self.gender)
        self.to_mysql()
    def to_mysql(self):
        self.my = Mysql_demo()
        self.sql = 'insert into user values ("{0}","{1}","{2}","{3}","{4}")'.format(self.tel,self.pwd,self.name,self.gender,3)
        self.my.insert(self.sql)
        #提示框
        self.hnt = tkinter.messagebox.showinfo('提示', '注册成功,前往登录')
        self.base.destroy()
Example #17
0
 def my_sql(self):
     self.b = Mysql_demo()
     self.sql = 'select id from user'
     self.data = self.b.search(self.sql)
     return len(self.data)
Example #18
0
class Book_det():
    def __init__(self, acount, name, book_name, drop_type):
        self.acount = acount
        self.name = name[0][0]
        self.book_name = book_name
        a = Mysql_demo()
        sql = 'insert into book_dian(book_name,drop_type) values ("{0}","{1}")'.format(
            self.book_name, drop_type)
        a.insert(sql)

    def start(self, book_name):
        self.base = tkinter.Toplevel()
        self.base.geometry("600x400")
        self.base.geometry('+500+100')
        self.base.wm_title(book_name[0][0])
        self.bor_name = book_name[0][0]
        #书名
        self.lable1 = tkinter.Label(self.base,
                                    text='书名: ' + book_name[0][0],
                                    font=("微软雅黑", 15),
                                    anchor='w')
        self.lable1.place(x=270, y=40, width=300)
        #作者
        self.lable2 = tkinter.Label(self.base,
                                    text='作者: ' + book_name[0][1],
                                    font=("微软雅黑", 15),
                                    anchor='w')
        self.lable2.place(x=270, y=80, width=300)
        #出版社
        self.lable3 = tkinter.Label(self.base,
                                    text='出版社: ' + book_name[0][2],
                                    font=("微软雅黑", 15),
                                    anchor='w')
        self.lable3.place(x=270, y=120, width=300)
        #概述
        # self.lable4 = tkinter.Label(self.base, text='概述: ' + book_name[0][3], font=("微软雅黑", 15),wraplength=300,justify='left',anchor='n')
        # self.lable4.place(x=270, y=120, width=300,height=190)
        # self.scrl = tkinter.Scrollbar(self.base)
        # self.scrl.place(x=570,y=120,height=190)

        self.scrl_text = scrolledtext.ScrolledText(self.base,
                                                   width=30,
                                                   height=150,
                                                   wrap=tkinter.WORD,
                                                   font=("微软雅黑", 12))
        self.scrl_text.insert(tkinter.END, '概述: ' + book_name[0][3])
        self.scrl_text.place(x=270, y=150, height=150)
        # self.lable4.configure(yscrollcommand=self.scrl.set)
        # self.scrl['command'] = self.lable4.yview
        #图片
        self.headers = {
            'Referer':
            'http://www.bookschina.com/',
            'Host':
            'www.bookschina.com',
            'User-Agent':
            "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/535.24 (KHTML, like Gecko) Chrome/19.0.1055.1 Safari/535.24"
        }
        req = requests.get(book_name[0][4], headers=self.headers, timeout=3)
        html = etree.HTML(req.text)
        try:

            self.photo_url = html.xpath('//a[@class="img"]/img/@src')[0]

            self.headers = {
                'User-Agent':
                "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/535.24 (KHTML, like Gecko) Chrome/19.0.1055.1 Safari/535.24"
            }

            with open(
                    'D:\\pythonproject\\MySQL_project\\book_photo\\' +
                    book_name[0][0] + '.png', 'wb') as f:
                res = requests.get(self.photo_url,
                                   headers=self.headers,
                                   timeout=6)
                f.write(res.content)
            img = Image.open("D:\\pythonproject\\MySQL_project\\book_photo\\" +
                             book_name[0][0] + '.png')  # 打开图片
        except:
            img = Image.open(
                'D:\\pythonproject\\MySQL_project\\book_photo\\feng300.png')
        self.book_photo = ImageTk.PhotoImage(img)
        self.lable4 = tkinter.Label(self.base, image=self.book_photo)
        self.lable4.place(x=10, y=30, width=212, height=300)
        #借阅按钮
        self.Button_bor = tkinter.Button(self.base,
                                         text="借阅",
                                         font=("隶书", 15),
                                         bg='cyan',
                                         command=self.borrow)
        self.Button_bor.place(x=330, y=330, width=150)
        self.base.mainloop()

    #借书
    def borrow(self):
        #查询是否还有借书条件
        self.my_is = Mysql_demo()
        sql = 'select borrow from user where id="{0}";'.format(self.acount)
        data = self.my_is.search(sql)[0][0]
        if data > 0:
            #获取当前时间戳
            time1 = time.time()
            #获取20天后的时间戳
            time2 = time.time() + 20 * 24 * 60 * 60
            time_b = time.strftime("%Y/%m/%d %H:%M", time.localtime(time1))
            time_r = time.strftime("%Y/%m/%d %H:%M", time.localtime(time2))
            self.my = Mysql_demo()
            sql = 'insert into bor_book values ("{0}","{1}","{2}","{3}","{4}");'.format(
                self.acount, self.name, time_b, time_r, self.bor_name)
            self.my.insert(sql)
            # 修改自己借书数目
            self.my_g = Mysql_demo()
            sql = 'update user set borrow={0} where id="{1}";'.format(
                data - 1, self.acount)
            self.my_g.update(sql)
            self.hnn = tkinter.messagebox.showinfo(
                '提示', '借书成功,请在{0}之前归还'.format(time_r))
            #修改书的剩余量
            my = Mysql_demo()
            sql = 'update book set re_qu=re_qu-1 where title={0};'.format(
                self.book_name)
            my.update(sql)
            self.base.destroy()
        else:
            self.hnt = tkinter.messagebox.showinfo('提示', '您借书已超过上限,无法再次借书!')
            self.base.destroy()
Example #19
0
class MN():
    def __init__(self):
        self.book = Book()
        pass

    def start(self):
        #进行自然语言处理初始化
        self.corpus_s = g_5.return_dectionary_tfidf(
            R'D:\pythonproject\MySQL_project\NLP_DATA\book_title.txt')
        # 读取数据
        self.data_l = [
            title for title in open(
                r'D:\pythonproject\MySQL_project\NLP_DATA\book_title.txt',
                'r',
                encoding='utf-8')
        ]
        # 加载lsi模型
        self.lsi_model = models.LsiModel.load(
            R'D:\pythonproject\MySQL_project\NLP_DATA\model_lsi.lsi')
        self.index_l = similarities.MatrixSimilarity(self.lsi_model)

        self.base = tkinter.Tk()
        self.base.geometry("800x500")
        self.base.geometry('+200+100')
        self.base.wm_title('网络图书管理系统')
        # 提示按钮
        self.lable = tkinter.Label(self.base,
                                   text='   请登录:         ',
                                   font=("微软雅黑", 18))
        self.lable.place(x=0, y=0, width=150, height=50)
        # 登录按钮
        self.Button_submit = tkinter.Button(self.base,
                                            text="登录",
                                            font=("隶书", 18),
                                            bg='blue',
                                            command=self.t_submit)
        self.Button_submit.place(x=200, y=10, width=50, height=30)
        # 注册按钮
        self.Button_register = tkinter.Button(self.base,
                                              text="注册",
                                              font=("隶书", 18),
                                              command=self.register)
        self.Button_register.place(x=300, y=10, width=50, height=30)
        # 分割线
        self.fengexian1 = tkinter.Label(
            self.base,
            text='——————————————————————————————————————————————————',
            font=("微软雅黑", 18))
        self.fengexian1.place(x=0, y=40, width=1000, height=10)
        # 搜索框
        self.var_entry = tkinter.Variable()
        self.entry = tkinter.Entry(self.base,
                                   font=("隶书", 22),
                                   width=20,
                                   textvariable=self.var_entry)
        self.entry.place(x=100, y=50, width=500, height=40)
        # 搜索按钮
        self.Button_search = tkinter.Button(self.base,
                                            text="搜索",
                                            font=("隶书", 18),
                                            bg='cyan',
                                            command=self.search)
        self.Button_search.place(x=620, y=50)
        # 列表
        self.var = tkinter.StringVar()
        global lb
        self.lb = tkinter.Listbox(self.base,
                                  listvariable=self.var,
                                  font=("隶书", 12))
        self.list_item = [i for i in range(1, 31)]
        for item in self.list_item:
            self.lb.insert(tkinter.END, item)

        #设置list的值
        self.var.set((self.book.first_book_list()))
        self.lb.bind('<ButtonRelease-1>', self.print_item)
        self.scrl = tkinter.Scrollbar(self.base)
        self.scrl.place(x=600, y=100, height=340)
        self.lb.configure(yscrollcommand=self.scrl.set)
        self.lb.place(x=20, y=100, width=580, height=340)
        self.scrl['command'] = self.lb.yview

        #类型列表
        self.vars = tkinter.StringVar()
        self.lbs = tkinter.Listbox(self.base,
                                   listvariable=self.vars,
                                   font=("隶书", 12))
        self.list_items = [i for i in range(1, 223)]
        for item in self.list_items:
            self.lbs.insert(tkinter.END, item)
        # 设置list的值
        self.vars.set(
            (('0-2岁', '3-6岁', '一般管理学', '世界名著', '世界政治', '世界文化', '世界美食', '两性关系',
              '个人理财', '中医保健', '中国儿童文学', '中国古代哲学', '中国古代随笔', '中国古典小说', '中国古诗词',
              '中国当代小说', '中国政治', '中国文化', '中国民族音乐', '中国现当代诗歌', '中国现当代随笔', '中国经济',
              '中国近现代小说', '中小学教辅', '中老年', '书画', '人体艺术', '人工智能', '人生哲学', '人际交往',
              '企业软件开发与实施', '会计', '传统文化', '传记', '体育明星', '作品集', '作品集/作品赏析',
              '作曲/指挥', '侦探/悬疑/推理', '保健/心理健康', '保健食谱营养', '保险', '信息安全', '健康百科',
              '健身', '其他国外青春文学', '军事', '农业/林业', '初中通用', '动漫/卡通', '励志/成长', '医学',
              '历代帝王', '历史人物', '历史知识读物', '历史读物', '叛逆/成长', '口才/演讲/辩论', '古代家具',
              '古籍整理', '史学理论', '史料典籍', '史类', '吉它', '名人励志', '后期处理', '哲学',
              '哲学知识读物', '四大名著', '国内自助旅游指南', '国外自助旅游指南', '国画', '国际法', '国际经济',
              '地图/地理', '地域文化', '地方史志', '城市自助旅游指南', '声乐', '外交、国际关系', '外国儿童文学',
              '外国小说', '外国诗歌', '外国随笔', '外国音乐', '外语', '大学英语', '子部', '孕产妇/育儿',
              '孕产百科', '字帖', '学者', '宗教', '宝石', '家居/休闲游戏', '家常食谱', '家庭与办公室用书',
              '家庭教育', '寓言传说', '小说', '少儿英语', '工业技术', '工具书', '工艺美术', '市场/营销',
              '常见病', '建筑', '建筑艺术', '影视制作', '影视明星', '影视理论', '影视赏析', '征订教材',
              '心灵与修养', '心理健康', '心理学', '性格与习惯', '悬疑/惊悚', '戏剧', '成功/励志', '成功/激励',
              '技法/教程', '技法教程', '拓展读物', '摄影器材', '摄影理论', '操作系统/系统开发', '收藏百科',
              '收藏随笔', '政治', '政治人物', '教师用书', '教育', '数据库', '数码摄影', '文化理论',
              '文化评述', '文学', '文学家', '文学理论', '文集', '新闻传播出版', '旅游', '旅游摄影/画册',
              '旅游攻略', '旅游随笔', '校园', '民俗文化', '民族史志', '民间艺术', '水粉水彩', '油画', '法律',
              '法律法规', '法的理论', '港台青春文学', '爆笑/无厘头', '玄幻/新武侠/魔幻/科幻', '玉器', '理论',
              '理论/欣赏', '生活常识', '电子商务', '电脑杂志――合订本', '益智游戏', '研究生/本科/专科教材',
              '硬笔书法', '碑帖', '社会学', '社会科学', '神秘现象', '科学家', '科幻', '科普/百科',
              '科普读物', '程序设计', '童话', '篆刻', '素描速写', '经济法', '经济理论', '经济通俗读物',
              '经部', '绘画理论', '美丽装扮', '美学', '美食', '考古文物', '考试', '育儿百科', '自传',
              '自然科学', '舞台艺术戏曲', '艺术家', '艺术理论', '艺术类考试', '艺术课堂', '英语考试', '英语读物',
              '行业/职业英语', '计算机体系结构', '计算机教材', '计算机理论', '计算机考试认证', '认知', '设计',
              '语文阅读', '语言文字', '软件工程/开发项目管理', '通俗音乐', '金融/投资', '钢琴', '钱币', '陶瓷',
              '集部', '雕品', '雕塑', '青春文学', '餐饮指南', '饮食文化', '高中通用', '高考')))
        self.lbs.bind('<ButtonRelease-1>', self.type_item)
        self.scrls = tkinter.Scrollbar(self.base)
        self.scrls.place(x=775, y=100, height=340)
        self.lbs.configure(yscrollcommand=self.scrls.set)
        self.lbs.place(x=630, y=100, height=340)
        self.scrls['command'] = self.lbs.yview
        self.base.mainloop()

    # 事件绑定
    def print_item(self, event):
        # try:
        self.book_name = ((self.lb.get(
            self.lb.curselection())).split('       ')[0]).replace('\n',
                                                                  '').strip()
        print(self.book_name)
        #根据book_name查找
        self.my_s = Mysql_demo()
        self.sql_s = 'select title,author,publisher,recolagu,href,drop_type from book where title="{0}";'.format(
            self.book_name)
        self.book_data = self.my_s.search(self.sql_s)
        print(self.book_data)
        self.bde = Book_det(self.id, self.name, self.book_name,
                            self.book_data[0][5])
        self.bde.start(self.book_data)

    # except:
    #     submit_warn = tkinter.messagebox.showinfo('警告', '请先登录!')

    #类型点击响应方法

    def type_item(self, event):
        self.type_name = self.lbs.get(self.lbs.curselection())
        # print(self.type_name)
        a = Book()
        self.var.set(a.type_book_list(self.type_name))

    # 登录
    def submit(self):
        s = t_user.T_submit()
        s.t_submit()

    # 注册
    def register(self):
        r = T_register()
        r.register()

    #搜索
    def search(self):
        self.entry_con = self.var_entry.get()
        # self.entry_con = list(self.entry_con)
        # self.sql_re = '.*'
        # for i in self.entry_con:
        #     self.sql_re = self.sql_re+i+'.*'
        # self.sql_s = Mysql_demo()
        # self.sql_search = "select title,author from book where title regexp '({0})';".format(self.sql_re)
        # self.search_datas = self.sql_s.search(self.sql_search)
        # print(self.search_datas)
        vec_bow = self.corpus_s[0].doc2bow(jieba.cut(self.entry_con))
        # 输入数据转换为tfidf模型
        vec_tfidf = self.corpus_s[1][vec_bow]
        # 输入数据转换成lsi模型
        vec_lsi = self.corpus_s[2][vec_tfidf]

        sims = self.index_l[vec_lsi]
        sims = sorted(enumerate(sims), key=lambda x: -x[1])
        self.search_datas = []  #初始化数据
        # with open('相似度.txt', 'w', encoding='utf-8') as f:
        count = 0
        for i in sims:
            if count <= 60 and i[1] > 0:
                a = [str(self.data_l[i[0]]), str(i[1])]
                self.search_datas.append(a)
                count += 1
            else:
                break
        # print(self.search_datas)
        #判断返回值
        if self.search_datas != False:
            #清空列表
            self.lb.delete(0, tkinter.END)
            self.list_item = [i for i in range(len(self.search_datas))]
            # print(self.list_item)
            for item in self.list_item:
                self.lb.insert(tkinter.END, item)
            #添加list数据
            data_list = []
            for i in self.list_item:
                data_list.append(self.search_datas[i][0] + '       ' +
                                 self.search_datas[0][1])
            data_list = tuple(data_list)
            self.var.set((data_list))
            self.lb.bind('<ButtonRelease-1>', self.print_item)
        else:
            # 清空列表
            self.lb.delete(0, tkinter.END)

    def t_submit(self):
        self.bases = tkinter.Tk()
        self.bases.geometry("300x400")
        self.bases.geometry('+500+100')
        self.bases.wm_title('登录')
        # 提示
        self.lable1 = tkinter.Label(self.bases, text='电 话', font=("微软雅黑", 18))
        self.lable1.place(x=0, y=10, width=70, height=50)
        # 手机号输入框
        self.entry1 = tkinter.Entry(self.bases, font=("隶书", 22), width=20)
        self.entry1.place(x=70, y=15, width=220, height=40)
        # 提示
        self.lable2 = tkinter.Label(self.bases, text='密 码', font=("微软雅黑", 18))
        self.lable2.place(x=0, y=65, width=70, height=50)
        # 密码输入框
        self.entry2 = tkinter.Entry(self.bases,
                                    font=("隶书", 22),
                                    width=20,
                                    show="*")
        self.entry2.place(x=70, y=65, width=220, height=40)
        # 登录按钮
        self.Button1 = tkinter.Button(self.bases,
                                      text="登录",
                                      font=("隶书", 18),
                                      bg='cyan',
                                      command=self.t_is_submit)
        self.Button1.place(x=50, y=140, width=200)
        # 用户登录按钮
        self.Button2 = tkinter.Button(self.bases,
                                      text="用户登录",
                                      font=("隶书", 10),
                                      state=tkinter.DISABLED)
        self.Button2.place(x=30, y=350, width=55)
        # 学生登录按钮
        self.Button3 = tkinter.Button(self.bases,
                                      text="学生登录",
                                      font=("隶书", 10),
                                      command=self.t_std_submit)
        self.Button3.place(x=200, y=350, width=55)
        self.bases.mainloop()

    # 学生登陆
    def t_std_submit(self):
        self.lable1.destroy()
        self.lable2.destroy()
        # 提示
        self.lable1 = tkinter.Label(self.bases, text='学 号', font=("微软雅黑", 18))
        self.lable1.place(x=0, y=10, width=70, height=50)
        # 提示
        self.lable2 = tkinter.Label(self.bases, text='密 码', font=("微软雅黑", 18))
        self.lable2.place(x=0, y=65, width=70, height=50)
        self.Button2['state'] = tkinter.NORMAL
        self.Button3['state'] = tkinter.DISABLED
        self.Button2['command'] = self.t_submit

    # 登录按钮函数
    def t_is_submit(self):

        self.id = self.entry1.get()
        self.pwd = self.entry2.get()
        if self.id == 'root' and self.pwd == '123456':
            a = T_root()
            a.start()
        else:
            self.to_mysql()

    # 数据库查询
    def to_mysql(self):
        if self.id == '' or self.pwd == '':
            self.hnt = tkinter.messagebox.showerror('错误', '请输入账号密码')
        else:
            self.my = Mysql_demo()
            self.sql = 'select name from user where id="{0}" and pwd="{1}";'.format(
                self.id, self.pwd)
            self.name = self.my.search(self.sql)
            if self.name != False:
                self.hnt = tkinter.messagebox.showinfo(
                    '提示', '登录成功,欢迎,{0}'.format(self.name[0][0]))
                self.bases.destroy()
                #登录后变化
                self.lable.destroy()
                self.Button_submit.destroy()
                self.Button_register.destroy()
                self.lable = tkinter.Label(self.base,
                                           text='欢迎,{0}'.format(
                                               self.name[0][0]),
                                           font=("微软雅黑", 18))
                self.lable_title = tkinter.Label(self.base,
                                                 text='Welcome Book World',
                                                 font=("微软雅黑", 18),
                                                 fg='orange')
                self.Button_per = tkinter.Button(self.base,
                                                 text="退出登录",
                                                 font=("隶书", 18),
                                                 bg='cyan',
                                                 command=self.person)
                self.Button_per.place(x=550, y=0)
                self.Button_huan = tkinter.Button(self.base,
                                                  text="还书系统",
                                                  font=("隶书", 18),
                                                  bg='lawngreen',
                                                  command=self.return_boo)
                self.Button_huan.place(x=680, y=0)
                self.lable_title.place(x=0, y=0)
                self.lable.place(x=300, y=0, width=200, height=40)

            else:
                self.hnt = tkinter.messagebox.showerror('错误', '账号或密码出错了')

    #个人中心
    def person(self):
        self.lable.destroy()
        self.Button_per.destroy()
        self.Button_huan.destroy()
        self.lable_title.destroy()
        self.lable = tkinter.Label(self.base,
                                   text='   请登录:         ',
                                   font=("微软雅黑", 18))
        self.lable.place(x=0, y=0, width=150, height=50)
        # 登录按钮
        self.Button_submit = tkinter.Button(self.base,
                                            text="登录",
                                            font=("隶书", 18),
                                            bg='blue',
                                            command=self.t_submit)
        self.Button_submit.place(x=200, y=10, width=50, height=30)
        # 注册按钮
        self.Button_register = tkinter.Button(self.base,
                                              text="注册",
                                              font=("隶书", 18),
                                              command=self.register)
        self.Button_register.place(x=300, y=10, width=50, height=30)
        self.fengexian1 = tkinter.Label(
            self.base,
            text='——————————————————————————————————————————————————',
            font=("微软雅黑", 18))
        self.fengexian1.place(x=0, y=40, width=1000, height=10)

    #还书系统
    def return_boo(self):
        self.re_book = Return_book(self.id)
        self.re_book.start()