예제 #1
0
파일: heartpage.py 프로젝트: sdlas/intelcub
 def __init__(self, mainclass, master, _winheight, _winwidth, resultlist):
     self.mainclass = mainclass
     self.winheight = _winheight
     self.winwidth = _winwidth
     self.master = master
     self.resultlist = resultlist
     self.fontpadding = 60
     self.fontsize = 30
     if self.resultlist != -1:
         self.resultpage = tk.Canvas(self.master,
                                     bg="greenyellow",
                                     width=self.winwidth,
                                     height=self.winheight)
         self.resultpage.place(x=0, y=0)
         self.resultpage.create_text(self.winwidth / 2,
                                     self.winheight / 2 -
                                     self.fontpadding * 3 / 2,
                                     text="收缩压:" + str(self.resultlist[0]),
                                     font=("宋体", self.fontsize))
         self.resultpage.create_text(self.winwidth / 2,
                                     self.winheight / 2 -
                                     self.fontpadding * 1 / 2,
                                     text="舒张压:" + str(self.resultlist[1]),
                                     font=("宋体", self.fontsize))
         self.resultpage.create_text(self.winwidth / 2,
                                     self.winheight / 2 +
                                     self.fontpadding * 1 / 2,
                                     text="心率:" + str(self.resultlist[2]),
                                     font=("宋体", self.fontsize))
         self.resultpage.create_text(self.winwidth / 2,
                                     self.winheight / 2 +
                                     self.fontpadding * 7 / 4,
                                     text="非常健康,一切指标良好",
                                     font=("宋体", self.fontsize + 5))
         self.writein()
         wordtovoice(self.mainclass, "非常健康,一切指标良好")
         backbtn(self, self.resultpage, self.winheight, self.winwidth, 8)
     else:
         self.resultpage = tk.Canvas(self.master,
                                     bg="red",
                                     width=self.winwidth,
                                     height=self.winheight)
         self.resultpage.place(x=0, y=0)
         self.resultpage.create_text(self.winwidth / 2,
                                     self.winheight / 2,
                                     text="测量出错,请检查仪器是否佩戴正确",
                                     font=("宋体", self.fontsize + 10))
         wordtovoice(self.mainclass, "测量出错,请检查仪器是否佩戴正确")
         backbtn(self, self.resultpage, self.winheight, self.winwidth, 8)
예제 #2
0
 def __init__(self, mainclass, master, _winheight, _winwidth):
     self.winheight = _winheight
     self.winwidth = _winwidth
     self.master = master
     self.mainclass = mainclass
     self.imagereadlist = []
     self.topheight = 130  #顶部标题高度
     self.heartpage = tk.Canvas(self.master,
                                bg="pink",
                                width=self.winwidth,
                                height=self.winheight)
     self.heartpage.place(x=0, y=0)
     self.heartpage.configure(highlightthickness=0)
     self.startbtnwidth = 350
     self.working = False
     self.btnimage = ImageTk.PhotoImage(
         Image.open("srcimage/startm.jpg").resize(
             (int(self.startbtnwidth), int(self.startbtnwidth))))
     self.waitingimage = ImageTk.PhotoImage(
         Image.open("srcimage/waiting.jpg").resize(
             (int(self.startbtnwidth), int(self.startbtnwidth))))
     #背景
     bg = background(self.heartpage, self.winheight, self.winwidth, "call")
     #返回按钮
     backbtn(self.heartpage, self.winheight, self.winwidth)
     #标题
     title(self.heartpage, self.winheight, self.winwidth, "心率测量")
     self.startbtn = tk.Button(self.heartpage,
                               image=self.btnimage,
                               width=self.startbtnwidth,
                               height=self.startbtnwidth,
                               command=self.start)
     self.startbtn.place(x=(self.winwidth - self.startbtnwidth) / 2,
                         y=(self.winheight - self.startbtnwidth) / 2)
     bg.showimage()
