• 存档2


    #!/usr/bin/python
    # -*- coding: utf-8 -*-
    
    """
    ZetCode Tkinter tutorial
    
    In this script, we use the Label
    widget to show an image.
    
    Author: Jan Bodnar
    Last modified: November 2015
    Website: www.zetcode.com
    """
    
    from PIL import Image, ImageTk
    from Tkinter import *
    from spider import spider
    
    
    class Example(Frame):
    
        def __init__(self, parent):
            Frame.__init__(self, parent)
    
            self.parent = parent
    
            self.spider=spider()
    
            self.initUI()
    
    
        def initUI(self):
    
            self.parent.title("成绩获取小助手")
    
            self.img = self.spider.getCaptcha()
            img_captcha = ImageTk.PhotoImage(self.img)
            self.Lbl_captcha = Label(self, image=img_captcha)
            self.Lbl_captcha.image = img_captcha
    
            self.Btn_fresh=Button(self, text="刷新")
            self.Lbl_studentID=Label(self, text="学号")
            self.Lbl_password= Label(self, text="密码")
            self.Lbl_verifyCode=Label(self, text="验证码")
            self.Btn_login=Button(self,text="登录")
            self.Ety_studentID = Entry(self)
            self.Ety_password = Entry(self)
            self.Ety_verifyCode= Entry(self)
    
            self.Lbl_studentID.grid(row=0,column=0)
            self.Ety_studentID.grid(row=0,column=1)
            self.Lbl_password.grid(row=1,column=0)
            self.Ety_password.grid(row=1,column=1)
            self.Lbl_verifyCode.grid(row=2,column=0)
            self.Ety_verifyCode.grid(row=2,column=1)
            self.Lbl_captcha.grid(row=2,column=2)
            self.Btn_fresh.grid(row=3,column=2)
            self.Btn_login.grid(row=3,column=1)
            self.Btn_login.bind("<Button-1>", self.loginSystem)
            self.Btn_fresh.bind("<Button-1>", self.freshCaptcha)
    
    
            self.pack()
    
        def loginSystem(self,event):
            self.spider.studentID=self.Ety_studentID.get()
            self.spider.password=self.Ety_password.get()
            self.spider.captcha=self.Ety_verifyCode.get()
    
            self.spider.loginMainPage()
    
            result=self.spider.getAndSaveScore()
            if(result==0):
                self.show_toplevel('获取失败,请重试!')
            else:
                self.show_toplevel('获取成功!')
            self.update()
    
        def show_toplevel(self,msg):
            self.top = Toplevel()
            self.top.title('操作提示')
            self.top.geometry("30x20+350+350")
            Label(self.top, text=msg).pack()
    
        def freshCaptcha(self,event):
            self.img = self.spider.getCaptcha()
            img_captcha = ImageTk.PhotoImage(self.img)
            self.Lbl_captcha = Label(self, image=img_captcha)
            self.Lbl_captcha.image = img_captcha
            self.Lbl_captcha.grid(row=2,column=2)
            self.update()
    
        def setGeometry(self):
    
            #w, h = self.img.size
            self.parent.geometry("300x150+300+300" )
    
    
    def main():
    
        root = Tk()
        ex = Example(root)
        ex.setGeometry()
        root.mainloop()
    
    
    if __name__ == '__main__':
        main()
  • 相关阅读:
    黑马程序员面向对象09天1
    一键安装LNMP
    多屏互动技术
    阿里云CentOS 64位解决kernel2.6.32220.13.1.el6.x86_64 has missing requires错误
    listview的onItemClickListener失效
    在阿里云主机上基于CentOS用vsftpd搭建FTP服务器(赚)
    asp.net关于在线支付的实现过程
    C#关闭登录窗体,显示主窗体
    winform 刷新父窗体(转)
    用代码生成器生成的DAL数据访问操作类 基本满足需求了
  • 原文地址:https://www.cnblogs.com/muyangshaonian/p/9650508.html
Copyright © 2020-2023  润新知