Esempio n. 1
0
        def __init__(self, root):
            self.root = root

            # membuat label untuk memasukkan nama link
            Label(self.root, text="Masukkan Nama Link : ").place(x=10, y=10)
            application.layout.txt_nama = Entry(self.root)
            application.layout.txt_nama.place(x=10, y=30)

            # membuat label untuk memasukkan link
            Label(self.root, text="Masukkan Link yang akan di simpan : ").place(x=10, y=60)
            application.layout.txt_link = Entry(self.root)
            application.layout.txt_link['width'] = 34
            application.layout.txt_link.place(x=10, y=80)

            # membuat kolom untuk memasukkan deskripsi
            Label(self.root, text="Masukkan deskripsi link : ").place(x=10, y=110)
            application.layout.txt_deskripsi = Entry(self.root)
            application.layout.txt_deskripsi['width'] = 34
            application.layout.txt_deskripsi.place(x=10, y=130)

            # membuat fungsi untuk menangani keypress dari user
            application.layout.txt_deskripsi.bind('<Key>', application.commad().key_press)

            # menampilakn table
            Label(self.root, text="Daftar Link yang Sudah tersimpan : ").place(x=310, y=10)
            application.layout.table = Treeview(self.root, columns=('nama', 'link', 'deskripsi'), height=11)
            application.layout.table.place(x=300, y=30)

            ybs = Scrollbar(self.root, orient='vertical', command=application.layout.table.yview)
            application.layout.table.configure(yscroll=ybs.set)
            ybs.place(x=971, y=30, height=241)

            xbs = Scrollbar(self.root, orient='horizontal', command=application.layout.table.xview)
            application.layout.table.configure(xscroll=xbs.set)
            xbs.place(x=300, y=271, width=672)

            application.layout.table.heading('#0', text='Id')
            application.layout.table.column('#0', width=40, minwidth=40)

            application.layout.table.heading('nama', text='Nama')
            application.layout.table.column('nama', width=150, minwidth=150)

            application.layout.table.heading('link', text='Link')
            application.layout.table.column('link', width=240, minwidth=240)

            application.layout.table.heading('deskripsi', text='Deskripsi')
            application.layout.table.column('deskripsi', width=240, minwidth=240)

            application.layout.table.bind('<Double-1>', application.commad().select_table, add='+')

            # membuat button untuk eksekusi
            Button(self.root, text="Simpan Link", command=application.commad().save_link).place(x=90, y=165)
            Button(self.root, text="Cek select", command=application.commad().select_table).place(x=90, y=195)
Esempio n. 2
0
 def build_treeview(self):
     clear_widgets(self.results_frame)
     self.results_tv = Treeview(self.results_frame, columns=1, height=20)
     self.results_tv.pack(expand=True, fill="both")
     self.result_label = tk.Label(self.results_frame,
                                  textvariable=self.result_count)
     self.result_label.pack(side="bottom")
     vsb = Scrollbar(self.results_tv,
                     orient="vertical",
                     command=self.results_tv.yview)
     vsb.place(x=1, y=25, height=400)
     self.results_tv.bind("<Double-1>", self.OnDoubleClick)
    def __init__(self, columns, data, title):
        self.root = tk.Tk()
        self.root.title(title)
        self.root.geometry("500x500")
        self.columns = tuple(columns)

        self.my_tree = ttk.Treeview(self.root)
        self.my_tree['columns'] = self.columns
        self.my_tree.column("#0", width=0, stretch=NO)

        for i in columns:
            self.my_tree.column(i, stretch=tk.YES)

        self.my_tree.heading("#0", text="")
        for i in columns:
            self.my_tree.heading(i, text=i)

        id = 0
        self.data = data
        for d in self.data:
            self.my_tree.insert(parent='',
                                index='end',
                                text="",
                                iid=id,
                                values=d)
            id = id + 1

        self.my_tree.pack(pady=20)

        # vsb = Scrollbar(self.root, orient="vertical", command=self.my_tree.yview)
        # vsb.place(relx=0.978, rely=0.175, relheight=0.713, relwidth=0.020)

        hsb = Scrollbar(self.root,
                        orient="horizontal",
                        command=self.my_tree.xview)
        hsb.place(relx=0.014, rely=0.875, relheight=0.020, relwidth=0.965)

        #self.my_tree.configure(yscrollcommand=vsb.set, xscrollcommand=hsb.set)
        self.my_tree.configure(xscrollcommand=hsb.set)

        self.root.mainloop()
Esempio n. 4
0
    def init_ui(self):
        self._win = tk.Tk()
        self._win.title("zk-client")
        self._win.geometry('900x700+500+300')
        self._win.resizable(height=False, width=False)
        tree_wrapper = tk.Frame(self._win, bg='red', width=300)
        tree_wrapper.pack(side=tk.LEFT, fill=tk.Y)

        canvas = self._tree_canvas = tk.Canvas(tree_wrapper,
                                               width=300,
                                               height=700,
                                               scrollregion=(0, 0, 300, 700),
                                               bg='gray')  # 创建canvas
        canvas.place(x=0, y=0)  # 放置canvas的位置

        frame = tk.Frame(canvas)  # 把frame放在canvas里
        # frame.place(width=180, height=600)  # frame的长宽,和canvas差不多的
        vbar = Scrollbar(canvas, orient=tk.VERTICAL)  # 竖直滚动条
        vbar.place(x=281, width=20, height=700)
        vbar.configure(command=canvas.yview)
        hbar = Scrollbar(canvas, orient=tk.HORIZONTAL)  # 水平滚动条
        hbar.place(x=0, y=680, width=280, height=20)
        hbar.configure(command=canvas.xview)
        canvas.config(xscrollcommand=hbar.set, yscrollcommand=vbar.set)  # 设置
        canvas.bind_all(
            "<MouseWheel>", lambda event: canvas.yview_scroll(
                int(-1 * (event.delta / 120)), "units"))

        self._tree_frame_id = canvas.create_window(
            0, 0, window=frame, anchor='nw')  # create_window)

        self._root = Treeview(frame)
        #
        self._root.pack(expand=True, fill=tk.BOTH)
        # self._root.bind("<Button-1>", self.clear_pre_selected)
        # self._root.bind("<< TreeviewClose>>", self.clear_pre_selected)
        self._root.bind("<<TreeviewOpen>>", self.open_node)
Esempio n. 5
0
class Movie_app:
    def __init__(self):
        self.win=Tk()
        self.win.title(" VIP视频破解工具")
        self.creat_res()
        self.creat_radiores()
        self.config()
        self.page=1
        self.p=Pro()
        self.win.resizable(0,0) #防止用户调整尺寸
        curWidth = 600
        curHight = 520
        # 获取屏幕宽度和高度
        scn_w, scn_h = self.win.maxsize()
        # 计算中心坐标
        cen_x = (scn_w - curWidth) / 2
        cen_y = (scn_h - curHight) / 2
        # 设置窗口初始大小和位置
        size_xy = '%dx%d+%d+%d' % (curWidth, curHight, cen_x, cen_y)
        self.win.geometry(size_xy)
        self.win.mainloop()


    def creat_res(self):
        #Menu菜单
        menu = tk.Menu(self.win)
        self.win.config(menu = menu)
        moviemenu = tk.Menu(menu,tearoff = 0)
        menu.add_cascade(label = '友情链接', menu = moviemenu)
        downmenu = tk.Menu(menu,tearoff = 0)
        #各个网站链接
        moviemenu.add_command(label = '网易公开课',command = lambda :webbrowser.open('http://open.163.com/'))
        moviemenu.add_command(label = '腾讯视频',command = lambda :webbrowser.open('http://v.qq.com/'))
        moviemenu.add_command(label = '搜狐视频',command = lambda :webbrowser.open('http://tv.sohu.com/'))
        moviemenu.add_command(label = '芒果TV',command = lambda :webbrowser.open('http://www.mgtv.com/'))
        moviemenu.add_command(label = '爱奇艺',command = lambda :webbrowser.open('http://www.iqiyi.com/'))
        moviemenu.add_command(label = 'PPTV',command = lambda :webbrowser.open('http://www.bilibili.com/'))
        moviemenu.add_command(label = '优酷',command = lambda :webbrowser.open('http://www.youku.com/'))
        moviemenu.add_command(label = '乐视',command = lambda :webbrowser.open('http://www.le.com/'))
        moviemenu.add_command(label = '土豆',command = lambda :webbrowser.open('http://www.tudou.com/'))
        moviemenu.add_command(label = 'A站',command = lambda :webbrowser.open('http://www.acfun.tv/'))
        moviemenu.add_command(label = 'B站',command = lambda :webbrowser.open('http://www.bilibili.com/'))

        self.temp=StringVar()#url地址
        self.temp2=StringVar()
        self.search=StringVar()#搜索
        self.t1=StringVar()#通道
        self.t3=StringVar()#爱奇艺,优酷,PPTV
        self.La_title=Label(self.win,text="第三方视频地址:")
        self.La_way=Label(self.win,text="选择视频解码通道:")
        self.La_mc=Label(self.win,text="关键字搜索:")
        #控件内容设置
        self.numberChosen = Combobox(self.win,width=20)
        self.numberChosen['values']=('通道一','通道二','通道三','通道四','通道五','通道六','通道七','通道八','通道九','通道十')
        self.numberChosen.config(state='readonly')
        self.numberChosen.current(0)

        self.B_play=Button(self.win,text="播放▶")
        self.B_searchSimple=Button(self.win,text="关键字搜索")
        self.B_uppage=Button(self.win,text="上页")
        self.B_nextpage=Button(self.win,text="下页")
        self.B_search=Button(self.win,text="搜索全站")
        self.La_page=Label(self.win,bg="#BFEFFF")
        self.S_croll=Scrollbar(self.win)
        self.L_box=Listbox(self.win,bg="#BFEFFF",selectmode=SINGLE)
        self.E_address=Entry(self.win,textvariable=self.temp)
        self.E_search=Entry(self.win,textvariable=self.search)
        self.label_explain = Label(self.win, fg = 'red', font = ('楷体',12), text = '\n注意:支持大部分主流视频网站的视频播放!\n此软件仅用于交流学习,请勿用于任何商业用途!\n在上面输入框输入现在主流视频网站网页地址\n点击播放弹出浏览器可以解码播放')
        self.label_explain.place(x=10,y=90,width=360,height=90)
        self.La_title.place(x=1,y=50,width=90,height=30)
        self.E_address.place(x=100,y=50,width=200,height=30)
        self.B_play.place(x=310,y=50,width=60,height=30)
        self.La_way.place(x=10,y=10,width=100,height=30)
        self.numberChosen.place(x=120,y=10,width=180,height=30)
        self.E_search.place(x=90,y=200,width=160,height=30)
        self.B_searchSimple.place(x=280,y=200,width=80,height=30)
        self.La_mc.place(x=10,y=200,width=70,height=30)
        self.B_search.place(x=252,y=240,width=100,height=30)
        self.L_box.place(x=10,y=280,width=252,height=230)
        self.S_croll.place(x=260,y=280,width=20,height=230)
        self.B_uppage.place(x=10,y=240,width=50,height=30)
        self.B_nextpage.place(x=180,y=240,width=50,height=30)
        self.La_page.place(x=80,y=240,width=90,height=28)

    def creat_radiores(self):
        self.movie=StringVar()#电影
        self.S_croll2=Scrollbar()#分集
        self.La_pic=Label(self.win,bg="#E6E6FA")
        self.La_movie_message=Listbox(self.win,bg="#7EC0EE")
        self.R_movie=Radiobutton(self.win,text="电影",variable=self.movie,value="m")
        self.tv=Radiobutton(self.win,text="电视剧",variable=self.movie,value="t")
        self.zhongyi=Radiobutton(self.win,text="综艺",variable=self.movie,value="z")
        self.dongman=Radiobutton(self.win,text="动漫",variable=self.movie,value="d")
        self.jilupian=Radiobutton(self.win,text="排行榜",variable=self.movie,value="j")
        self.movie.set('m')
        self.B_view=Button(self.win,text="查看")
        self.B_info=Button(self.win,text="使用说明")
        self.B_clearbox=Button(self.win,text="清空列表")
        self.B_add=Button(self.win,text="打开浏览器观看")
        self.R_movie.place(x=290,y=280,width=80,height=30)
        self.B_view.place(x=290,y=430,width=70,height=30)
        self.B_add.place(x=370,y=255,width=100,height=30)
        self.B_clearbox.place(x=500,y=255,width=70,height=30)
        self.tv.place(x=290,y=310,width=80,height=30)
        self.zhongyi.place(x=290,y=340,width=80,height=30)
        self.dongman.place(x=290,y=370,width=80,height=30)
        self.jilupian.place(x=290,y=400,width=80,height=30)
        self.La_movie_message.place(x=370,y=290,width=200,height=220)
        self.La_pic.place(x=370,y=10,width=200,height=240)
        self.B_info.place(x=290,y=470,width=70,height=30)
        self.S_croll2.place(x=568,y=290,width=20,height=220)

    def show_info(self):
        msg="""
        1.输入视频播放地址,即可播放
          下拉选择可切换视频源
        2.选择视频网,选择电视剧或者电影,
          搜索全网后选择想要看得影片,点
          查看,在右方list里选择分集视频
          添加到播放列表里点选播放
        3.复制网上视频连接
          点击播放即可(VIP视频也可以免费播放)
        4.此软件仅用于交流学习
          请勿用于任何商业用途!
        5.此软件内容来源于互联网
          此软件不承担任何由于内容的合法性及
          健康性所引起的争议和法律责任。
        6.欢迎大家对此软件内容侵犯版权等
          不合法和不健康行为进行监督和举报
        """
        messagebox.showinfo(title="使用说明",message=msg)

    def config(self):
        self.t1.set(True)
        self.B_play.config(command=self.play_url_movie)
        self.B_search.config(command=self.search_full_movie)
        self.B_info.config(command=self.show_info)
        self.S_croll.config(command=self.L_box.yview)
        self.L_box['yscrollcommand']=self.S_croll.set
        self.S_croll2.config(command=self.La_movie_message.yview)
        self.La_movie_message['yscrollcommand']=self.S_croll2.set
        self.B_view.config(command=self.view_movies)
        self.B_add.config(command=self.add_play_list)
        self.B_clearbox.config(command=self.clear_lisbox2)
        self.B_uppage.config(command=self.uppage_)
        self.B_nextpage.config(command=self.nextpage_)
        self.B_searchSimple.config(command=self.searchSimple)

    def uppage_(self):
        print('---------上一页---------')
        self.page-=1
        print(self.page)
        if self.page<1:
            self.page=1
        self.search_full_movie()
    def nextpage_(self):
        print('----------下一页--------')
        self.page+=1
        print(self.page)
        self.search_full_movie()

    def clear_lisbox(self):
        self.L_box.delete(0,END)

    def clear_lisbox2(self):
        self.La_movie_message.delete(0,END)

    def search_full_movie(self):
        print("-----search----")
        self.La_page.config(text="当前页:{}".format(self.page))
        self.clear_lisbox()
        try:
            movie_url, movie_title, movie_src_pic=self.p.get_movie_res(self.t3.get(),self.movie.get(),self.page)
            self.movie_dic={}
            for i,j,k in zip(movie_title,movie_url,movie_src_pic):
                self.movie_dic[i]=[j,k]
            for title in movie_title:
                self.L_box.insert(END,title)
            print(self.movie_dic)
            return self.movie_dic
        except:
            messagebox.showerror(title='警告',message='请选择电影或者电视剧')

    def add_play_list(self):
        print('---------playlist----------')
        # print(self.movie_dic)
        if self.La_movie_message.get(self.La_movie_message.curselection())=="":
            messagebox.showwarning(title="警告",message='请在列表选择影片')
        else:
            print("电影名字:",self.La_movie_message.get(self.La_movie_message.curselection()))
            # self.temp.set('http://www.133kp.com' + self.new_more_dic[self.La_movie_message.get(self.La_movie_message.curselection())])
            webbrowser.open('http://www.133kp.com' + self.new_more_dic[self.La_movie_message.get(self.La_movie_message.curselection())])


    def view_pic(self,pic_url):
        print('--------viewpic---------')
        pa_url_check=r'//.+[.]jpg'
        if re.match(pa_url_check,pic_url):
            print("ok")
            pic_url="http:"+pic_url
        print(pic_url)
        data=requests.get(pic_url).content
        # data=urlopen(pic_url).read()
        io_data=io.BytesIO(data)
        self.img=Image.open(io_data)
        self.u=ImageTk.PhotoImage(self.img)
        self.La_pic.config(image=self.u)

    def view_movies(self):
        print("--------viewmovie----------")
        self.clear_lisbox2()
        cur_index=self.L_box.curselection()
        print(self.L_box.get(cur_index))
        self.new_more_dic=self.p.get_more_tv_urls(self.movie_dic[self.L_box.get(cur_index)][0],self.t3.get(),self.movie.get())
        print(self.new_more_dic)
        for i,fenji_url in self.new_more_dic.items():
            self.La_movie_message.insert(END, i)
        self.view_pic(self.movie_dic[self.L_box.get(self.L_box.curselection())][1])#加载图片

    def play_url_movie(self):
        print("--------ok-----------")
        # print(type(self.t1.get()),self.t1.get())
        if self.temp.get()=="":
            messagebox.showwarning(title="警告",message="请先输入视频地址")
        else:
            if self.numberChosen.get()!="":
                self.p.play_movie(self.temp.get(),self.numberChosen.get())
            else:
                messagebox.showwarning(title='警告',message='请选择通道')
    def searchSimple(self):
        if self.search.get()=="":
            messagebox.showwarning(title="警告",message="请先输入搜索关键字")
        else:    
            self.clear_lisbox()  
            url = 'https://www.133kp.com//index.php?m=vod-search&wd={}'.format(self.search.get())
            res=requests.get(url=url,headers=self.p.header).content.decode('utf-8')
            html=etree.HTML(res)
            movie_size=html.xpath('//input[@class="pagego"]/@size')
            list = [] 
            for s in range(0, int(movie_size[0])):
                url = 'https://www.133kp.com/vod-search-pg-{}-wd-{}.html'.format(s+1,self.search.get())
                list.append(self.p.simpleSearch(url)) 
            # movie_url, movie_title, movie_src_pic=self.p.simpleSearch(self.search.get())
            self.movie_dic={}
            i = 0
            for b in list:
                for i,j,k in zip(b[0],b[1],b[2]):
                    self.movie_dic[i]=[j,re.findall(r'[(](.*?)[)]', k)[0]]
                for title in b[0]:
                    self.L_box.insert(END,title)
            print(self.movie_dic)