예제 #3
0
 def __init__(self,master,_winheight,_winwidth):
     self.extensionlist = ['mp4']
     self.videolist = []
     for extension in self.extensionlist:
         file_list = glob.glob('videos/*.' + extension)  #返回一个列表
         for item in file_list:
             self.videolist.append(item[6:])
     self.master = master
     self.master.config(bg='blue')
     self.playing = False #当前是否有视频正在播放
     # 屏幕宽高
     self.winheight = _winheight
     self.winwidth = _winwidth
     self.videowidth = self.winwidth/8
     self.videopadding = self.winwidth/64
     self.topheight = 130 #顶部标题高度
     self.firstimagelist = []
     for n in range(0,len(self.videolist)):
         self.firstimagelist.append(self.getfirstimage(self.videolist[n]))
     # 获取每个视频的第一张图
     # 视频集画框
     self.videocanvas = tk.Canvas(self.master,bg="pink",height=self.winheight,width=self.winwidth)
     self.videocanvas.place(x=0,y=0)
     #背景
     bg = background(self.videocanvas,self.winheight,self.winwidth,"call")
     #返回按钮
     backbtn(self.videocanvas,self.winheight,self.winwidth)
     #标题
     title(self.videocanvas,self.winheight,self.winwidth,"播放视频")
     # 视频缩略图放置
     for n in range(0,len(self.videolist)):
         locals()['self.tempbutton'+str(n)] = tk.Button(self.videocanvas,image=self.firstimagelist[n], width=self.videowidth,height=self.videowidth,command=self.returnfun(n),bd=0)
         locals()['self.tempbutton'+str(n)].place(x=n%7*(self.videowidth+self.videopadding)+self.videopadding,y=int((n+1)/8)*(self.videowidth+self.videopadding)+self.topheight)
     bg.showimage()
예제 #4
0
 def __init__(self, mainclass, matser, _winheight, _winwidth):
     self.mainclass = mainclass
     self.winheight = _winheight
     self.winwidth = _winwidth
     self.master = matser
     self.hearto2page = tk.Frame(self.master,
                                 bg="pink",
                                 height=self.winheight,
                                 width=self.winwidth)
     self.hearto2page.place(x=0, y=0)
     self.heartratescale = [0, 150]  #心跳速度范围
     self.heartratelength = self.heartratescale[1] - self.heartratescale[0]
     self.oxygenscale = [0, 150]  #血氧浓度范围
     self.oxygenlength = self.oxygenscale[1] - self.oxygenscale[0]
     #背景
     bg = background(self.hearto2page, self.winheight, self.winwidth,
                     "call")
     #返回按钮
     backbtn(self.hearto2page, self.winheight, self.winwidth)
     #标题
     self.testbtn = tk.Button(self.hearto2page,
                              bitmap="error",
                              width=100,
                              height=100,
                              command=self.testbtn)
     self.testbtn.place(x=0, y=0)
     title(self.hearto2page, self.winheight, self.winwidth, "健康检测")
     self.paddingl = 200  #水平的间隙
     self.paddingv = 60  #竖直方向的间隙
     self.matwidth = self.winwidth - self.paddingl * 2
     self.matheight = self.winheight - self.paddingv * 2
     self.perx = self.matwidth / 100
     self.pery = self.matheight / 100
     self.matcanvas = tk.Canvas(self.hearto2page,
                                bg="white",
                                width=self.matwidth,
                                height=self.matheight)
     self.matcanvas.place(x=self.paddingl, y=self.paddingv)
     self.opointx = 10 * self.perx
     self.opointy = 90 * self.pery
     self.yheight = 80 * self.pery
     self.xwidth = 80 * self.perx
     self.drawaxis()  #绘制坐标轴
     # 40,130
     # 85,100
     #bg.showimage()
     #self.updatecan()
     plt.ion()
     plt.figure(1)
예제 #5
0
파일: heartpage.py 프로젝트: sdlas/intelcub
 def __init__(self, mainclass, master, _winheight, _winwidth):
     self.mainclass = mainclass
     self.master = master
     self.winheight = _winheight
     self.winwidth = _winwidth
     self.waitingcanvas = tk.Canvas(self.master,
                                    width=self.winwidth,
                                    height=self.winheight)
     self.waitingcanvas.place(x=0, y=0)
     self.waiting0 = ImageTk.PhotoImage(
         Image.open("srcimage/waiting0.jpg").resize(
             (int(self.winwidth), int(self.winheight))))
     self.waiting1 = ImageTk.PhotoImage(
         Image.open("srcimage/waiting1.jpg").resize(
             (int(self.winwidth), int(self.winheight))))
     self.waiting2 = ImageTk.PhotoImage(
         Image.open("srcimage/waiting2.jpg").resize(
             (int(self.winwidth), int(self.winheight))))
     self.waiting3 = ImageTk.PhotoImage(
         Image.open("srcimage/waiting3.jpg").resize(
             (int(self.winwidth), int(self.winheight))))
     self.gif()
예제 #6
0
    def __init__(self, master=None):
        tk.Tk.__init__(self)
        self.canvas = tk.Canvas(self, width=1280, height=768)
        self.canvas.pack(side="top", fill="both", expand=True)
        self.img_size = 128, 128
        self.create_widgets()

        #load user scores
        with open("../pickles/user_score_dictionary.p", "rb") as f:
            self.user_dict = pickle.load(f)

        #load pokemon and dex number dicts
        with open("../pickles/pokemon_to_dex.p", "rb") as f:
            self.poke_to_dex = pickle.load(f)
        with open("../pickles/dex_to_pokemon.p", "rb") as f:
            self.dex_to_poke = pickle.load(f)

        self.score = 0
        self.previous_pokemon = []
        self.previous_guesses = []
        self.is_userCreated = False
        self.question_number = 0
예제 #7
0
 def __init__(self, master):
     self.master = master
     #基准界面initface
     self.initface = tk.Canvas(self.master,
                               bg="white",
                               width=winwidth,
                               height=winheight)
     self.initface.pack()
     self.initface.configure(highlightthickness=0)
     #常量定义
     self.closebtnwidth = 70  #关闭按钮的大小
     self.Bigbtnwidth = winwidth / 3  #中央大按钮的大小
     self.btnwidth = winheight / 4  #普通按钮的大小
     self.padding1 = 40  #普通按钮之间的间隔
     self.midlength = winwidth * 9 / 24
     self.sidelength = winwidth * 15 / 48
     self.tomid = 50
     self.Amovex = winwidth / 3 - self.padding1 - self.btnwidth - self.tomid
     self.Bmovey = winheight / 4
     self.Cmovex = winwidth * 2 / 3 + self.padding1 + self.tomid
     self.midmove = 60  #中间层按钮偏移量
     self.heartratelist = [80, 90, 69, 110, 102, 79]  #心跳速度列表
     self.oxygenlist = [89, 90, 98, 96, 87, 92]  #血氧浓度列表
     #偏移量
     self.move = [
         [self.Amovex, self.Bmovey - self.btnwidth / 2 - self.padding1 / 2],
         [
             self.Amovex - self.midmove,
             self.Bmovey + self.btnwidth / 2 + self.padding1 / 2
         ],
         [
             self.Amovex,
             self.Bmovey + self.btnwidth * 3 / 2 + self.padding1 * 3 / 2
         ], [winwidth / 3, 0], [winwidth / 3, self.Bmovey],
         [self.sidelength, winheight * 5 / 6],
         [self.Cmovex, self.Bmovey - self.btnwidth / 2 - self.padding1 / 2],
         [
             self.Cmovex + self.midmove,
             self.Bmovey + self.btnwidth / 2 + self.padding1 / 2
         ],
         [
             self.Cmovex,
             self.Bmovey + self.btnwidth * 3 / 2 + self.padding1 * 3 / 2
         ]
     ]
     #读取图片
     self.titleimage = ImageTk.PhotoImage(
         Image.open("srcimage/title.jpg").resize(
             (int(winwidth / 3), int(winheight / 6))))
     self.backgroundimage = ImageTk.PhotoImage(
         Image.open("srcimage/background.jpg").resize(
             (int(winwidth), int(winheight))))
     self.bookimage = ImageTk.PhotoImage(
         Image.open("srcimage/photos.jpg").resize(
             (int(self.btnwidth), int(self.btnwidth))))
     self.movieimage = ImageTk.PhotoImage(
         Image.open("srcimage/video.jpg").resize(
             (int(self.btnwidth), int(self.btnwidth))))
     self.musicimage = ImageTk.PhotoImage(
         Image.open("srcimage/music.jpg").resize(
             (int(self.btnwidth), int(self.btnwidth))))
     self.studyimage = ImageTk.PhotoImage(
         Image.open("srcimage/emecall.jpg").resize(
             (int(self.btnwidth), int(self.btnwidth))))
     self.gameimage = ImageTk.PhotoImage(
         Image.open("srcimage/phone.jpg").resize(
             (int(self.btnwidth), int(self.btnwidth))))
     self.hearto2image = ImageTk.PhotoImage(
         Image.open("srcimage/hearto2.jpg").resize(
             (int(self.btnwidth), int(self.btnwidth))))
     self.workimage = ImageTk.PhotoImage(
         Image.open("srcimage/looking.jpg").resize(
             (int(self.Bigbtnwidth), int(self.Bigbtnwidth))))
     self.closeimage = ImageTk.PhotoImage(
         Image.open("srcimage/close.jpg").resize(
             (int(self.closebtnwidth), int(self.closebtnwidth))))
     # 右边的三个按钮
     self.buttonA_1 = tk.Button(self.initface,
                                image=self.bookimage,
                                height=self.btnwidth,
                                width=self.btnwidth,
                                relief="ridge",
                                command=self.gotophoto,
                                bd=0)
     self.buttonA_1.place(x=self.move[0][0], y=self.move[0][1])
     self.buttonA_2 = tk.Button(self.initface,
                                image=self.movieimage,
                                height=self.btnwidth,
                                width=self.btnwidth,
                                relief="ridge",
                                command=self.gotovideo,
                                bd=0)
     self.buttonA_2.place(x=self.move[1][0], y=self.move[1][1])
     self.buttonA_3 = tk.Button(self.initface,
                                image=self.musicimage,
                                height=self.btnwidth,
                                width=self.btnwidth,
                                relief="ridge",
                                command=self.gotomusic,
                                bd=0)
     self.buttonA_3.place(x=self.move[2][0], y=self.move[2][1])
     # 交大的校徽
     self.titleCanvas = tk.Canvas(self.initface,
                                  width=self.Bigbtnwidth,
                                  height=winheight / 6)
     self.titleCanvas.place(x=self.move[3][0], y=self.move[3][1])
     self.titleCanvas.create_image(0, 0, anchor='nw', image=self.titleimage)
     self.titleCanvas.configure(highlightthickness=0)
     # 中间的按钮
     self.buttonB = tk.Button(self.initface,
                              image=self.workimage,
                              height=int(winheight / 2),
                              width=int(winwidth / 3),
                              relief="ridge")
     self.buttonB.place(x=self.move[4][0], y=self.move[4][1])
     # 左边的三个按钮
     self.buttonC_1 = tk.Button(self.initface,
                                image=self.studyimage,
                                height=self.btnwidth,
                                width=self.btnwidth,
                                relief="ridge",
                                command=self.emecall,
                                bd=0)
     self.buttonC_1.place(x=self.move[6][0], y=self.move[6][1])
     self.buttonC_2 = tk.Button(self.initface,
                                image=self.gameimage,
                                height=self.btnwidth,
                                width=self.btnwidth,
                                relief="ridge",
                                command=self.callfamily,
                                bd=0)
     self.buttonC_2.place(x=self.move[7][0], y=self.move[7][1])
     self.buttonC_3 = tk.Button(self.initface,
                                image=self.hearto2image,
                                height=self.btnwidth,
                                width=self.btnwidth,
                                relief="ridge",
                                bd=0,
                                command=self.gotoheartpage)
     self.buttonC_3.place(x=self.move[8][0], y=self.move[8][1])
     #关闭按钮
     self.closebtn = tk.Button(self.initface,
                               image=self.closeimage,
                               width=self.closebtnwidth,
                               height=self.closebtnwidth,
                               bd=0,
                               command=self.destroypage)
     self.closebtn.place(x=winwidth - self.closebtnwidth, y=0)
     self.hearto2page = []
     #刷新显示图片
     self.showtitle()