Esempio n. 6
0
class App(object):
    def __init__(self):
        self.win = Tk()
        self.win.geometry('400x380')
        self.win.title("网易云mp3播放下载器")
        self.creat_res()
        self.res_config()
        self.win.mainloop()

    def creat_res(self):
        self.mp3_lis = []
        self.temp = StringVar()  # url输入框
        self.temp2 = StringVar()  # id输入框和歌名播放
        self.temp3 = StringVar()  # path 输入框
        self.T_message = Listbox(self.win, background="#EEE9E9")
        self.B_search = Button(self.win, text="搜索")
        self.B_path = Button(self.win, text="选择目录")
        self.E_song = Entry(self.win, textvariable=self.temp)
        self.E_path = Entry(self.win, textvariable=self.temp3)
        self.Play_button = Button(self.win, text="播放")
        self.Pause_button = Button(self.win, text="暂停")
        self.Temp_button = Button(self.win, text="单曲下载")
        self.Info = Button(self.win, text="说明")
        self.More_down = Button(self.win, text="歌单批量下载")
        self.S_bal = Scrollbar(self.win)
        self.L_mp3_name = Label(self.win, text="播放歌曲名")
        self.E_box = Entry(self.win, textvariable=self.temp2)
        self.B_search.place(x=340, y=10, width=50, height=40)
        self.E_song.place(x=10, y=10, width=300, height=35)
        self.T_message.place(x=10, y=165, width=280, height=200)
        self.Play_button.place(x=340, y=190, width=50, height=40)
        self.Pause_button.place(x=340, y=250, width=50, height=40)
        self.E_box.place(x=310, y=95, width=80, height=30)
        self.Temp_button.place(x=310, y=141, width=80, height=30)
        self.S_bal.place(x=286, y=165, width=20, height=200)
        self.E_path.place(x=10, y=70, width=200, height=40)
        self.B_path.place(x=230, y=70, width=60, height=40)
        self.L_mp3_name.place(x=310, y=60, width=80, height=30)
        self.Info.place(x=340, y=300, width=50, height=40)
        self.More_down.place(x=10, y=125, width=100, height=30)

    def res_config(self):
        self.B_search.config(command=self.get_lis)
        self.S_bal.config(command=self.T_message.yview)
        self.T_message["yscrollcommand"] = self.S_bal.set
        self.B_path.config(command=self.choose_path)
        self.More_down.config(command=self.download_music)
        self.Info.config(command=self.show_mesage)
        self.Temp_button.config(command=self.single_music_down)
        self.Play_button.config(command=self.play_music)
        self.Pause_button.config(command=self.pause_music)

    def choose_path(self):
        self.path_ = askdirectory()
        self.temp3.set(self.path_)

    def show_mesage(self):
        msg = "输入框可识别歌单list,或者歌曲名称 '\n'" \
              "输入歌单,请搜索后选择路径和批量下载 '\n'" \
              "搜索单曲后选择id号输入进行下载 '\n'" \
              "播放功能待完善"
        messagebox.showinfo(message=msg, title="使用说明")

    def get_lis(self):  # 搜索按钮,先判断下输入的是url 还是单曲
        flag = music_get.do_something(self.temp.get())
        music_dic = music_get.get_music_id(self.temp.get())
        if self.temp.get() != "":  # 输入框非空
            if flag == True:  # 输入的是链接
                mp3_url = music_get.get_mps_url(self.temp.get())
                for i, j in mp3_url.items():
                    self.T_message.insert(END, "歌曲:" + i + "\n")
                for i in mp3_url.keys():
                    self.mp3_lis.append(i)  # 存储清单歌曲名字,备用
                print(self.mp3_lis)
            else:  # 如果输入的是单曲
                self.T_message.insert(END, "正在查找歌曲:" + self.temp.get() + "\n")
                for id, name in music_dic.items():
                    self.T_message.insert(END,
                                          "找到歌曲:{}-{}".format(id, name) + "\n")
        else:
            self.T_message.insert(END, "清输入歌曲名或者歌单链接:" + "\n")

    def download_music(self):  # 歌单批量下载
        mp3_url = music_get.get_mps_url(self.temp.get())
        music_get.down_mp3(self.temp3.get(), self.temp.get())
        print(self.temp.get(), self.temp3.get())
        for i in mp3_url.keys():
            t = random.randint(100, 300) * 0.01
            self.T_message.insert(END, "正在努力下载歌曲:" + i + "\n")
            time.sleep(t)

    def single_music_down(self):  # 单曲下载
        print("下载单曲")
        flag = music_get.do_something(
            self.temp.get())  # 判断是url 还是歌曲名字 如果是url true 否则f
        mps_dic = music_get.get_music_id(self.temp.get())
        # 首先判断以下 路径存在,输入的是单曲名,输入的是id号
        if os.path.exists(self.temp3.get(
        )) and flag == False and self.temp2.get() in mps_dic.keys():
            music_get.down_music2(self.temp3.get(), self.temp2.get(),
                                  self.temp.get())
            self.T_message.insert(
                END, "正在下载歌曲:" + self.temp.get() + self.temp2.get() + "\n")

    def play_music(self):
        print("播放音乐")
        path = self.temp3.get()  # 路径
        if os.path.exists(path):
            count = 0
            print(os.listdir(self.temp3.get()))
            for mp3 in os.listdir(self.temp3.get()):
                if self.temp2.get() in mp3:  # 如果名字在路径下面
                    song_index = os.listdir(self.temp3.get()).index(mp3)
                    self.T_message.insert(END,
                                          "找到歌曲:" + self.temp2.get() + "\n")
                    path_play = path + "/" + self.temp2.get() + ".mp3"
                    print(path_play)
                    # song=minimu.load(path_play)
                    # song.play()
                    # song.volume(50)
                else:
                    count += 1
            if count == len(os.listdir(self.temp3.get())):
                self.T_message.insert(END, "没找到歌曲:" + self.temp2.get() + "\n")
        else:
            self.T_message.insert(END, "清输入路径:" + "\n")

    def pause_music(self):
        print("暂停播放")