예제 #8
0
파일: heartpage.py 프로젝트: sdlas/intelcub
 def __init__(self, master, _winheight, _winwidth):
     self.master = master
     self.winheight = _winheight
     self.winwidth = _winwidth
     self.history = tk.Canvas(self.master,
                              bg="pink",
                              width=self.winwidth,
                              height=self.winheight)
     self.history.place(x=0, y=0)
     self.linewidth = 5  #线宽
     self.pointradius = 6
     # 背景
     bg = background(self.history, self.winheight, self.winwidth, "call")
     # 返回按钮
     bb = backbtn(self, self.history, self.winheight, self.winwidth, 9)
     bb.backbtn.place(x=bb.backbtnpadding, y=10)
     self.paddingl = 60  #水平的间隙
     self.paddingv = 50  #竖直方向的间隙
     self.matwidth = self.winwidth - self.paddingl * 2
     self.matheight = self.winheight - self.paddingv * 2
     self.perx = self.matwidth / 100
     self.pery = self.matheight / 100
     self.matcanvas = tk.Canvas(self.history,
                                bg="white",
                                width=self.matwidth,
                                height=self.matheight)
     self.matcanvas.place(x=self.paddingl, y=self.paddingv + 40)
     self.opointx = 10 * self.perx
     self.opointy = 90 * self.pery
     self.yheight = 80 * self.pery
     self.xwidth = 80 * self.perx
     self.highpressurelist = []
     self.highpressurescale = [90, 170]
     self.lowpressurescale = [50, 110]
     self.heartscale = [40, 130]
     self.safescalelist = [[self.highpressurescale[0], 140],
                           [self.lowpressurescale[0], 90], [60, 100]]
     self.lowpressurelist = []
     self.pressurelist = []
     self.datelist = []
     self.switchbtnwidth = 80
     self.switchbtnheight = 50
     self.curid = 0  #当前选择的模块
     self.btnpadding = 10
     self.switchimagenamelist = [
         "highpressure.jpg", "lowpressure.jpg", "heartrate.jpg"
     ]
     self.switchimageablenamelist = [
         "highpressureable.jpg", "lowpressureable.jpg", "heartrateable.jpg"
     ]
     self.switchimagelist = []
     self.switchimageablelist = []
     for i in range(0, len(self.switchimagenamelist)):
         self.switchimagelist.append(
             ImageTk.PhotoImage(
                 Image.open("srcimage/" +
                            self.switchimagenamelist[i]).resize(
                                (int(self.switchbtnwidth),
                                 int(self.switchbtnheight)))))
         self.switchimageablelist.append(
             ImageTk.PhotoImage(
                 Image.open("srcimage/" +
                            self.switchimageablenamelist[i]).resize(
                                (int(self.switchbtnwidth),
                                 int(self.switchbtnheight)))))
     self.menubtnlist = []
     for i in range(0, len(self.switchimagenamelist)):
         self.menubtnlist.append(
             tk.Button(self.matcanvas,
                       image=self.switchimageablelist[i],
                       width=self.switchbtnwidth,
                       height=self.switchbtnheight,
                       command=self.returnfun(i)))
         self.menubtnlist[i].place(
             x=self.btnpadding +
             (self.btnpadding + self.switchbtnwidth) * i,
             y=self.btnpadding)
     self.f = open("doc/heart.txt")
     line = self.f.readline().replace("\n", "")
     count = 0
     while line and count < 5:
         count = count + 1
         self.highpressurelist.append(int(line))
         line = self.f.readline().replace("\n", "")
         self.pressurelist.append(int(line))
         line = self.f.readline().replace("\n", "")
         self.lowpressurelist.append(int(line))
         line = self.f.readline().replace("\n", "")
         templist = []
         templist.append(int(line))
         line = self.f.readline().replace("\n", "")
         templist.append(int(line))
         line = self.f.readline().replace("\n", "")
         templist.append(int(line))
         if len(self.datelist) > 0:
             for i in range(0, 3):
                 if templist[i] != self.datelist[-1][i]:
                     self.datelist.append(templist)
         else:
             self.datelist.append(templist)
         line = self.f.readline().replace("\n", "")
     self.highpressurelength = self.highpressurescale[
         1] - self.highpressurescale[0]
     self.lowpressurelength = self.lowpressurescale[
         1] - self.lowpressurescale[0]
     self.heartlength = self.heartscale[1] - self.heartscale[0]
     self.datevalue = []
     self.scalelist = []
     self.datescale = [
         self.turnvalue(self.datelist[0]),
         self.turnvalue(self.datelist[-1])
     ]
     self.xlist = []
     for i in range(0, len(self.datelist)):
         self.datevalue.append(self.turnvalue(self.datelist[i]))
         self.scalelist.append((self.datevalue[i] - self.datescale[0]) /
                               (self.datescale[1] - self.datescale[0]))
         self.xlist.append(self.opointx +
                           self.perx * 70 * self.scalelist[i])
     self.changecanvas(self.curid)
     bg.showimage()