Esempio n. 7
0
'''
from tkinter import Tk
from tkinter.ttk import Style, Scrollbar

root = Tk()
style = Style()
style.theme_use('classic')

style.configure("1st.Horizontal.TScrollbar",
                background="Green",
                troughcolor="lightblue",
                bordercolor="blue",
                arrowsize=20,
                borderwidth=5)

style.configure("2nd.Horizontal.TScrollbar",
                background="Green",
                troughcolor="lightblue",
                bordercolor="blue",
                arrowsize=20)

hs = Scrollbar(root, orient="horizontal", style="1st.Horizontal.TScrollbar")
hs.place(x=5, y=5, width=150)
hs.set(0.2, 0.3)

hs2 = Scrollbar(root, orient="horizontal", style="2nd.Horizontal.TScrollbar")
hs2.place(x=5, y=50, width=150)
hs2.set(0.2, 0.3)

root.mainloop()
Esempio n. 8
0
class Movie_app:
    def __init__(self):
        self.win = Tk()
        self.win.geometry('600x420')
        self.win.title("爱奇艺-优酷-PPTV视频播放下载器V3.1")
        self.creat_res()
        self.creat_radiores()
        self.config()
        self.page = 1
        self.p = Pro()
        self.win.mainloop()

    def creat_res(self):
        self.temp = StringVar()  # url地址
        self.temp2 = StringVar()
        self.t1 = StringVar()  # 通道
        self.t3 = StringVar()  # 爱奇艺,优酷,PPTV
        self.La_title = Label(self.win, text="地址:")
        self.La_way = Label(self.win, text="选择视频通道:")
        self.R_way1 = Radiobutton(self.win,
                                  text="通道A",
                                  variable=self.t1,
                                  value=True)
        self.R_way2 = Radiobutton(self.win,
                                  text="通道B",
                                  variable=self.t1,
                                  value=False)
        self.R_aiqiyi = Radiobutton(self.win,
                                    text="爱奇艺",
                                    variable=self.t3,
                                    value="a")
        self.R_youku = Radiobutton(self.win,
                                   text="优酷",
                                   variable=self.t3,
                                   value="y")
        self.R_pptv = Radiobutton(self.win,
                                  text="PPTV",
                                  variable=self.t3,
                                  value="p")
        self.B_play = Button(self.win, text="播放▶")
        self.B_uppage = Button(self.win, text="上页")
        self.B_nextpage = Button(self.win, text="下页")
        self.B_search = Button(self.win, text="♣搜索全站♠")
        self.La_mesasge = Label(self.win, text="☜  ⇠☸⇢  ☞", bg="pink")
        self.La_page = Label(self.win, bg="#BFEFFF")
        self.S_croll = Scrollbar(self.win)
        self.L_box = Listbox(self.win, bg="#BFEFFF", selectmode=SINGLE)
        self.E_address = Entry(self.win, textvariable=self.temp)
        self.La_title.place(x=10, y=50, width=50, height=30)
        self.E_address.place(x=70, y=50, width=200, height=30)
        self.B_play.place(x=300, y=50, width=50, height=30)
        self.R_way1.place(x=160, y=10, width=70, height=30)
        self.R_way2.place(x=240, y=10, width=70, height=30)
        self.La_way.place(x=10, y=10, width=100, height=30)
        self.R_aiqiyi.place(x=20, y=100, width=70, height=30)
        self.R_youku.place(x=90, y=100, width=70, height=30)
        self.R_pptv.place(x=160, y=100, width=70, height=30)
        self.B_search.place(x=252, y=140, width=100, height=30)
        self.La_mesasge.place(x=80, y=125, width=90, height=20)
        self.L_box.place(x=10, y=180, width=252, height=230)
        self.S_croll.place(x=260, y=180, width=20, height=230)
        self.B_uppage.place(x=10, y=140, width=50, height=30)
        self.B_nextpage.place(x=180, y=140, width=50, height=30)
        self.La_page.place(x=80, y=150, width=90, height=28)

    def creat_radiores(self):
        self.movie = StringVar()  # 电影
        self.S_croll2 = Scrollbar()  # 分集
        self.La_pic = Label(self.win, bg="#E6E6FA")
        self.La_movie_message = Listbox(self.win, bg="#7EC0EE")
        self.R_movie = Radiobutton(self.win,
                                   text="电影",
                                   variable=self.movie,
                                   value="m")
        self.tv = Radiobutton(self.win,
                              text="电视剧",
                              variable=self.movie,
                              value="t")
        self.zhongyi = Radiobutton(self.win,
                                   text="综艺",
                                   variable=self.movie,
                                   value="z")
        self.dongman = Radiobutton(self.win,
                                   text="动漫",
                                   variable=self.movie,
                                   value="d")
        self.jilupian = Radiobutton(self.win,
                                    text="纪录片",
                                    variable=self.movie,
                                    value="j")
        self.B_view = Button(self.win, text="✤查看✤")
        self.B_info = Button(self.win, text="使用说明")
        self.B_clearbox = Button(self.win, text="清空列表")
        self.B_add = Button(self.win, text="添加到播放列表")
        self.R_movie.place(x=290, y=180, width=80, height=30)
        self.B_view.place(x=290, y=330, width=70, height=30)
        self.B_add.place(x=370, y=255, width=100, height=30)
        self.B_clearbox.place(x=500, y=255, width=70, height=30)
        self.tv.place(x=290, y=210, width=80, height=30)
        self.zhongyi.place(x=290, y=240, width=80, height=30)
        self.dongman.place(x=290, y=270, width=80, height=30)
        self.jilupian.place(x=290, y=300, width=80, height=30)
        self.La_movie_message.place(x=370, y=290, width=200, height=120)
        self.La_pic.place(x=370, y=10, width=200, height=240)
        self.B_info.place(x=290, y=370, width=70, height=30)
        self.S_croll2.place(x=568, y=290, width=20, height=120)

    def show_info(self):
        msg = """
        1.输入视频播放地址,即可播放
          选择A或者B可切换视频源
        2.选择视频网,选择电视剧或者电影,
          搜索全网后选择想要看得影片,点
          查看,在右方list里选择分集视频
          添加到播放列表里点选播放
        """
        messagebox.showinfo(title="使用说明", message=msg)

    def config(self):
        self.t1.set(True)
        self.B_play.config(command=self.play_url_movie)
        self.B_search.config(command=self.search_full_movie)
        self.B_info.config(command=self.show_info)
        self.S_croll.config(command=self.L_box.yview)
        self.L_box['yscrollcommand'] = self.S_croll.set
        self.S_croll2.config(command=self.La_movie_message.yview)
        self.La_movie_message['yscrollcommand'] = self.S_croll2.set
        self.B_view.config(command=self.view_movies)
        self.B_add.config(command=self.add_play_list)
        self.B_clearbox.config(command=self.clear_lisbox2)
        self.B_uppage.config(command=self.uppage_)
        self.B_nextpage.config(command=self.nextpage_)

    def uppage_(self):
        print('---------上一页---------')
        self.page -= 1
        print(self.page)
        if self.page < 1:
            self.page = 1

    def nextpage_(self):
        print('----------下一页--------')
        self.page += 1
        print(self.page)
        if self.t3 == "a" or self.t3 == "y":
            if self.page > 30:
                self.page = 30
        elif self.t3 == "p":
            if self.movie == "m":
                if self.page > 165:
                    self.page = 165
            elif self.movie == "t":
                if self.page > 85:
                    self.page = 85
            elif self.movie == "z":
                if self.page > 38:
                    self.page = 38
            elif self.movie == "d":
                if self.page > 146:
                    self.page = 146
            elif self.movie == "j":
                if self.page > 40:
                    self.page = 40

    def clear_lisbox(self):
        self.L_box.delete(0, END)

    def clear_lisbox2(self):
        self.La_movie_message.delete(0, END)

    def search_full_movie(self):
        print("-----search----")
        self.La_page.config(text="当前页:{}".format(self.page))
        self.clear_lisbox()
        try:
            movie_url, movie_title, movie_src_pic = self.p.get_movie_res(
                self.t3.get(), self.movie.get(), self.page)
            self.movie_dic = {}
            for i, j, k in zip(movie_title, movie_url, movie_src_pic):
                self.movie_dic[i] = [j, k]
            for title in movie_title:
                self.L_box.insert(END, title)
            print(self.movie_dic)
            return self.movie_dic
        except:
            messagebox.showerror(title='警告', message='请选择电影或者电视剧')

    def add_play_list(self):
        print('---------playlist----------')
        print(self.movie_dic)
        if self.La_movie_message.get(
                self.La_movie_message.curselection()) == "":
            messagebox.showwarning(title="警告", message='请在列表选择影片')
        else:
            print(
                "电影名字:",
                self.La_movie_message.get(
                    self.La_movie_message.curselection()))
            if self.movie.get() != "m":
                self.temp.set(self.new_more_dic[self.La_movie_message.get(
                    self.La_movie_message.curselection())])
            else:
                self.temp.set(self.movie_dic[self.La_movie_message.get(
                    self.La_movie_message.curselection())][0])

    def view_pic(self, pic_url):
        print('--------viewpic---------')
        pa_url_check = r'//.+[.]jpg'
        if re.match(pa_url_check, pic_url):
            print("ok")
            pic_url = "http:" + pic_url
        print(pic_url)
        data = requests.get(pic_url).content
        # data=urlopen(pic_url).read()
        io_data = io.BytesIO(data)
        self.img = Image.open(io_data)
        self.u = ImageTk.PhotoImage(self.img)
        self.La_pic.config(image=self.u)

    def view_movies(self):
        print("--------viewmovie----------")
        cur_index = self.L_box.curselection()
        print(self.L_box.get(cur_index))
        if self.movie.get() != "m":  # 非电影类
            self.new_more_dic = self.p.get_more_tv_urls(
                self.movie_dic[self.L_box.get(cur_index)][0], self.t3.get(),
                self.movie.get())
            print(self.new_more_dic)
            for i, fenji_url in self.new_more_dic.items():
                self.La_movie_message.insert(END, i)
        else:  # 电影类
            self.La_movie_message.insert(END, self.L_box.get(cur_index))
        self.view_pic(self.movie_dic[self.L_box.get(
            self.L_box.curselection())][1])  # 加载图片

    def play_url_movie(self):
        print("--------ok-----------")
        # print(type(self.t1.get()),self.t1.get())
        if self.temp.get() == "":
            messagebox.showwarning(title="警告", message="请先输入视频地址")
        else:
            if self.t1.get() != "":
                self.p.play_movie(self.temp.get(), self.t1.get())
            else:
                messagebox.showwarning(title='警告', message='请选择通道')
def read_mail_func(username, password, mail):
    email_to = None
    email_content = None
    original_email_content = None
    email_signature_key = None
    html_content = None
    email_attachments = []
    subject = mail["subject"]

    try:
        email_from = re.search("<(.*)>", mail["from"]).group(1)
    except:
        email_from = mail["from"]

    GUI_mail_reader = Tk()
    GUI_mail_reader.title(mail["subject"] if mail["subject"] else "No subject")
    GUI_mail_reader.geometry("720x600")
    GUI_mail_reader.resizable(0, 0)

    # Listbox Labels navigation
    label_sender = Label(GUI_mail_reader, text=f"From: {email_from}")
    label_sender.place(x=20, y=10)

    def event_pressed_decrypt():
        decrypt_func(original_email_content.decode(), email_signature_key)

    def event_pressed_save():
        for file in email_attachments:
            path = os.path.join("C:/Users", os.getlogin(), "Downloads",
                                "Mailex")
            os.makedirs(path, exist_ok=True)
            f = open(os.path.join(path, file["content"]["filename"]), "wb")
            f.write(file["content"]["payload"])
            f.close()

    button_decrypt = Button(GUI_mail_reader,
                            height=1,
                            text="Decrypt",
                            command=event_pressed_decrypt)
    button_decrypt.place(x=120, y=565)

    button_decrypt = Button(GUI_mail_reader,
                            height=1,
                            text="Save all files",
                            command=event_pressed_save)
    button_decrypt.place(x=20, y=565)

    def event_pressed_reply():
        from mail_replier import display_reply_mail

        display_reply_mail(username, password, subject, email_from,
                           email_content.decode())

    def event_pressed_foward():
        from mail_forwarder import display_forward_mail

        display_forward_mail(
            username,
            password,
            subject,
            email_from,
            [email_to if email_to else ""],
            email_content.decode(),
        )

    button_reply = Button(GUI_mail_reader,
                          height=1,
                          text="Reply",
                          command=event_pressed_reply)
    button_reply.place(x=570, y=565)

    button_forward = Button(GUI_mail_reader,
                            height=1,
                            text="Forward",
                            command=event_pressed_foward)
    button_forward.place(x=630, y=565)

    treeview = Treeview(GUI_mail_reader, height=8)
    treeview.place(x=20, y=370)

    vertical_scrollbar = Scrollbar(GUI_mail_reader,
                                   orient="vertical",
                                   command=treeview.yview)
    vertical_scrollbar.place(x=680, y=370)

    treeview.configure(xscrollcommand=vertical_scrollbar.set)
    treeview["columns"] = ("File", "Verified")
    treeview["show"] = "headings"

    treeview.column("File", width=320, anchor="c")
    treeview.column("Verified", width=320, anchor="c")

    treeview.heading("File", text="File")
    treeview.heading("Verified", text="Verified status")

    for content in mail["content"]:
        file_index = 0
        if content["contentType"] == "text/plain":
            email_content = content["payload"]
            original_email_content = content["payload"]

        if content["Signature-Verifier"]:
            email_signature_key = content["Signature-Verifier"]
            if not email_content:
                email_content = email_content[:-512]
            if email_content:
                try:
                    test_hex = bytes.fromhex(email_content[-512:].decode())
                    email_content = email_content[:-512]
                except Exception as e:
                    pass

        if content["filename"]:
            file_index += 1
            attachment = {"content": content, "verified": "Verified"}

            if content["Signature"]:
                try:
                    signature = bytes.fromhex(content["Signature"])
                    pub = RSA.import_key(
                        bytes.fromhex(content["Signature-Verifier"]))
                    public_key = pkcs1_15.new(pub)

                    file = content["payload"]

                    hashed_f = SHA256.new()
                    hashed_f.update(file)

                    public_key.verify(hashed_f, signature)
                    attachment["verified"] = "Valid"

                except Exception as e:
                    print(e)
                    attachment["verified"] = "Invalid"

            else:
                attachment["verified"] = "No signature"

            treeview.insert(
                "",
                "end",
                text=file_index,
                values=(content["filename"], attachment["verified"]),
            )
            email_attachments.append(attachment)

    if not email_content:
        email_content = b"Not supported yet"

    text_message = Text(GUI_mail_reader, wrap="word", width=84, height=20)
    text_message.configure(state=NORMAL)
    text_message.insert(INSERT, email_content.decode(), CHAR)
    text_message.configure(state=DISABLED)
    text_message.place(x=20, y=30)
class WindEdit():
    def __init__(self,root):
        self.root = root
        self.root.config(bg="#2c2f33")
        self.root.title("Portal")
        self.root.geometry("1220x720")
        self.root.iconbitmap('Medical-Management/icone.ico')
        self.root.resizable(0, 0)       
        self.searx = StringVar()
        self.number = StringVar()
        self.city_x = StringVar()
        self.adress_x = StringVar()
        self.wei_x = StringVar()
        self.hei_x = StringVar()
        self.mart_ans = StringVar()
 #=======================================================================================================================       
        self.frame_left = Frame(self.root, width=260, height=720, bg="#23272a").place(x=0,y=0)
        
        self.clck = Label(self.root,text="",font='Helvetica 14',fg="white",bg="#1e2124")
        self.clck.place(x=0, y=20,width=260,height=30) 
        self.update_clock()
                        
        self.label3 = Label(root, text='All work by mr-p-oliveira (⌐■_■), 2021',font='Helvetica 7',
                    fg="#D0D3D4",bg="#1e2124").place(x=0 ,y=700, width=260, height=22)
        
        self.label2 = Label(root,font='Helvetica 7',
                    fg="#D0D3D4",bg="#1e2124").place(x=260 ,y=700, width=960, height=22)        
        
        self.label = Label(root, text='Selected',font='Helvetica 8',
                            fg="#D0D3D4",bg="#1e2124").place(x=0,y=87,width=260,height=13)
        
        self.lf_lbl = Label(root,text="Edit",font='Helvetica 12',fg="white", bg="#005042").place(x=0,y=100,width=260,height=55)  
        
        self.fr_1 = LabelFrame(root,fg="white",bg="#2c2f33").place(x=300,y=100,width=750,height=55)
        self.fr_2 = LabelFrame(root,text=' Record Update ',fg="white",bg="#2c2f33").place(x=300,y=245,width=750,height=100)
 #=======================================================================================================================
        self.srch_lbl = Label(root,text=" Insert :",width=14,font='Helvetica 12',fg="white", bg="#2c2f33").place(x=315,y=116)
        self.srch_ent = Entry(root,font='Helvetica 12',width=16,justify='center',textvariable=self.number)
        self.srch_ent.place(x=445,y=118)
        self.types_serx = ("NHS number","SSC number")
        self.typ_cmbx = Combobox(root, values=self.types_serx,textvariable=self.searx,font='Helvetica 10',width=5,justify='center')
        self.typ_cmbx.place(x=595,y=118,width=115)
        self.typ_cmbx.current(0)
 #=======================================================================================================================
        self.city_lbl = Label(root,text="City :",width=14,font='Helvetica 12',fg="white", bg="#2c2f33").place(x=315,y=275)
        self.city_ent = Entry(root,width=18,font='Helvetica 10',justify='center',textvariable=self.city_x).place(x=405,y=276)
        self.adres_lbl = Label(root,text="Adress :",width=14,font='Helvetica 12',fg="white", bg="#2c2f33").place(x=303,y=305)
        self.adres_ent = Entry(root,width=18,font='Helvetica 10',justify='center',textvariable=self.adress_x).place(x=405,y=307)
        self.mart_lbl =  Label(root,text="Martial Status :",font='Helvetica 11',fg="white", bg="#2c2f33").place(x=565,y=275)
        martial =("Single", "Married", "Widowed", "Divorced", "Separated")
        self.mart_cmb = Combobox(root, values= martial,textvariable=self.mart_ans,font='Helvetica 11',width=10,justify='center')
        self.mart_cmb.place(x=675,y=275)
        self.mart_cmb.current(0)
        self.hei_lbl = Label(root,text="Height :",width=14,font='Helvetica 12',fg="white", bg="#2c2f33").place(x=572,y=305)
        self.hei_ent = Entry(root,width=14,font='Helvetica 10',justify='center',textvariable=self.hei_x).place(x=675,y=307)
        self.wei_lbl = Label(root,text="Weight :",width=14,font='Helvetica 12',fg="white", bg="#2c2f33").place(x=780,y=305)
        self.wei_etn = Entry(root,width=14,font='Helvetica 10',justify='center',textvariable=self.wei_x).place(x=880,y=307)
 #=======================================================================================================================  
        self.srch_btn = Button(root,text="Search",font='Helvetica 12',width=12,fg="white", bg="#005042",command=self.search_reg).place(x=770,y=115)
        self.clr_btn = Button(root,text="Clear",font='Helvetica 12',width=12,fg="white", bg="red",command=self.clear_srch_reg).place(x=900,y=115)
        self.updt_btn = Button(root,text="Update Record",font='Helvetica 12',width=12,fg="white", bg="#005042",command=self.update_reg).place(x=770,y=355)
        self.delet_btn = Button(root,text="Delete Record",font='Helvetica 12',width=12,fg="white", bg="red",command=self.delete_reg).place(x=900,y=355)
 #=======================================================================================================================       
        self.ex_btn = Button(root,text="Exit",font='Helvetica 7',width=10,fg="white", bg="#2c2f33",relief='flat',command=self.ExitApp).place(x=1150,y=700)
        self.bck_btn = Button(root,text="Back",font='Helvetica 12',width=12,fg="white", bg="#005042",command=self.back_win).place(x=1050,y=650)  
 #======================================================TreeView==========================================================
        headings=('Last name','Gender','Birthdate','Blood','Martial status','Weight','Height','Allergies','Doctor')
        self.tree = Treeview(root,columns=("lastnam","gender", "birthdate","city","blood", "martial","weight","height","allerg","doctor"),show='headings', selectmode="extended")
        self.tree.place(x=300,y=170,height=50,width=750)
        for j in range(len(headings)):
            self.tree.column(j,minwidth=100,width=120, stretch=0, anchor=CENTER)
            self.tree.heading(j,text=headings[j])
        self.hscroll = Scrollbar(root,orient=HORIZONTAL,command=self.tree.xview)
        self.hscroll.place(x=300,y=220,width=750)
        self.tree.configure(xscrollcommand=self.hscroll.set)
        self.tree.bind("<Double 1>",self.click_bind)
 #=======================================================================================================================
    def search_reg(self):
        db.connect()
        i = 0
        type = self.searx.get()
        if type == "NHS number":
                self.nhsnumber = self.number.get()
                self.tree.delete(*self.tree.get_children())
                sq4l = "SELECT * FROM pat_reg WHERE nhsnumber='" + self.nhsnumber + "'"
                db_cursor.execute(sq4l)
                rows = db_cursor.fetchall()
                for ro in rows:
                 self.tree.insert("", 'end', text="", values=(ro[2], ro[3], ro[4], ro[12], ro[13], ro[14], ro[15], ro[16], ro[17]))
                db.close()
        else:
                self.sscnumber = self.number.get()
                self.tree.delete(*self.tree.get_children())
                sq5l = "SELECT * FROM pat_reg WHERE sscnumber='"+ self.sscnumber + "'"
                db_cursor.execute(sq5l)
                rows = db_cursor.fetchall()
                for ro in rows:
                 self.tree.insert("", 'end', text="",values=(ro[2], ro[3], ro[4], ro[12], ro[13], ro[14], ro[15], ro[16], ro[17]))
                db.close()        
    def clear_srch_reg(self):
        self.tree.delete(*self.tree.get_children())
        self.srch_ent.delete(0, 'end') 
        self.city_x.set(' ')
        self.adress_x.set(' ')
        self.wei_x.set(' ')
        self.hei_x.set(' ')
        
    def click_bind(self,e):
        db.connect()
        self.numb = self.number.get()
        sq6l = "SELECT * FROM pat_reg WHERE sscnumber='"+ self.numb + "' OR nhsnumber='" + self.numb + "'"
        db_cursor.execute(sq6l)
        rows = db_cursor.fetchall()
        for ro in rows:
                self.city_x.set(ro[6])
                self.adress_x.set(ro[5])
                self.wei_x.set(ro[14])
                self.hei_x.set(ro[15])
    def update_reg(self):
        city = self.city_x.get()
        adress = self.adress_x.get()
        weight = self.wei_x.get()
        height = self.hei_x.get()
        martial = self.mart_ans.get()
        if adress == "" or city == "" or height == "" or weight == "":
              messagebox.showinfo('Information','Please Fill All Fields')
        else:
         db.connect()
         sq6l = "UPDATE pat_reg set adress =%s, city=%s, weight=%s, height=%s, martial =%s WHERE sscnumber=%s OR nhsnumber=%s"
         val = (adress, city, weight, height, martial, self.numb, self.numb)
         db_cursor.execute(sq6l,val)
         db.commit()
         messagebox.showinfo('Information','Patient Record Updated')
         db.close()
         self.clear_srch_reg()
    def delete_reg(self):
        self.delet_mess = messagebox.askquestion("Confirm", "Do You Want to Delete this Record",icon = 'warning')
        if self.delet_mess == 'yes' :
                db.connect()
                sq7l = "DELETE FROM pat_reg WHERE sscnumber=%s OR nhsnumber=%s"
                val = (self.numb,self.numb)
                db_cursor.execute(sq7l,val)
                db.commit()
                db.close()
                messagebox.showinfo('Complete','Patient Record ' + str(self.numb) + ' Deleted')
                self.clear_srch_reg()
        else:
                messagebox.showinfo('Return','You will now return to the application screen')
        
            
 #=======================================================================================================================
    def ExitApp(self):
         self.ExitApp = tkinter.messagebox.askquestion ('Exit Portal','Are you sure you want to exit the application. ( Your data is automatically saved )',icon = 'warning')
         if self.ExitApp == 'yes':
            root.destroy()
         else:
            messagebox.showinfo('Return','You will now return to the application screen')
           
    def update_clock(self):
        now = time.strftime("%d %b %Y ,%H:%M:%S")
        self.clck.configure(text=now)
        self.clck.after(1000, self.update_clock)  
        
    def back_win(self):
        self.root.withdraw()
        self.newWindow = Toplevel(self.root)
        self.app = Window1(self.newWindow)       
class Windsearch():
    def __init__(self,root):
        self.root = root
        self.root.config(bg="#2c2f33")
        self.root.title("Portal")
        self.root.geometry("1220x720")
        self.root.iconbitmap('Medical-Management/icone.ico')
        self.root.resizable(0, 0)       
        self.searx = StringVar()
        self.number = StringVar()
 #=======================================================================================================================       
        self.frame_left = Frame(self.root, width=260, height=720, bg="#23272a").place(x=0,y=0)
        
        self.clck = Label(self.root,text="",font='Helvetica 14',fg="white",bg="#1e2124")
        self.clck.place(x=0, y=20,width=260,height=30) 
        self.update_clock()
                        
        self.label3 = Label(root, text='All work by mr-p-oliveira (⌐■_■), 2021',font='Helvetica 7',
                    fg="#D0D3D4",bg="#1e2124").place(x=0 ,y=700, width=260, height=22)
        
        self.label2 = Label(root,font='Helvetica 7',
                    fg="#D0D3D4",bg="#1e2124").place(x=260 ,y=700, width=960, height=22)        
        
        self.label = Label(root, text='Selected',font='Helvetica 8',
                            fg="#D0D3D4",bg="#1e2124").place(x=0,y=87,width=260,height=13)
        
        self.lf_lbl = Label(root,text="Search",font='Helvetica 12',fg="white", bg="#005042").place(x=0,y=100,width=260,height=55)  
        
        self.fr_1 = LabelFrame(root,fg="white",bg="#2c2f33").place(x=300,y=100,width=750,height=55)
 #=======================================================================================================================
        self.srch_lbl = Label(root,text=" Insert :",width=14,font='Helvetica 12',fg="white", bg="#2c2f33").place(x=315,y=116)
        self.srch_ent = Entry(root,font='Helvetica 12',width=16,justify='center',textvariable=self.number)
        self.srch_ent.place(x=445,y=118)
        self.types_serx = ("NHS number","SSC number")
        self.typ_cmbx = Combobox(root, values=self.types_serx,textvariable=self.searx,font='Helvetica 10',width=5,justify='center')
        self.typ_cmbx.place(x=595,y=118,width=115)
        self.typ_cmbx.current(0)
 #=======================================================================================================================  
        self.srch_btn = Button(root,text="Search",font='Helvetica 12',width=12,fg="white", bg="#005042",command=self.search_reg).place(x=770,y=115)
        self.clr_btn = Button(root,text="Clear",font='Helvetica 12',width=12,fg="white", bg="red",command=self.clear_srch_reg).place(x=900,y=115)
 #=======================================================================================================================       
        self.but_ex = Button(root,text="Exit",font='Helvetica 7',width=10,fg="white", bg="#2c2f33",relief='flat',command=self.ExitApp).place(x=1150,y=700)
        self.bck_btn = Button(root,text="Back",font='Helvetica 12',width=12,fg="white", bg="#005042",command=self.back_win).place(x=1050,y=650)  
 #=======================================================================================================================
        headings=('Last name','Gender','Birthdate','Blood','Martial status','Weight','Height','Allergies','Doctor')
        self.tree = Treeview(root,columns=("lastnam","gender", "birthdate","city","blood", "martial","weight","height","allerg","doctor"),show='headings', selectmode="extended")
        self.tree.place(x=300,y=170,height=50,width=750)
        for j in range(len(headings)):
            self.tree.column(j,minwidth=100,width=120, stretch=0, anchor=CENTER)
            self.tree.heading(j,text=headings[j])
 #=======================================================================================================================
        self.hscroll = Scrollbar(root,orient=HORIZONTAL,command=self.tree.xview)
        self.hscroll.place(x=300,y=220,width=750)
        self.tree.configure(xscrollcommand=self.hscroll.set)
 #=======================================================================================================================
    def search_reg(self):
        db.connect()
        i = 0
        type = self.searx.get()
        if type == "NHS number":
                nhsnumber = self.number.get()
                self.tree.delete(*self.tree.get_children())
                sq4l = "SELECT * FROM pat_reg WHERE nhsnumber='" + nhsnumber + "'"
                db_cursor.execute(sq4l)
                rows = db_cursor.fetchall()
                for ro in rows:
                 self.tree.insert("", 'end', text="", values=(ro[2], ro[3], ro[4], ro[12], ro[13], ro[14], ro[15], ro[16], ro[17]))
                db.close()
        else:
                sscnumber = self.number.get()
                self.tree.delete(*self.tree.get_children())
                sq5l = "SELECT * FROM pat_reg WHERE sscnumber='"+ sscnumber + "'"
                db_cursor.execute(sq5l)
                rows = db_cursor.fetchall()
                for ro in rows:
                 self.tree.insert("", 'end', text="",values=(ro[2], ro[3], ro[4], ro[12], ro[13], ro[14], ro[15], ro[16], ro[17]))
                db.close()        
    def clear_srch_reg(self):
        self.tree.delete(*self.tree.get_children())
        self.srch_ent.delete(0, 'end')
 #=======================================================================================================================
    def ExitApp(self):
         self.ExitApp = tkinter.messagebox.askquestion ('Exit Portal','Are you sure you want to exit the application. ( Your data is automatically saved )',icon = 'warning')
         if self.ExitApp == 'yes':
            root.destroy()
         else:
            messagebox.showinfo('Return','You will now return to the application screen')
           
    def update_clock(self):
        now = time.strftime("%d %b %Y ,%H:%M:%S")
        self.clck.configure(text=now)
        self.clck.after(1000, self.update_clock)  
        
    def back_win(self):
        self.root.withdraw()
        self.newWindow = Toplevel(self.root)
        self.app = Window1(self.newWindow)   
class Windallreg2():
    def __init__(self,root):
        self.root = root
        self.root.config(bg="#2c2f33")
        self.root.title("Portal")
        self.root.geometry("1220x720")
        self.root.iconbitmap('Medical-Management/icone.ico')
        self.root.resizable(0, 0)       
 #=============================================================================================================        
        self.frame_left = Frame(self.root, width=260, height=720, bg="#23272a").place(x=0,y=0)
        
        self.clck = Label(self.root,text="",font='Helvetica 14',fg="white",bg="#1e2124")
        self.clck.place(x=0, y=20,width=260,height=30) 
        self.update_clock()
                        
        self.label3 = Label(root, text='All work by mr-p-oliveira (⌐■_■), 2021',font='Helvetica 7',
                    fg="#D0D3D4",bg="#1e2124").place(x=0 ,y=700, width=260, height=22)
        
        self.label2 = Label(root,font='Helvetica 7',
                    fg="#D0D3D4",bg="#1e2124").place(x=260 ,y=700, width=960, height=22)        
        
        self.label = Label(root, text='Selected',font='Helvetica 8',
                            fg="#D0D3D4",bg="#1e2124").place(x=0,y=87,width=260,height=13)
        
        self.lf_lbl = Label(root,text="Search",font='Helvetica 12',fg="white", bg="#005042").place(x=0,y=100,width=260,height=55)  
 #=======================================================================================================================
        i = 0
        db.connect()
        
        self.tree = Treeview(root,columns=("firstnam" , "lastnam" , "gender", "birthdate", "adress", "city", "zipcod", "phone", "email", "sscnumber", "nhsnumber", "blood", "martial","weight","height","allerg", "doctor"),show='headings', selectmode="extended")
        self.tree.place(x=295,y=70,height=450,width=900)

        headings=('First name','Last name','Gender','Birthdate','Adress','City','Zipcode', 'Phone','Email','Social','NHS','Blood','Martial status','Weight','Height','Allergies','Doctor') 
        sq2l = ("SELECT * FROM pat_reg")
        db_cursor.execute(sq2l)
        for j in range(len(headings)):
            self.tree.column(j,minwidth=100,width=120, stretch=0, anchor=CENTER)
            self.tree.heading(j,text=headings[j])
        for ro in db_cursor:
            self.tree.insert('', i, text="",values=(ro[1], ro[2], ro[3], ro[4], ro[5], ro[6], ro[7], ro[8], ro[9], ro[10], ro[11], ro[12], ro[13], ro[14], ro[15], ro[16], ro[17]))
            i+=1
        db.close()

        self.vscroll = Scrollbar(root,orient=VERTICAL,command=self.tree.yview)
        self.vscroll.place(x=1195,y=70,height=450)
        self.hscroll = Scrollbar(root,orient=HORIZONTAL,command=self.tree.xview)
        self.hscroll.place(x=295,y=500,width=900)

        self.tree.configure(xscrollcommand=self.hscroll.set,yscrollcommand=self.vscroll.set)
 #=======================================================================================================================         
        self.but_ex = Button(root,text="Exit",font='Helvetica 7',width=10,fg="white", bg="#2c2f33",relief='flat',command=self.ExitApp).place(x=1150,y=700)
        self.bck_btn = Button(root,text="Back",font='Helvetica 12',width=12,fg="white", bg="#005042",command=self.back_win).place(x=1050,y=650)  
 #=======================================================================================================================
    def ExitApp(self):
         self.ExitApp = tkinter.messagebox.askquestion ('Exit Portal','Are you sure you want to exit the application. ( Your data is automatically saved )',icon = 'warning')
         if self.ExitApp == 'yes':
            root.destroy()
         else:
            messagebox.showinfo('Return','You will now return to the application screen')
           
    def update_clock(self):
        now = time.strftime("%d %b %Y ,%H:%M:%S")
        self.clck.configure(text=now)
        self.clck.after(1000, self.update_clock)  
        
    def back_win(self):
        self.root.withdraw()
        self.newWindow = Toplevel(self.root)
        self.app = Windview(self.newWindow)        
Esempio n. 13
0
class App_test(object):
    def __init__(self):
        self.win = Tk()
        self.win.title('12306火车票查询系统V2.6')
        self.win.geometry('860x400')
        self.creat_res()
        self.add_train_info()
        self.add_check_button()
        self.res_config()
        self.train_message = {}
        # self.get_train_args()
        self.win.mainloop()

    def creat_res(self):
        self.v = IntVar()  #车票查询
        self.v.set(True)
        self.temp = StringVar()  #开始站
        self.temp2 = StringVar()  #目的站
        self.start_mon = StringVar()  #出发月
        self.start_day = StringVar()  #出发日
        self.start_year = StringVar()  #出啊年
        self.E_startstation = Entry(self.win, textvariable=self.temp)
        self.E_endstation = Entry(self.win, textvariable=self.temp2)
        self.La_startstation = Label(self.win, text="出发站:")
        self.La_endstation = Label(self.win, text="目的站:")
        self.La_time = Label(self.win, text="请选择出发时间-年-月-日", fg="blue")
        self.B_search = Button(self.win, text="搜索")
        self.R_site = Radiobutton(self.win,
                                  text="车票查询",
                                  variable=self.v,
                                  value=True)
        self.R_price = Radiobutton(self.win,
                                   text="票价查询",
                                   variable=self.v,
                                   value=False)
        self.B_buy_tick = Button(self.win, text="购票")
        self.C_year = Combobox(self.win, textvariable=self.start_year)
        self.C_mon = Combobox(self.win, textvariable=self.start_mon)
        self.La_s = Label(self.win, text="--")
        self.C_day = Combobox(self.win, textvariable=self.start_day)
        self.S_move = Scrollbar(self.win)
        self.E_startstation.place(x=70, y=10, width=65, height=30)
        self.E_endstation.place(x=70, y=60, width=65, height=30)
        self.La_startstation.place(x=10, y=10, width=50, height=30)
        self.La_endstation.place(x=10, y=60, width=50, height=30)
        self.La_time.place(x=10, y=100, width=150, height=30)
        self.C_year.place(x=10, y=140, width=70, height=30)
        self.C_mon.place(x=100, y=140, width=50, height=30)
        self.C_day.place(x=100, y=180, width=50, height=30)
        self.La_s.place(x=80, y=140, width=20, height=30)
        self.B_search.place(x=10, y=180, width=50, height=30)
        self.S_move.place(x=834, y=40, width=30, height=350)
        self.B_buy_tick.place(x=10, y=260, width=80, height=40)
        self.R_site.place(x=10, y=230, width=70, height=30)
        self.R_price.place(x=90, y=230, width=70, height=30)

    def res_config(self):
        self.C_year.config(values=[x for x in range(2018, 2020)])
        self.C_mon.config(values=["{:02d}".format(x)
                                  for x in range(1, 13)])  #时间格式是2018-01-01
        self.C_day.config(values=["{:02d}".format(x) for x in range(1, 32)])
        self.B_search.config(command=self.search_train_message)
        self.S_move.config(command=self.tree.yview)
        self.tree.config(yscrollcommand=self.S_move.set)

    def add_train_info(self):
        lis_train = ["C" + str(x) for x in range(0, 15)]
        tuple_train = tuple(lis_train)
        self.tree = Treeview(self.win,
                             columns=tuple_train,
                             height=30,
                             show="headings")
        self.tree.place(x=168, y=40, width=670, height=350)
        train_info = [
            ' 车次 ', ' 出发/到达站', '出发/到达时间', '历时 ', '商/特座', '一等座', '二等座', '高软',
            '软卧', '动卧', '硬卧', '软座', '硬座', '无座', '其他'
        ]
        for i in range(0, len(lis_train)):
            self.tree.column(lis_train[i],
                             width=len(train_info[i]) * 11,
                             anchor='center')
            self.tree.heading(lis_train[i], text=train_info[i])

    def add_check_button(self):
        self.v1 = IntVar()
        self.v2 = IntVar()
        self.v3 = IntVar()
        self.v4 = IntVar()
        self.v5 = IntVar()
        self.v6 = IntVar()
        self.v7 = IntVar()
        self.v1.set("T")
        self.Check_total = Checkbutton(self.win,
                                       text="全部车次",
                                       variable=self.v1,
                                       onvalue='T')
        self.Check_total.place(x=168, y=7, width=80, height=30)
        self.Check_total = Checkbutton(self.win,
                                       text="G-高铁",
                                       variable=self.v2,
                                       onvalue='T')
        self.Check_total.place(x=258, y=7, width=70, height=30)
        self.Check_total = Checkbutton(self.win,
                                       text="D-动车",
                                       variable=self.v3,
                                       onvalue='T')
        self.Check_total.place(x=348, y=7, width=60, height=30)
        self.Check_total = Checkbutton(self.win,
                                       text="Z-直达",
                                       variable=self.v4,
                                       onvalue='T')
        self.Check_total.place(x=418, y=7, width=60, height=30)
        self.Check_total = Checkbutton(self.win,
                                       text="T-特快",
                                       variable=self.v5,
                                       onvalue='T')
        self.Check_total.place(x=488, y=7, width=60, height=30)
        self.Check_total = Checkbutton(self.win,
                                       text="K-快速",
                                       variable=self.v6,
                                       onvalue='T')
        self.Check_total.place(x=568, y=7, width=60, height=30)
        self.Check_total = Checkbutton(self.win,
                                       text="其他",
                                       variable=self.v7,
                                       onvalue='T')
        self.Check_total.place(x=648, y=7, width=60, height=30)

    def get_train_args(self):  #输出获得的日期,出发站代码,目的站代码
        date = self.start_year.get() + "-" + self.start_mon.get(
        ) + "-" + self.start_day.get()
        start_station = self.temp.get()
        end_station = self.temp2.get()
        start_station_str = ""
        end_station_str = ""
        count1, count2 = 0, 0
        with open("res/dict2.txt", mode='r', encoding='utf-8') as f:
            mes = f.readlines()
            for i in mes:
                d = json.loads(i)
                if start_station in d:
                    start_station_str = d[start_station]
                else:
                    count1 += 1
                if end_station in d:
                    end_station_str = d[end_station]
                else:
                    count2 += 1
            if count1 == len(mes) or count2 == len(mes):
                messagebox.showwarning(title="友情提示", message="无法找到车站数据")
        return date, start_station_str, end_station_str

    def is_leapyear(self):
        #先判断输入是否是日期,如果是日期执行方法体,
        a = self.C_year.get()
        b = self.C_mon.get()
        c = self.C_day.get()
        pa_year = '20[\d][\d]'  # 2018
        if re.compile(pa_year).findall(a) and b in [
                "{:02d}".format(x) for x in range(1, 13)
        ] and c in ["{:02d}".format(x) for x in range(1, 32)]:
            nowtime = time.localtime()
            now_time_sp = time.mktime(nowtime)
            start_time = a + "-" + b + "-" + c + " 23:59:29"  #"2018-08-09  23:59:29"
            start_timestrip = time.strptime(start_time, "%Y-%m-%d %H:%M:%S")
            start_times = time.mktime(start_timestrip)
            days = (start_times - now_time_sp) / 60 / 60 / 24
            print(days)
            print(a, b, c)
            if days > 29:
                messagebox.showerror(title="警告", message="大于30天无法获取数据")
            elif days < 0:
                messagebox.showerror(title="警告", message="小于1天无法获取数据")
            elif days > 0 and days < 30:
                if int(a) % 4 == 0 and int(a) % 100 != 0 or int(
                        a) % 400 == 0:  #如果是闰年
                    if (int(b) in (1, 3, 5, 7, 8, 10, 12) and int(c) > 31) or (
                        (int(b) in (4, 6, 9, 11)
                         and int(c) > 30)) or (int(b) == 2 and int(c) > 29):
                        messagebox.showerror(title="警告", message="你确定这个月有这一天么")
                else:
                    if (int(b) in (1, 3, 5, 8, 10, 12) and int(c) > 31) or (
                        (int(b) in (4, 6, 9, 11)
                         and int(c) > 30)) or (int(b) == 2 and int(c) > 28):
                        messagebox.showerror(title="警告", message="你确定这个月有这一天么")
        else:
            messagebox.showerror(title="警告", message="请输入正确格式的年:月:日")

    def manage_date(self):  #处理时间,闰年以及当天时间
        self.is_leapyear()

    def change_str(self, mm):
        for i, j in mm.items():
            with open("res/dict.txt", mode='r', encoding='utf-8') as f:
                mes = f.readlines()
                for s in mes:
                    d = json.loads(s)
                    if j[0] in d:
                        j[0] = d[j[0]]
                    if j[1] in d:
                        j[1] = d[j[1]]
        # print(self.new_train_message) #车次信息
        non_empty_str = ['']
        for m, n in mm.items():
            mm[m] = ['-' if x in non_empty_str else x for x in n]  # 替换''字符为'-'
        return mm

    def trans_train_dic(self):  #输出出发站-目的站-名字
        date, start_station, end_station = self.get_train_args()
        print(date, start_station, end_station)
        try:
            p = Pro_train(date, start_station, end_station)
            self.train_message = p.get_train_res()  # 获得车次信息字典 车次英文
            self.train_tick = p.get_tarin_ticket()  #获得票价信息
            # print(self.train_message) #车次信息
            self.new_train_message = self.train_message  #复制一份
            self.new_train_tick = self.train_tick
            self.new_train_message = self.change_str(self.new_train_message)
            self.new_train_tick = self.change_str(self.new_train_tick)
            return self.new_train_message, self.new_train_tick  # 中文字典
        except Exception as e:
            # messagebox.showerror(title="警告",message="无法解析数据,请重新选择")
            print("错误码:", e.args)

    def search_train_message(self):
        self.manage_date()  #处理日期-True-transe-view
        if self.v.get():
            self.view_list()
        else:
            self.view_price()

    def clear_tree(self):
        x = self.tree.get_children()
        for n in x:
            self.tree.delete(n)

    def view_list(self):  #显示到网格
        # 车次 出发/站 出发到达时间 历时 商务座31  一等座30 二等座29  高软20 软卧22 动卧 硬卧27 软座23 硬座28 无座25 其他21
        try:
            self.clear_tree()
            self.new_train_message, x = self.trans_train_dic()  #生成新车次字典
            for i, j in self.new_train_message.items():
                self.tree.insert("",
                                 "end",
                                 values=(i, j[0] + "->" + j[1],
                                         j[2] + "->" + j[3], j[4], j[5], j[6],
                                         j[7], j[8], j[9], j[10], j[11], j[12],
                                         j[13], j[14], j[15]))
        except Exception as e:
            # messagebox.showerror(title="警告",message="无法处理数据")
            print("错误:", e.args)

    def view_price(self):
        print("-------票价ok-------")
        try:
            self.clear_tree()
            y, self.new_train_tick = self.trans_train_dic()  #生成新车次字典
            for i, j in self.new_train_tick.items():
                self.tree.insert("",
                                 "end",
                                 values=(i, j[0] + "->" + j[1],
                                         j[2] + "->" + j[3], j[4], j[5], j[6],
                                         j[7], j[8], j[9], j[10], j[11], j[12],
                                         j[13], j[14], "-"))
        except Exception as e:
            # messagebox.showerror(title="警告",message="无法处理数据")
            print("错误:", e.args)
Esempio n. 14
0
from tkinter.ttk import Style, Scrollbar

root = Tk()
style = Style()
style.theme_use('classic')
test_size = font.Font(family="Times", size=12, weight="bold").measure('Test')
mult = int(test_size / 30)

style.configure("1st.Horizontal.TScrollbar",
                background="Green",
                troughcolor="lightblue",
                bordercolor="blue",
                arrowsize=20 * mult,
                borderwidth=5)

style.configure("2nd.Horizontal.TScrollbar",
                background="Green",
                troughcolor="lightblue",
                bordercolor="blue",
                arrowsize=20 * mult)

hs = Scrollbar(root, orient="horizontal", style="1st.Horizontal.TScrollbar")
hs.place(x=5 * mult, y=5 * mult, width=150 * mult)
hs.set(0.2, 0.3)

hs2 = Scrollbar(root, orient="horizontal", style="2nd.Horizontal.TScrollbar")
hs2.place(x=5 * mult, y=50 * mult, width=150 * mult)
hs2.set(0.2, 0.3)

root.mainloop()
Esempio n. 15
0
class App_test(object):
    def __init__(self, master, fuc, query, next, pre):
        self.win = master
        self.win.title('笔趣阁阅读_v1.0   by: 孤月')
        self.win.iconbitmap('./ico/gui_text_proce.ico')  # 指定界面图标
        curWidth = self.win.winfo_width()
        curHeight = self.win.winfo_height()
        scnWidth, scnHeight = self.win.maxsize()
        tmpcnf = '1340x640+500+300'  # % ((scnWidth - curWidth) / 2, (scnHeight - curHeight) / 2)
        self.win.geometry(tmpcnf)
        self.creat_res()
        self.set_position()
        self.add_train_info()
        self.res_config(fuc, query, next, pre)
        self.train_message = {}
        self.gettime()  # 系统时间

    def creat_res(self):
        self.v = IntVar()  # 书籍查询
        self.v.set(True)
        self.temp = StringVar()  # 书名/作者 录入
        self.temp2 = StringVar()  # 章节名录入
        self.sys_time = StringVar()  # 系统时间

        self.E_startstation = Entry(self.win, textvariable=self.temp)
        self.E_endstation = Entry(self.win, textvariable=self.temp2)

        self.La_startstation = Label(self.win, text="根据书名/作者搜索:")
        self.La_endstation = Label(self.win, text="根据章节名搜索:")
        self.La_directory = Label(self.win, text="目录")
        self.La_text = Label(self.win, text="正文")
        self.La_sys_time = Label(self.win, textvariable=self.sys_time, fg='blue', font=("黑体", 20))  # 设置字体大小颜色

        self.B_search = Button(self.win, text="搜索")
        self.B_buy_tick = Button(self.win, text="阅读")
        self.B_pre_chapter = Button(self.win, text="上一章")
        self.B_next_chapter = Button(self.win, text="下一章")

        self.R_site = Radiobutton(self.win, text="书名查询", variable=self.v, value=True)
        self.R_price = Radiobutton(self.win, text="章节查询", variable=self.v, value=False)

        self.init_data_Text = Text(self.win)  # 原始数据录入框
        self.S_move = Scrollbar(self.win)  # 目录滚动条
        self.S_text_move = Scrollbar(self.win)  # 创建文本框滚动条

    # 设置位置
    def set_position(self):
        self.init_data_Text.place(x=430, y=40, width=870, height=550)
        self.E_startstation.place(x=10, y=50, width=145, height=30)
        self.E_startstation.insert(10, "星辰变")
        self.E_endstation.place(x=10, y=140, width=145, height=30)
        self.E_endstation.insert(10, "第一章 秦羽")
        self.La_startstation.place(x=10, y=10, width=130, height=30)
        self.La_endstation.place(x=10, y=100, width=120, height=30)
        self.La_sys_time.place(x=1150, y=600, width=160, height=30)
        self.B_search.place(x=10, y=220, width=80, height=40)
        self.B_pre_chapter.place(x=950, y=600, width=80, height=40)
        self.B_next_chapter.place(x=1050, y=600, width=80, height=40)
        self.S_move.place(x=380, y=40, width=30, height=550)
        self.S_text_move.place(x=1300, y=40, width=30, height=550)
        self.B_buy_tick.place(x=90, y=220, width=80, height=40)
        self.R_site.place(x=10, y=180, width=90, height=30)
        self.R_price.place(x=100, y=180, width=90, height=30)
        self.La_directory.place(x=180, y=7, width=90, height=30)
        self.La_text.place(x=420, y=7, width=70, height=30)

    # 为按钮绑定事件
    def res_config(self, fuc, query, next_, pre):
        self.B_search.config(command=fuc)  # 搜索
        self.B_buy_tick.config(command=query)  # 阅读
        self.B_pre_chapter.config(command=pre)  # 上一章
        self.B_next_chapter.config(command=next_)  # 下一章
        self.S_move.config(command=self.tree.yview)  # 目录滚动条
        self.tree.config(yscrollcommand=self.S_move.set)
        self.S_text_move.config(command=self.init_data_Text.yview)  # 文本框滚动条
        self.init_data_Text.config(yscrollcommand=self.S_text_move.set)

    def add_train_info(self):
        lis_train = ["C" + str(x) for x in range(0, 2)]
        tuple_train = tuple(lis_train)
        self.tree = Treeview(self.win, columns=tuple_train, height=30, show="headings")
        self.tree.place(x=200, y=40, width=180, height=550)
        train_info = [' 书名 ', ' 作者 ']
        for i in range(0, len(lis_train)):
            self.tree.column(lis_train[i], width=len(train_info[i]) * 11,
                             anchor='w')  # must be n, ne, e, se, s, sw, w, nw, or center
            self.tree.heading(lis_train[i], text=train_info[i])

    # 实时显示时钟
    def gettime(self):
        # 获取当前时间
        self.sys_time.set(time.strftime("%H:%M:%S"))
        # 每隔一秒调用函数自身获取时间
        self.win.after(1000, self.gettime)
Esempio n. 16
0
        def buat_table(self):
            application.set_gui.table = Treeview(
                self.root,
                columns=("nomer_regis", "terbit", "nama", "merk", "kemasan",
                         "produsen", "lokasi"),
                height=10)

            # membuat tombol scrol atas ke bawah
            ybs = Scrollbar(self.root,
                            orient='vertical',
                            command=application.set_gui.table.yview)
            application.set_gui.table.configure(
                yscroll=ybs.set)  # setting scroll bal vertical
            ybs.place(x=1190, y=150, height=222)

            # membuat tombol utuk scrol kanan ke kiri
            xbs = Scrollbar(self.root,
                            orient='horizontal',
                            command=application.set_gui.table.xview)
            application.set_gui.table.configure(xscroll=xbs.set)
            xbs.place(x=10, y=371, width=1180)

            application.set_gui.table.configure()

            # setting header table

            # setting column id
            application.set_gui.table.heading('#0', text='ID')
            application.set_gui.table.column('#0', minwidth=40, width=40)

            # setting column nomer_regis
            application.set_gui.table.heading('nomer_regis',
                                              text='Nomer Regristasi')
            application.set_gui.table.column('nomer_regis',
                                             minwidth=150,
                                             width=150)

            # setting column terbit
            application.set_gui.table.heading('terbit', text="Tgl Terbit")
            application.set_gui.table.column('terbit', minwidth=100, width=100)

            # setting column nama
            application.set_gui.table.heading('nama', text='Nama Produk')
            application.set_gui.table.column('nama', minwidth=300, width=300)

            # setting column merk
            application.set_gui.table.heading('merk', text='Merk')
            application.set_gui.table.column('merk', minwidth=150, width=150)

            # setting column kemasan
            application.set_gui.table.heading('kemasan', text='Kemasan')
            application.set_gui.table.column('kemasan',
                                             minwidth=150,
                                             width=150)

            # setting column produsen
            application.set_gui.table.heading('produsen', text='Produsen')
            application.set_gui.table.column('produsen',
                                             minwidth=150,
                                             width=150)

            # setting column lokasi
            application.set_gui.table.heading('lokasi', text='Lokasi')
            application.set_gui.table.column('lokasi', minwidth=150, width=150)

            application.set_gui.table.place(x=10, y=150)
Esempio n. 17
0
class Movie_app:
    def __init__(self):
        self.win = Tk()
        self.win.geometry('600x420')
        self.win.title(" VIP视频破解工具")
        self.creat_res()
        self.creat_radiores()
        self.config()
        self.page = 1
        self.p = Pro()
        self.win.mainloop()

    def creat_res(self):
        #Menu菜单
        menu = tk.Menu(self.win)
        self.win.config(menu=menu)
        moviemenu = tk.Menu(menu, tearoff=0)
        menu.add_cascade(label='友情链接', menu=moviemenu)
        downmenu = tk.Menu(menu, tearoff=0)
        #各个网站链接
        moviemenu.add_command(
            label='网易公开课',
            command=lambda: webbrowser.open('http://open.163.com/'))
        moviemenu.add_command(
            label='腾讯视频', command=lambda: webbrowser.open('http://v.qq.com/'))
        moviemenu.add_command(
            label='搜狐视频',
            command=lambda: webbrowser.open('http://tv.sohu.com/'))
        moviemenu.add_command(
            label='芒果TV',
            command=lambda: webbrowser.open('http://www.mgtv.com/'))
        moviemenu.add_command(
            label='爱奇艺',
            command=lambda: webbrowser.open('http://www.iqiyi.com/'))
        moviemenu.add_command(
            label='PPTV',
            command=lambda: webbrowser.open('http://www.bilibili.com/'))
        moviemenu.add_command(
            label='优酷',
            command=lambda: webbrowser.open('http://www.youku.com/'))
        moviemenu.add_command(
            label='乐视', command=lambda: webbrowser.open('http://www.le.com/'))
        moviemenu.add_command(
            label='土豆',
            command=lambda: webbrowser.open('http://www.tudou.com/'))
        moviemenu.add_command(
            label='A站',
            command=lambda: webbrowser.open('http://www.acfun.tv/'))
        moviemenu.add_command(
            label='B站',
            command=lambda: webbrowser.open('http://www.bilibili.com/'))

        self.temp = StringVar()  #url地址
        self.temp2 = StringVar()
        self.t1 = StringVar()  #通道
        self.t3 = StringVar()  #爱奇艺,优酷,PPTV
        self.La_title = Label(self.win, text="地址:")
        self.La_way = Label(self.win, text="选择视频通道:")
        # self.R_way1=Radiobutton(self.win,text="通道A",variable=self.t1,value=True)
        # self.R_way2=Radiobutton(self.win,text="通道B",variable=self.t1,value=False)
        #控件内容设置
        self.numberChosen = Combobox(self.win, width=20)
        self.numberChosen['values'] = ('通道一', '通道二', '通道三', '通道四', '通道五',
                                       '通道六', '通道七', '通道八', '通道九', '通道十')
        self.numberChosen.config(state='readonly')
        self.numberChosen.current(1)

        self.R_aiqiyi = Radiobutton(self.win,
                                    text="爱奇艺",
                                    variable=self.t3,
                                    value="a")
        self.R_youku = Radiobutton(self.win,
                                   text="优酷",
                                   variable=self.t3,
                                   value="y")
        self.R_pptv = Radiobutton(self.win,
                                  text="PPTV",
                                  variable=self.t3,
                                  value="p")
        self.t3.set('y')
        self.B_play = Button(self.win, text="播放▶")
        self.B_uppage = Button(self.win, text="上页")
        self.B_nextpage = Button(self.win, text="下页")
        self.B_search = Button(self.win, text="搜索全站")
        # self.La_mesasge=Label(self.win,text="☜  ⇠☸⇢  ☞",bg="pink")
        self.La_page = Label(self.win, bg="#BFEFFF")
        self.S_croll = Scrollbar(self.win)
        self.L_box = Listbox(self.win, bg="#BFEFFF", selectmode=SINGLE)
        self.E_address = Entry(self.win, textvariable=self.temp)
        self.La_title.place(x=10, y=50, width=50, height=30)
        self.E_address.place(x=70, y=50, width=200, height=30)
        self.B_play.place(x=280, y=50, width=80, height=80)
        # self.R_way1.place(x=160,y=10,width=70,height=30)
        # self.R_way2.place(x=240,y=10,width=70,height=30)
        self.numberChosen.place(x=120, y=10, width=180, height=30)
        self.La_way.place(x=10, y=10, width=100, height=30)
        # self.R_aiqiyi.place(x=20,y=100,width=70,height=30)
        self.R_youku.place(x=20, y=100, width=70, height=30)
        self.R_pptv.place(x=90, y=100, width=70, height=30)
        self.B_search.place(x=252, y=140, width=100, height=30)
        # self.La_mesasge.place(x=80,y=125,width=90,height=20)
        self.L_box.place(x=10, y=180, width=252, height=230)
        self.S_croll.place(x=260, y=180, width=20, height=230)
        self.B_uppage.place(x=10, y=140, width=50, height=30)
        self.B_nextpage.place(x=180, y=140, width=50, height=30)
        self.La_page.place(x=80, y=140, width=90, height=28)

    def creat_radiores(self):
        self.movie = StringVar()  #电影
        self.S_croll2 = Scrollbar()  #分集
        self.La_pic = Label(self.win, bg="#E6E6FA")
        self.La_movie_message = Listbox(self.win, bg="#7EC0EE")
        self.R_movie = Radiobutton(self.win,
                                   text="电影",
                                   variable=self.movie,
                                   value="m")
        self.tv = Radiobutton(self.win,
                              text="电视剧",
                              variable=self.movie,
                              value="t")
        self.zhongyi = Radiobutton(self.win,
                                   text="综艺",
                                   variable=self.movie,
                                   value="z")
        self.dongman = Radiobutton(self.win,
                                   text="动漫",
                                   variable=self.movie,
                                   value="d")
        self.jilupian = Radiobutton(self.win,
                                    text="纪录片",
                                    variable=self.movie,
                                    value="j")
        self.movie.set('m')
        self.B_view = Button(self.win, text="查看")
        self.B_info = Button(self.win, text="使用说明")
        self.B_clearbox = Button(self.win, text="清空列表")
        self.B_add = Button(self.win, text="添加到播放列表")
        self.R_movie.place(x=290, y=180, width=80, height=30)
        self.B_view.place(x=290, y=330, width=70, height=30)
        self.B_add.place(x=370, y=255, width=100, height=30)
        self.B_clearbox.place(x=500, y=255, width=70, height=30)
        self.tv.place(x=290, y=210, width=80, height=30)
        self.zhongyi.place(x=290, y=240, width=80, height=30)
        self.dongman.place(x=290, y=270, width=80, height=30)
        self.jilupian.place(x=290, y=300, width=80, height=30)
        self.La_movie_message.place(x=370, y=290, width=200, height=120)
        self.La_pic.place(x=370, y=10, width=200, height=240)
        self.B_info.place(x=290, y=370, width=70, height=30)
        self.S_croll2.place(x=568, y=290, width=20, height=120)

    def show_info(self):
        msg = """
        1.输入视频播放地址,即可播放
          下拉选择可切换视频源
        2.选择视频网,选择电视剧或者电影,
          搜索全网后选择想要看得影片,点
          查看,在右方list里选择分集视频
          添加到播放列表里点选播放
        3.复制网上视频连接,点击播放即可
        4.VIP视频也可以免费播放
        """
        messagebox.showinfo(title="使用说明", message=msg)

    def config(self):
        self.t1.set(True)
        self.B_play.config(command=self.play_url_movie)
        self.B_search.config(command=self.search_full_movie)
        self.B_info.config(command=self.show_info)
        self.S_croll.config(command=self.L_box.yview)
        self.L_box['yscrollcommand'] = self.S_croll.set
        self.S_croll2.config(command=self.La_movie_message.yview)
        self.La_movie_message['yscrollcommand'] = self.S_croll2.set
        self.B_view.config(command=self.view_movies)
        self.B_add.config(command=self.add_play_list)
        self.B_clearbox.config(command=self.clear_lisbox2)
        self.B_uppage.config(command=self.uppage_)
        self.B_nextpage.config(command=self.nextpage_)

    def uppage_(self):
        print('---------上一页---------')
        self.page -= 1
        print(self.page)
        if self.page < 1:
            self.page = 1

    def nextpage_(self):
        print('----------下一页--------')
        self.page += 1
        print(self.page)
        if self.t3 == "a" or self.t3 == "y":
            if self.page > 30:
                self.page = 30
        elif self.t3 == "p":
            if self.movie == "m":
                if self.page > 165:
                    self.page = 165
            elif self.movie == "t":
                if self.page > 85:
                    self.page = 85
            elif self.movie == "z":
                if self.page > 38:
                    self.page = 38
            elif self.movie == "d":
                if self.page > 146:
                    self.page = 146
            elif self.movie == "j":
                if self.page > 40:
                    self.page = 40

    def clear_lisbox(self):
        self.L_box.delete(0, END)

    def clear_lisbox2(self):
        self.La_movie_message.delete(0, END)

    def search_full_movie(self):
        print("-----search----")
        self.La_page.config(text="当前页:{}".format(self.page))
        self.clear_lisbox()
        try:
            movie_url, movie_title, movie_src_pic = self.p.get_movie_res(
                self.t3.get(), self.movie.get(), self.page)
            self.movie_dic = {}
            for i, j, k in zip(movie_title, movie_url, movie_src_pic):
                self.movie_dic[i] = [j, k]
            for title in movie_title:
                self.L_box.insert(END, title)
            print(self.movie_dic)
            return self.movie_dic
        except:
            messagebox.showerror(title='警告', message='请选择电影或者电视剧')

    def add_play_list(self):
        print('---------playlist----------')
        print(self.movie_dic)
        if self.La_movie_message.get(
                self.La_movie_message.curselection()) == "":
            messagebox.showwarning(title="警告", message='请在列表选择影片')
        else:
            print(
                "电影名字:",
                self.La_movie_message.get(
                    self.La_movie_message.curselection()))
            if self.movie.get() != "m":
                self.temp.set(self.new_more_dic[self.La_movie_message.get(
                    self.La_movie_message.curselection())])
            else:
                self.temp.set(self.movie_dic[self.La_movie_message.get(
                    self.La_movie_message.curselection())][0])

    def view_pic(self, pic_url):
        print('--------viewpic---------')
        pa_url_check = r'//.+[.]jpg'
        if re.match(pa_url_check, pic_url):
            print("ok")
            pic_url = "http:" + pic_url
        print(pic_url)
        data = requests.get(pic_url).content
        # data=urlopen(pic_url).read()
        io_data = io.BytesIO(data)
        self.img = Image.open(io_data)
        self.u = ImageTk.PhotoImage(self.img)
        self.La_pic.config(image=self.u)

    def view_movies(self):
        print("--------viewmovie----------")
        self.clear_lisbox2()
        cur_index = self.L_box.curselection()
        print(self.L_box.get(cur_index))
        if self.movie.get() != "m":  #非电影类
            self.new_more_dic = self.p.get_more_tv_urls(
                self.movie_dic[self.L_box.get(cur_index)][0], self.t3.get(),
                self.movie.get())
            print(self.new_more_dic)
            for i, fenji_url in self.new_more_dic.items():
                self.La_movie_message.insert(END, i)
        else:  #电影类
            self.La_movie_message.insert(END, self.L_box.get(cur_index))
        self.view_pic(self.movie_dic[self.L_box.get(
            self.L_box.curselection())][1])  #加载图片

    def play_url_movie(self):
        print("--------ok-----------")
        # print(type(self.t1.get()),self.t1.get())
        if self.temp.get() == "":
            messagebox.showwarning(title="警告", message="请先输入视频地址")
        else:
            if self.numberChosen.get() != "":
                self.p.play_movie(self.temp.get(), self.numberChosen.get())
            else:
                messagebox.showwarning(title='警告', message='请选择通道')
Esempio n. 18
0
class App_test(object):
    def __init__(self, master, fuc):
        self.win = master
        self.win.title('12306火车票查询系统V2.6')
        curWidth = self.win.winfo_width()
        curHeight = self.win.winfo_height()
        scnWidth, scnHeight = self.win.maxsize()
        tmpcnf = '1130x600+500+300'  # % ((scnWidth - curWidth) / 2, (scnHeight - curHeight) / 2)
        self.win.geometry(tmpcnf)
        self.creat_res()
        self.add_train_info()
        self.add_check_button()
        self.res_config(fuc)
        self.set_combox_defaut()
        self.train_message = {}

    # self.get_train_args()
    # self.win.mainloop()

    def creat_res(self):
        self.v = IntVar()  # 车票查询
        self.v.set(True)
        self.temp = StringVar()  # 开始站
        self.temp2 = StringVar()  # 目的站
        self.start_mon = StringVar()  # 出发月
        self.start_day = StringVar()  # 出发日
        self.start_year = StringVar()  # 出啊年
        self.La_start_end = Label(self.win, text="请输入出发地和目的地", fg="blue")
        self.E_startstation = Entry(self.win, textvariable=self.temp)
        self.E_endstation = Entry(self.win, textvariable=self.temp2)
        self.La_startstation = Label(self.win, text="出发站:")
        self.La_endstation = Label(self.win, text="目的站:")
        self.La_time = Label(self.win, text="请选择出发时间-年-月-日", fg="blue")
        self.B_search = Button(self.win, text="搜索")
        self.R_site = Radiobutton(self.win,
                                  text="车票查询",
                                  variable=self.v,
                                  value=True)
        self.R_price = Radiobutton(self.win,
                                   text="票价查询",
                                   variable=self.v,
                                   value=False)
        self.B_buy_tick = Button(self.win, text="购票")
        self.C_year = Combobox(self.win, textvariable=self.start_year)
        self.La_s = Label(self.win, text="--")
        self.C_mon = Combobox(self.win, textvariable=self.start_mon)
        self.La_s1 = Label(self.win, text="--")
        self.C_day = Combobox(self.win, textvariable=self.start_day)
        # 滚动条
        self.S_move = Scrollbar(self.win)
        self.La_start_end.place(x=10, y=10, width=150, height=30)
        self.E_startstation.place(x=70, y=50, width=145, height=30)
        self.E_startstation.insert(10, "杭州东")
        self.E_endstation.place(x=70, y=100, width=145, height=30)
        self.E_endstation.insert(10, "南京南")
        self.La_startstation.place(x=10, y=50, width=50, height=30)
        self.La_endstation.place(x=10, y=100, width=50, height=30)
        self.La_time.place(x=0, y=140, width=190, height=30)
        self.C_year.place(x=10, y=180, width=70, height=30)
        self.La_s.place(x=80, y=180, width=20, height=30)
        self.C_mon.place(x=100, y=180, width=50, height=30)
        self.La_s1.place(x=150, y=180, width=20, height=30)
        self.C_day.place(x=170, y=180, width=50, height=30)
        self.B_search.place(x=10, y=220, width=80, height=40)
        self.S_move.place(x=1100, y=40, width=30, height=550)
        self.B_buy_tick.place(x=10, y=310, width=80, height=40)
        self.R_site.place(x=10, y=270, width=90, height=30)
        self.R_price.place(x=100, y=270, width=90, height=30)

    def res_config(self, fuc):
        localTime = time.localtime(int(time.time()))
        # 获取今年的年份
        startTime = int(time.strftime("%Y", localTime))  # 2018
        self.C_year.config(
            values=[x for x in range(startTime, startTime + 10)])
        self.C_mon.config(values=["{:02d}".format(x)
                                  for x in range(1, 13)])  # 时间格式是2018-01-01
        self.C_day.config(values=["{:02d}".format(x) for x in range(1, 32)])
        self.B_search.config(command=fuc)
        self.S_move.config(command=self.tree.yview)
        self.tree.config(yscrollcommand=self.S_move.set)

    def add_train_info(self):
        lis_train = ["C" + str(x) for x in range(0, 15)]
        tuple_train = tuple(lis_train)
        self.tree = Treeview(self.win,
                             columns=tuple_train,
                             height=30,
                             show="headings")
        self.tree.place(x=228, y=40, width=870, height=550)
        train_info = [
            ' 车次 ', ' 出发/到达站', '出发/到达时间', '历时 ', '商/特座', '一等座', '二等座', '高软',
            '软卧', '动卧', '硬卧', '软座', '硬座', '无座', '其他'
        ]
        for i in range(0, len(lis_train)):
            self.tree.column(lis_train[i],
                             width=len(train_info[i]) * 11,
                             anchor='center')
            self.tree.heading(lis_train[i], text=train_info[i])

    def add_check_button(self):
        self.v1 = IntVar()
        self.v2 = IntVar()
        self.v3 = IntVar()
        self.v4 = IntVar()
        self.v5 = IntVar()
        self.v6 = IntVar()
        self.v7 = IntVar()
        self.v1.set("T")
        self.Check_total = Checkbutton(self.win,
                                       text="全部车次",
                                       variable=self.v1,
                                       onvalue='T')
        self.Check_total.place(x=228, y=7, width=90, height=30)
        self.Check_total = Checkbutton(self.win,
                                       text="G-高铁",
                                       variable=self.v2,
                                       onvalue='T')
        self.Check_total.place(x=318, y=7, width=70, height=30)
        self.Check_total = Checkbutton(self.win,
                                       text="D-动车",
                                       variable=self.v3,
                                       onvalue='T')
        self.Check_total.place(x=398, y=7, width=70, height=30)
        self.Check_total = Checkbutton(self.win,
                                       text="Z-直达",
                                       variable=self.v4,
                                       onvalue='T')
        self.Check_total.place(x=478, y=7, width=70, height=30)
        self.Check_total = Checkbutton(self.win,
                                       text="T-特快",
                                       variable=self.v5,
                                       onvalue='T')
        self.Check_total.place(x=558, y=7, width=70, height=30)
        self.Check_total = Checkbutton(self.win,
                                       text="K-快速",
                                       variable=self.v6,
                                       onvalue='T')
        self.Check_total.place(x=638, y=7, width=70, height=30)
        self.Check_total = Checkbutton(self.win,
                                       text="其他",
                                       variable=self.v7,
                                       onvalue='T')
        self.Check_total.place(x=718, y=7, width=70, height=30)

    # 设置下拉框默认值
    def set_combox_defaut(self):
        localTime = time.localtime(int(time.time()))
        mon = int(time.strftime("%m", localTime))
        day = int(time.strftime("%d", localTime))
        self.C_year.current(0)
        self.C_mon.current(mon - 1)
        self.C_day.current(day - 1)
Esempio n. 19
0
class App_test(object):
    def __init__(self, master, fuc, query, next, pre, query_all_chapters,
                 query_text):
        self.win = master
        self.win.title('shuyaya阅读_v2.0   by: 孤月')
        # self.win.iconbitmap('./ico/gui_text_proce.ico')  # 指定界面图标
        curWidth = self.win.winfo_width()
        curHeight = self.win.winfo_height()
        scnWidth, scnHeight = self.win.maxsize()
        tmpcnf = '1340x640+500+300'  # % ((scnWidth - curWidth) / 2, (scnHeight - curHeight) / 2)
        self.win.geometry(tmpcnf)
        self.creat_res()
        self.set_position()
        self.list_box(query_all_chapters, query_text)
        # self.add_train_info()
        self.res_config(fuc, query, next, pre)
        self.train_message = {}
        self.gettime()  # 系统时间

    def creat_res(self):
        # self.v = IntVar()  # 书籍查询
        # self.v.set(True)
        self.temp = StringVar()  # 书名/作者 录入
        self.temp2 = StringVar()  # 章节名录入
        self.sys_time = StringVar()  # 系统时间

        self.E_startstation = Entry(self.win, textvariable=self.temp)
        # self.E_endstation = Entry(self.win, textvariable=self.temp2)

        self.La_startstation = Label(self.win, text="根据书名/作者搜索:")
        self.La_endstation = Label(self.win, text="书籍目录:")
        self.La_directory = Label(self.win, text="目录")
        self.La_text = Label(self.win, text="正文")
        self.La_sys_time = Label(self.win,
                                 textvariable=self.sys_time,
                                 fg='blue',
                                 font=("黑体", 20))  # 设置字体大小颜色
        self.La_pic = Label(self.win, bg="#E6E6FA")
        self.La_anthor = Label(self.win, bg="#E6E6FA")
        self.La_type = Label(self.win, bg="#E6E6FA")
        self.La_update_time = Label(self.win, bg="#E6E6FA")
        self.La_latest_chapter = Label(self.win, bg="#E6E6FA")

        self.B_search = Button(self.win, text="搜索")
        self.B_buy_tick = Button(self.win, text="阅读")
        self.B_pre_chapter = Button(self.win, text="上一章")
        self.B_next_chapter = Button(self.win, text="下一章")

        # self.R_site = Radiobutton(self.win, text="书名查询", variable=self.v, value=True)
        # self.R_price = Radiobutton(self.win, text="章节查询", variable=self.v, value=False)

        self.init_data_Text = Text(self.win)  # 原始数据录入框
        self.S_move = Scrollbar(self.win)  # 目录滚动条
        self.S_text_move = Scrollbar(self.win)  # 创建文本框滚动条

    # 设置位置
    def set_position(self):
        self.init_data_Text.place(x=430, y=40, width=870, height=550)
        self.E_startstation.place(x=10, y=50, width=145, height=30)
        self.E_startstation.insert(10, "星辰变")
        # self.E_endstation.place(x=10, y=140, width=145, height=30)
        # self.E_endstation.insert(10, "第一章 秦羽")
        self.La_startstation.place(x=10, y=10, width=130, height=30)
        self.La_endstation.place(x=10, y=100, width=60, height=30)
        self.La_sys_time.place(x=1150, y=600, width=160, height=30)
        self.La_pic.place(x=10, y=350, width=170, height=180)  # 图片
        self.La_anthor.place(x=10, y=545, width=170, height=30)
        self.La_type.place(x=10, y=575, width=170, height=30)
        self.La_update_time.place(x=10, y=605, width=170, height=30)
        self.La_latest_chapter.place(x=10, y=635, width=170, height=30)

        self.B_search.place(x=10, y=300, width=80, height=40)
        self.B_buy_tick.place(x=90, y=300, width=80, height=40)
        self.B_pre_chapter.place(x=950, y=600, width=80, height=40)
        self.B_next_chapter.place(x=1050, y=600, width=80, height=40)
        self.S_move.place(x=380, y=40, width=30, height=550)
        self.S_text_move.place(x=1300, y=40, width=30, height=550)
        # self.R_site.place(x=10, y=180, width=90, height=30)
        # self.R_price.place(x=100, y=180, width=90, height=30)
        self.La_directory.place(x=180, y=7, width=90, height=30)
        self.La_text.place(x=420, y=7, width=70, height=30)

    # 为按钮绑定事件
    def res_config(self, fuc, query, next_, pre):
        self.B_search.config(command=fuc)  # 搜索
        self.B_buy_tick.config(command=query)  # 阅读
        self.B_pre_chapter.config(command=pre)  # 上一章
        self.B_next_chapter.config(command=next_)  # 下一章
        self.S_move.config(command=self.Ls_box_ct.yview)  # 目录滚动条
        self.Ls_box_ct.config(yscrollcommand=self.S_move.set)
        self.S_text_move.config(command=self.init_data_Text.yview)  # 文本框滚动条
        self.init_data_Text.config(yscrollcommand=self.S_text_move.set)

    # def printlist(self,event):
    #     print(self.Ls_box.get(self.Ls_box.curselection()))

    def list_box(self, query_all_chapters, query_text):
        self.Ls_box = Listbox(self.win, selectmode=EXTENDED, fg='blue')
        self.Ls_box.place(x=10, y=140, width=170, height=150)
        self.Ls_box.bind(
            '<Double-Button-1>', query_all_chapters
        )  # 鼠标双击  更多事件请看http://www.cnblogs.com/hackpig/p/8195678.html
        self.Ls_box.insert(END, "获取排行榜")  # 请输入书名&作者进行查询

        self.Ls_box_ct = Listbox(self.win, selectmode=EXTENDED, fg='blue')
        self.Ls_box_ct.place(x=200, y=40, width=180, height=550)
        self.Ls_box_ct.bind('<Double-Button-1>', query_text)

    def add_train_info(self):
        lis_train = ["C" + str(x) for x in range(0, 2)]
        tuple_train = tuple(lis_train)
        self.tree = Treeview(self.win,
                             columns=tuple_train,
                             height=30,
                             show="headings")
        self.tree.place(x=200, y=40, width=180, height=550)
        train_info = [' 书名 ', ' 作者 ']
        for i in range(0, len(lis_train)):
            self.tree.column(
                lis_train[i], width=len(train_info[i]) * 11,
                anchor='w')  # must be n, ne, e, se, s, sw, w, nw, or center
            self.tree.heading(lis_train[i], text=train_info[i])

    # 实时显示时钟
    def gettime(self):
        # 获取当前时间
        self.sys_time.set(time.strftime("%H:%M:%S"))
        # 每隔一秒调用函数自身获取时间
        self.win.after(1000, self.gettime)
Esempio n. 20
0
class App(object):
    def __init__(self):
        self.win=Tk()
        self.win.geometry('405x380')
        self.win.title("网易云mp3播放下载器")
        self.creat_res()
        self.res_config()
        self.win.mainloop()

    def creat_res(self):
        self.music_temp=StringVar(value="(.)(.)")
        self.mp3_lis=[] #备用
        self.temp=StringVar()#url输入框
        self.temp2=IntVar() #单选框 播放或者下载
        self.temp3=StringVar()#path 输入框
        self.T_message=Listbox(self.win,background="#EEE9E9")
        self.B_search=Button(self.win,text="搜索")
        self.B_path=Button(self.win,text="选择目录")
        self.E_song=Entry(self.win,textvariable=self.temp)
        self.E_path=Entry(self.win,textvariable=self.temp3)
        self.Play_button=Button(self.win,text="播放")
        self.Pause_button=Button(self.win,textvariable=self.music_temp)
        self.Temp_button=Button(self.win,text="单曲下载")
        self.Stop_button=Button(self.win,text="停止")
        self.Info=Button(self.win,text="说明")
        self.More_down=Button(self.win,text="歌单批量下载")
        self.B_search_loacl=Button(self.win,text="扫描本地歌曲")
        self.S_bal=Scrollbar(self.win)
        self.R_1=Radiobutton(self.win,variable=self.temp2,text="下载",value=True)
        self.R_2=Radiobutton(self.win,variable=self.temp2,text="播放",value=False)
        self.L_mp3_message=Label(self.win,background="#EEE9E9",fg="#9370DB")
        self.B_search.place(x=340,y=5,width=50,height=30)
        self.E_song.place(x=10,y=10,width=300,height=35)
        self.T_message.place(x=10,y=165,width=280,height=200)
        self.Play_button.place(x=340,y=160,width=50,height=40)
        self.Pause_button.place(x=340,y=209,width=50,height=40)
        self.Temp_button.place(x=130,y=125,width=100,height=30)
        self.S_bal.place(x=286,y=165,width=20,height=200)
        self.E_path.place(x=10,y=70,width=200,height=40)
        self.B_path.place(x=230,y=75,width=60,height=38)
        self.L_mp3_message.place(x=241,y=125,width=152,height=30)
        self.Info.place(x=340,y=315,width=50,height=40)
        self.More_down.place(x=10,y=125,width=100,height=30)
        self.B_search_loacl.place(x=300,y=75,width=100,height=38)
        self.R_1.place(x=265,y=50,width=60,height=25)
        self.R_2.place(x=340,y=50,width=60,height=25)
        self.Stop_button.place(x=340,y=260,width=50,height=40)

    def res_config(self):
        self.B_search.config(command=self.get_lis)
        self.S_bal.config(command=self.T_message.yview)
        self.T_message["yscrollcommand"]=self.S_bal.set
        self.T_message.config(selectmode=BROWSE)
        self.B_path.config(command=self.choose_path)
        self.More_down.config(command=self.download_music)
        self.Info.config(command=self.show_mesage)
        self.Temp_button.config(command=self.single_music_down)
        self.Play_button.config(command=self.play_music)
        self.Pause_button.config(command=self.pause_button_click)
        self.Stop_button.config(command=self.stop_button_click)
        self.temp2.set(1) #默认配置为下载模式

    def choose_path(self):
        self.path_=askdirectory()
        self.temp3.set(self.path_)

    def show_mesage(self):
        msg="输入框可识别歌单list,或者歌曲名称 '\n'" \
            "输入歌单,请搜索后选择单独下载或者全部批量下载 '\n'" \
            "播放单曲需要先选择路径,选择歌曲"
        messagebox.showinfo(message=msg,title="使用说明")

    def get_web_lis(self):
        if self.temp.get()!="":#输入框非空
            flag = music_get.do_something(self.temp.get())
            music_dic=music_get.get_music_id(self.temp.get())
            if flag==True:#输入的是链接
                mp3_url=music_get.get_mps_url(self.temp.get())
                for i, j in mp3_url.items():#i是id号
                    self.T_message.insert(END,"歌曲:"+i+"\n")
            else:#如果输入的是单曲
                self.T_message.insert(END, "正在查找歌曲:" + self.temp.get() + "\n")
                for id,name in music_dic.items():
                    self.T_message.insert(END, "找到歌曲:{}-{}".format(id,name)+ "\n")
        else:
            self.T_message.insert(END, "清输入歌曲名或者歌单链接:"  + "\n")
            messagebox.showerror(title="警告",message="请输入歌名或者歌曲清单链接")

    def get_loacl_lis(self):
        for file in os.listdir(self.temp3.get()):
            self.T_message.insert(END, file + "\n")

    def get_lis(self):#搜索按钮,先判断下输入的是url 还是单曲
        print("开关",self.temp2.get())
        if self.temp2.get():#wen搜索
            print("web搜索")
            self.get_web_lis()
        else: #本地搜所
            print("本地搜索")
            self.get_loacl_lis()

    def download_music(self):#歌单批量下载
        try:
            mp3_url = music_get.get_mps_url(self.temp.get())#mp3 清单表 字典
            print(mp3_url)
            music_get.down_mp3(self.temp3.get(),self.temp.get())
            flag = music_get.do_something(self.temp.get())
            print(self.temp.get(),self.temp3.get())
            if os.path.exists(self.temp3.get()) and flag==True and len(mp3_url)>0:#路径存在,输入连接,dic飞空
                self.L_mp3_message.config(text="批量下载中,请不要再操作软件")
                for i in mp3_url.keys():
                    t=random.randint(100,300)*0.01
                    self.T_message.insert(END, "正在努力下载歌曲:" + i + "\n")
                    time.sleep(t)
            else:
                self.T_message.insert(END, "请输入歌单连接和存储路径" + "\n")
        except Exception as s:
            print(s.args)
            self.T_message.insert(END, "请先输入歌单连接和存储路径" + "\n")
            messagebox.showerror(title="警告",message="请输入歌名或者歌曲清单链接")


    def get_id(self):#获取id号
        if self.T_message.curselection():#不为空
            s=self.T_message.curselection()
            res=self.T_message.get(s[0])
            pa_id='找到歌曲:[\d]+-.+'
            if re.match(pa_id,res):#选择listbox
                id=res[res.find(":")+1:res.find("-")]
                return id
            else:
                self.T_message.insert(END, "请选择带id号的歌曲" + "\n")
        else:
            self.T_message.insert(END, "请先搜索歌名" + "\n")

    def single_music_down(self):#单曲下载
        print("----------下载单曲----------")
        id=self.get_id()
        flag=music_get.do_something(self.temp.get())#判断是url 还是歌曲名字 如果是url true 否则f
        if os.path.exists(self.temp3.get()) and flag==False:
            try:
                music_get.down_music2(self.temp3.get(),id,self.temp.get())
                self.T_message.insert(END, "正在下载歌曲:" +self.temp.get()+ str(id) + "\n")
                self.L_mp3_message.config(text="歌曲{}_{}下载完成".format(self.temp.get(),id))
            except Exception:
                self.T_message.insert(END, "请选择带的ID号的歌曲:" + "\n")
                messagebox.showwarning(title="友情提示", message="请选择带的ID号的歌曲")
        else:
            self.T_message.insert(END, "erro,请选择存储路径:" + "\n")
            messagebox.showwarning(title="温馨提示",message="请先搜索歌曲再选择存储路径")


    def play_music(self):
        print("播放音乐")
        path=self.temp3.get()#路径
        if os.path.exists(path) and self.temp2.get()==False:#如果路径存在,开关在播放模式
            if self.T_message.curselection():#lisbox飞空
                print("--------开始播放--------")
                music_file=self.T_message.get(self.T_message.curselection())
                current_music_path=self.temp3.get()+"/"+music_file
                pa_music=".+[\.]mp3"
                if re.match(pa_music,music_file):#匹配mp3文件
                    print("文件识别OK")
                    print(current_music_path)
                    self.L_mp3_message.config(text="文件识别OK")
                    self.play_music_mp3(current_music_path.strip()) #此处有坑,需要清除字符串换行符
                    self.music_temp.set("暂停")
                else:
                    print("非mp3文件")
                    self.L_mp3_message.config(text="非mp3文件")
            else:
                self.T_message.insert(END, "erro,请选择歌名:" + "\n")
        else:
            messagebox.showwarning(title="温馨提示",message="请选择歌曲路径,选择播放模式")

    def play_music_mp3(self,name):#播放音乐
        pygame.init()
        pygame.mixer.music.load(name)
        pygame.mixer.music.play()
        time.sleep(12)
        # pygame.mixer.music.stop()

    def pause_button_click(self):
        if self.music_temp.get()=="暂停":
            pygame.mixer.music.pause()
            self.music_temp.set("继续")
        elif self.music_temp.get()=="继续":
            pygame.mixer.music.unpause()
            self.music_temp.set("暂停")

    def pause_music(self):
        print("暂停播放")
        pygame.mixer.music.pause()

    def stop_button_click(self):
        pygame.mixer.music.stop()
style.theme_use('yummy')  # 'default'

fr1 = Frame(fr, height=250, width=250)
fr1.grid(column=0, row=11, sticky='nsew')

widg = Scrollbar(fr1, orient="vertical")
widg1 = Scrollbar(fr1, orient="horizontal")
mylist = Listbox(fr1)
for line in range(100):
    mylist.insert('end', "A really long line. " + str(line) + " Line number ")

mylist.grid(column=0, row=0)

widg.grid(column=1, row=0, sticky='ns')
widg.configure(command=mylist.yview)

widg1.grid(column=0, row=1, sticky='ew')
widg1.configure(command=mylist.xview)
mylist.configure(yscrollcommand=widg.set, xscrollcommand=widg1.set)

root.mainloop()
'''
widg.place(x=5, y=5, width=150)
widg.set(0.2,0.3)

widg1.place(x=25, y=75, height=150)
widg1.set(0.2,0.3)
            
,
'''