예제 #9
0
    session = tf.compat.v1.Session(config=config)
    if os.path.exists(get_last_model_dir(best_model_path)):
        model = tf.keras.models.load_model(get_last_model_dir(best_model_path),
                                           compile=False)
        print("best model {} loaded!".format(
            get_last_model_dir(best_model_path)))
    else:
        raise FileNotFoundError("There is no model to load")

    master = mtk.Tk()
    player_moved = mtk.BooleanVar()
    AI_thinking = mtk.BooleanVar()
    finish = mtk.BooleanVar()
    finish.set(False)
    tk = mtk.Canvas(master,
                    width=DIMENSION + MARGIN * 2,
                    height=DIMENSION + MARGIN * 2)
    tk.pack()

    pool = ThreadPool(processes=1)

    PLAYER_IS_WHITE = True
    C_GO_FIRST = 1 if PLAYER_IS_WHITE else -1

    tk.bind("<Button-1>", lambda event: mouse_clicked(event))
    tk.bind("<Return>", lambda event: key_pressed(event))
    draw_grid(tk)
    draw_pieces(tk, Game.board)
    tk.update()

    while True:
예제 #10
0
파일: testdemo.py 프로젝트: sdlas/intelcub
    def __init__(self, master):
        self.master = master
        #基准界面initface
        self.initface = tk.Canvas(self.master,
                                  bg="white",
                                  width=winwidth,
                                  height=winheight)
        self.initface.pack()
        self.initface.configure(highlightthickness=0)
        #常量定义
        self.closebtnwidth = 60  #关闭按钮的大小
        self.Bigbtnwidth = winwidth / 3  #中央大按钮的大小
        self.btnwidth = winheight / 6  #普通按钮的大小
        self.padding1 = 60  #普通按钮之间的间隔
        self.midlength = winwidth * 9 / 24
        self.sidelength = winwidth * 15 / 48
        self.tomid = 50
        self.Amovex = winwidth / 3 - self.padding1 - self.btnwidth - self.tomid
        self.Bmovey = winheight / 4
        self.Cmovex = winwidth * 2 / 3 + self.padding1 + self.tomid
        self.midmove = 60  #中间层按钮偏移量
        self.heartratelist = [80, 90, 69, 110, 102, 79]  #心跳速度列表
        self.oxygenlist = [89, 90, 98, 96, 87, 92]  #血氧浓度列表
        self.twomove = 100
        self.closemove = 40
        self.closemove2 = 30
        self.playclockwidth = winwidth
        self.playclockheight = winheight
        self.littlewidth = 140
        self.littleheight = self.littlewidth * winheight / winwidth
        self.smiling = True
        self.small = False
        self.emojiid = 0
        self.playclocking = False
        self.fallflag = False
        self.falldowntime = 0
        self.voicerecing = True
        self.curfunid = -1  #当前功能id 0照片 1音乐 2视频 3 环境 4呼救 5打电话 6设闹钟 7测血压
        #偏移量
        self.move = [
            [[
                self.Amovex - self.twomove / 2 + self.closemove +
                self.closemove2,
                self.Bmovey - self.btnwidth / 2 - self.padding1 / 2
            ],
             [
                 self.Amovex - self.midmove - self.twomove + 90 +
                 self.closemove,
                 self.Bmovey + self.btnwidth / 2 + self.padding1 / 2
             ],
             [
                 self.Amovex - self.midmove + self.btnwidth + 100 -
                 self.twomove + self.closemove,
                 self.Bmovey + self.btnwidth / 2 + self.padding1 / 2
             ],
             [
                 self.Amovex - self.twomove / 2 + self.closemove2 +
                 self.closemove,
                 self.Bmovey + self.btnwidth * 3 / 2 + self.padding1 * 3 / 2
             ]],
            [
                [winwidth / 3, 0],
                [winwidth / 3, self.Bmovey + 30],
                [winwidth / 3, self.Bmovey + self.Bigbtnwidth + 30],
            ],
            [[
                self.Cmovex + self.twomove / 2 - self.closemove -
                self.closemove2,
                self.Bmovey - self.btnwidth / 2 - self.padding1 / 2
            ],
             [
                 self.Cmovex + self.midmove - self.twomove - self.closemove,
                 self.Bmovey + self.btnwidth / 2 + self.padding1 / 2
             ],
             [
                 self.Cmovex + self.midmove + self.btnwidth - self.twomove +
                 10 - self.closemove,
                 self.Bmovey + self.btnwidth / 2 + self.padding1 / 2
             ],
             [
                 self.Cmovex + self.twomove / 2 - self.closemove -
                 self.closemove2,
                 self.Bmovey + self.btnwidth * 3 / 2 + self.padding1 * 3 / 2
             ]]
        ]
        self.child = []
        # for item in self.child:
        #     item
        #读取图片
        self.titleimage = ImageTk.PhotoImage(
            Image.open("srcimage/title.jpg").resize(
                (int(winwidth / 3) + 1, int(winheight / 7) + 1)))
        self.backgroundimage = ImageTk.PhotoImage(
            Image.open("srcimage/background.jpg").resize(
                (int(winwidth), int(winheight))))
        self.bookimage = ImageTk.PhotoImage(
            Image.open("srcimage/photos.jpg").resize(
                (int(self.btnwidth) + 2, int(self.btnwidth) + 2)))
        self.movieimage = ImageTk.PhotoImage(
            Image.open("srcimage/video.jpg").resize(
                (int(self.btnwidth) + 2, int(self.btnwidth) + 2)))
        self.musicimage = ImageTk.PhotoImage(
            Image.open("srcimage/music.jpg").resize(
                (int(self.btnwidth) + 2, int(self.btnwidth) + 2)))
        self.studyimage = ImageTk.PhotoImage(
            Image.open("srcimage/emecall.jpg").resize(
                (int(self.btnwidth) + 2, int(self.btnwidth) + 2)))
        self.gameimage = ImageTk.PhotoImage(
            Image.open("srcimage/phone.jpg").resize(
                (int(self.btnwidth) + 2, int(self.btnwidth) + 2)))
        self.hearto2image = ImageTk.PhotoImage(
            Image.open("srcimage/hearto2.jpg").resize(
                (int(self.btnwidth) + 2, int(self.btnwidth) + 2)))
        self.clockimage = ImageTk.PhotoImage(
            Image.open("srcimage/clock.jpg").resize(
                (int(self.btnwidth) + 2, int(self.btnwidth) + 2)))
        self.environmentimage = ImageTk.PhotoImage(
            Image.open("srcimage/environment.jpg").resize(
                (int(self.btnwidth) + 2, int(self.btnwidth) + 2)))

        self.workimage = ImageTk.PhotoImage(
            Image.open("srcimage/looking.jpg").resize(
                (int(self.Bigbtnwidth), int(self.Bigbtnwidth))))
        self.faceback = ImageTk.PhotoImage(
            Image.open("srcimage/faceback.jpg").resize(
                (int(self.Bigbtnwidth) + 2, int(self.Bigbtnwidth))))
        self.closeimage = ImageTk.PhotoImage(
            Image.open("srcimage/close.jpg").resize(
                (int(self.closebtnwidth) + 4, int(self.closebtnwidth) + 4)))
        self.playclockimage = ImageTk.PhotoImage(
            Image.open("srcimage/playclock.jpg").resize(
                (int(self.playclockwidth), int(self.playclockheight))))

        self.lsmile0 = ImageTk.PhotoImage(
            Image.open("srcimage/smile0.jpg").resize(
                (int(self.littlewidth), int(self.littleheight))))
        self.lsmile1 = ImageTk.PhotoImage(
            Image.open("srcimage/smile1.jpg").resize(
                (int(self.littlewidth), int(self.littleheight))))
        self.lsmile2 = ImageTk.PhotoImage(
            Image.open("srcimage/smile2.jpg").resize(
                (int(self.littlewidth), int(self.littleheight))))
        self.lsmile3 = ImageTk.PhotoImage(
            Image.open("srcimage/smile3.jpg").resize(
                (int(self.littlewidth), int(self.littleheight))))
        self.lhappy = ImageTk.PhotoImage(
            Image.open("srcimage/happy.jpg").resize(
                (int(self.littlewidth), int(self.littleheight))))
        self.ldislike = ImageTk.PhotoImage(
            Image.open("srcimage/dislike.jpg").resize(
                (int(self.littlewidth), int(self.littleheight))))
        # 右边的三个按钮
        self.buttonA_1 = tk.Button(self.initface,
                                   image=self.bookimage,
                                   height=self.btnwidth,
                                   width=self.btnwidth,
                                   relief="groove",
                                   command=self.gotophoto,
                                   bd=0,
                                   highlightthickness=0,
                                   highlightcolor="white")
        self.buttonA_1.place(x=self.move[0][0][0], y=self.move[0][0][1])
        self.buttonA_2 = tk.Button(self.initface,
                                   image=self.movieimage,
                                   height=self.btnwidth,
                                   width=self.btnwidth,
                                   relief="groove",
                                   command=self.gotovideo,
                                   bd=0,
                                   highlightthickness=0)
        self.buttonA_2.place(x=self.move[0][1][0], y=self.move[0][1][1])
        self.buttonA_3 = tk.Button(self.initface,
                                   image=self.musicimage,
                                   height=self.btnwidth,
                                   width=self.btnwidth,
                                   relief="groove",
                                   command=self.gotomusic,
                                   bd=0,
                                   highlightthickness=0)
        self.buttonA_3.place(x=self.move[0][2][0], y=self.move[0][2][1])
        self.buttonA_4 = tk.Button(self.initface,
                                   image=self.environmentimage,
                                   height=self.btnwidth,
                                   width=self.btnwidth,
                                   relief="groove",
                                   command=self.gotoenvpage,
                                   bd=0,
                                   highlightthickness=0)
        self.buttonA_4.place(x=self.move[0][3][0], y=self.move[0][3][1])
        # 交大的校徽
        self.titleCanvas = tk.Canvas(self.initface,
                                     width=self.Bigbtnwidth,
                                     height=winheight / 7)
        self.titleCanvas.place(x=self.move[1][0][0], y=self.move[1][0][1])
        self.titleCanvas.create_image(0, 0, anchor='nw', image=self.titleimage)
        self.titleCanvas.configure(highlightthickness=0)
        # 中间的按钮
        self.buttonB = tk.Button(self.initface,
                                 image=self.faceback,
                                 height=int(winheight / 3) + 50,
                                 width=int(winwidth / 3),
                                 relief="groove",
                                 bd=0,
                                 highlightthickness=0)
        self.buttonB.place(x=self.move[1][1][0], y=self.move[1][1][1])
        #下面的文字
        self.wordcanvas = tk.Canvas(self.initface,
                                    bg="white",
                                    width=winwidth / 3,
                                    height=100,
                                    highlightthickness=0)
        self.wordcanvas.place(x=self.move[1][2][0], y=self.move[1][2][1])
        self.wordcanvas.create_text(winwidth / 6,
                                    50,
                                    text="知心小雨为您服务",
                                    font=("宋体", 20))
        # 左边的三个按钮
        self.buttonC_1 = tk.Button(self.initface,
                                   image=self.studyimage,
                                   height=self.btnwidth,
                                   width=self.btnwidth,
                                   relief="groove",
                                   command=self.emecall,
                                   bd=0,
                                   highlightthickness=0)
        self.buttonC_1.place(x=self.move[2][0][0], y=self.move[2][0][1])
        self.buttonC_2 = tk.Button(self.initface,
                                   image=self.gameimage,
                                   height=self.btnwidth,
                                   width=self.btnwidth,
                                   relief="groove",
                                   command=self.callfamily,
                                   bd=0,
                                   highlightthickness=0)
        self.buttonC_2.place(x=self.move[2][1][0], y=self.move[2][1][1])
        self.buttonC_3 = tk.Button(self.initface,
                                   image=self.clockimage,
                                   height=self.btnwidth,
                                   width=self.btnwidth,
                                   relief="groove",
                                   bd=0,
                                   highlightthickness=0,
                                   command=self.gotoclockpage)
        self.buttonC_3.place(x=self.move[2][2][0], y=self.move[2][2][1])
        self.buttonC_4 = tk.Button(self.initface,
                                   image=self.hearto2image,
                                   height=self.btnwidth,
                                   width=self.btnwidth,
                                   relief="groove",
                                   bd=0,
                                   highlightthickness=0,
                                   command=self.gotoheartpage)
        self.buttonC_4.place(x=self.move[2][3][0], y=self.move[2][3][1])
        #关闭按钮
        self.closebtn = tk.Button(self.initface,
                                  image=self.closeimage,
                                  width=self.closebtnwidth,
                                  height=self.closebtnwidth,
                                  bd=0,
                                  command=self.destroypage)
        self.closebtn.place(x=winwidth - self.closebtnwidth, y=0)
        self.facepage = tk.Canvas(self.master,
                                  width=self.littlewidth,
                                  height=self.littleheight,
                                  highlightthickness=0)
        self.facepage.place(x=(winwidth - self.littlewidth) / 2,
                            y=(winheight - self.littleheight) / 2 + 15)
        self.facepage.create_image(0, 0, anchor='nw', image=self.lsmile0)
        self.playclock = tk.Canvas(self.initface,
                                   width=self.playclockwidth,
                                   height=self.playclockheight)
        self.playclock.create_image(0,
                                    0,
                                    anchor="nw",
                                    image=self.playclockimage)
        self.hearto2page = []
        self.tasklist = []
        self.readclock()
        #刷新显示图片
        #人工智障
        _thread.start_new_thread(self.playface, ("threadname", 1))
        #语音控制
        _thread.start_new_thread(self.readtext, ("treadname", 1))
        _thread.start_new_thread(self.starttest, ("treadname", 1))
        #闹钟
        _thread.start_new_thread(self.clock, ("threadname", 1))
예제 #11
0
    dialog.Destroy()
    img = Image.open(filepath)
    width, height = img.size
    scale = width / height
    if scale > 0:
        height = CANVAS_SIZE / scale
    else:
        height = CANVAS_SIZE * scale
    img = ImageTk.PhotoImage(img.resize((CANVAS_SIZE, round(height))))
    canv.create_image(CANVAS_SIZE/2, CANVAS_SIZE/2, image=img)
    if round(pr.predict(filepath)) == 1:
        messagebox.showinfo("Prediction", "This is a dog.")
    else:
        messagebox.showinfo("Prediction", "This is a cat.")


# Creating the main window
window = tk.Tk()
window.geometry("600x600")
window.resizable(0, 0)
window.title("Recognizing Dogs And Cats")
window.configure(background='#94fffb')
load_image_button = tk.Button(window, text="Load The Image And See The Prediction!", command=load_and_predict, width=40,
                              background='#33ff3a')
load_image_button.place(relx=0.5, rely=0.075, anchor='center')
canv = tk.Canvas(window, width=CANVAS_SIZE, height=CANVAS_SIZE, bg='white')
canv.place(relx=0.5, rely=0.5, anchor='center')
exit_button = tk.Button(window, text="Exit", command=exit, width=20, background='#fa2d2d')
exit_button.place(relx=0.5, rely=0.925, anchor='center')
tk.mainloop()