Example #1
0
class App:
    #constructor
    def __init__(self):
        self.data=data
        self.fewarrows=0
        self.MakeWindow()
        self.refreshDataFrame()
        self.refreshPicFrame()
        self.fixent=1 #UGLY FIX FOR ENTRIES/ENTRIESIJ
        # self.root.mainloop() -maybe needed for Windows OS


    #makes frames and frames within frames needed for correct display
    def MakeWindow (self):
        self.root=tk.Tk()
        self.root.wm_title("Data Input and Graphical Output")
        self.outsideframed1=tk.Frame(self.root,width=300, height=800)
        self.outsideframepic=tk.Frame(self.root,width=675, height=800)
        self.outsideframed1.pack(side=tk.LEFT,fill=None,expand=False)
        self.outsideframepic.pack(side=tk.LEFT,fill=None,expand=False)                                 
        self.outsideframed1.pack_propagate(False) 
        self.outsideframepic.pack_propagate(False)      
        self.framed1=tk.Frame(self.outsideframed1,width=200, height=100)
        self.framed1.pack(side=tk.LEFT,fill=None,expand=False)
        self.framepic=tk.Frame(self.outsideframepic,borderwidth=5,relief=tk.RIDGE)
        self.framepic.pack(side=tk.TOP,fill=tk.BOTH,expand=1) #BIG-BAD
        self.refreshDataFrame()
        self.refreshPicFrame()

    
    #makes the plot: boxes and the (fancy) arrows connecting them
    def createBoxGraph(self):
        TextBox.list_box=[]  #CLEAR ALL PREVIOUS!!!
        f = plt.figure(facecolor = 'white')
        f.set_size_inches(8,10)
        a = f.add_subplot(111)
        a.axis('off')
        for index in range(len(data.b)):
            xy=data.bxy[index]
            TextBox(a,xy[0],xy[1],data.b[index],index,data.labels[index],data.boxcolor[index])
        id=0
        if (self.fewarrows==0):
            for i in range(len(data.b)):
                for j in range(len(data.b)):
                    if i!=j and data.a[i][j]!=0:
                        arrow=ArrowObject(a,i,j,id)
                        id=id+1
        else:
            i=self.box_id
            for j in range(len(data.b)):
                if i!=j and data.a[i][j]!=0:
                    arrow=ArrowObject(a,i,j,id)
                    id=id+1
            j=self.box_id
            for i in range(len(data.b)):
                if i!=j and data.a[i][j]!=0:
                    arrow=ArrowObject(a,i,j,id)
                    id=id+1
        plt.show(block=False)
        #coding trick to close extra figures accidentally created in canvas----
        openfigs=plt.get_fignums()
        last=openfigs[-1]
        plt.close(last)
        #coding trick to close extra figures accidentally created in canvas----
        return f

    
    #used to scale the sizes of the textboxes
    def scalebox(vector):
        data2=[0 for i in range(len(vector))]
        minbox,maxbox=2,30
        minb,maxb=min(vector),max(vector)
        if minb!=maxb:
            data2=[(vector[i]-minb)/(maxb-minb) for i in range(len(vector))]
            vectornew=[(maxbox-minbox)*data2[i]+minbox for i in range(len(vector))]
        else:
            vectornew=[(minbox+maxbox)/2. for i in range(len(vector))]
        return vectornew


    #Euler numerical integration of the ordinary differential equations
    def recalculate(self,pass_data):
        #UGLY FIX FOR ENTRIES/ENTRIESIJ----------------------------------------
        if self.fixent==1:
            self.data.z[0]=[eval((self.entries[i][1].get())) for i in range(len(self.entries))]
        if self.fixent==2:
            column=[eval((self.entriesIJ[i][1].get())) for i in range(len(self.entriesIJ))]
            self.data.ca[:,self.box_id]=column
        #UGLY FIX FOR ENTRIES/ENTRIESIJ----------------------------------------
        self.fewarrows=0
        pass_data.tt=0
        for i in range (1,pass_data.numdata):
            mtanh=np.tanh(pass_data.z[i-1])
            cterm=np.dot(pass_data.ca,mtanh)
            pass_data.dx=pass_data.dt*(pass_data.ma*pass_data.z[i-1] + pass_data.ba + cterm)
            pass_data.tt=pass_data.tt+pass_data.dt
            pass_data.t[i]=pass_data.tt
            pass_data.z[i]=pass_data.z[i-1]+pass_data.dx
            for j in range(pass_data.numc):
                pass_data.z[i][j]=max(pass_data.z[i][j],0.)
                #holding values constant
                if pass_data.hold==1:
                    pass_data.z[i][pass_data.jfix]=pass_data.jvalue
        #make new plot
        App.MakePlot(data)
        #scale b's from z[-1]
        vector=data.z[-1]
        data.b=App.scalebox(vector)
        #set z[0]=z[-1] for the NEXT iteration
        pass_data.z[0]=pass_data.z[-1]
        #CLEAR and REFRESH DATA and PIC frames
        App.ClearFrame(self.framed1)
        App.ClearFrame(self.framepic)
        self.refreshDataFrame()
        self.refreshPicFrame()        
     
        
    #makes plot of x(i) vs. time
    def MakePlot(pass_data):
        print('\nYour plot is ready')
        localtime = time.asctime( time.localtime(time.time()) )
        x_start=pass_data.z[0]
        x_final=pass_data.z[-1]
        plt.figure()
        plt.axes([0.1,.075,.8,.7])
        plt.plot(pass_data.t,pass_data.z[:,0:pass_data.numc])
        #print labels on lines
        xtext=25
        for i in range (pass_data.numc):
            ytext=pass_data.z[-1,i]
            varis=str(i) #first variable is 0
            plt.text(xtext,ytext,varis)
            xtext=xtext-1    
        programname='teal.py, tealclass.py, data.py   '+localtime
        param1='\n   input files= '+str(pass_data.fnamec)+'    '    +str(pass_data.fnameb)+'    '+str(pass_data.fnamem) +'    '+str(pass_data.fnamebtextbxy) + '     dt='+str(pass_data.dt)
        start=App.displayinput(pass_data.z[0],75)
        finish=App.displayinput(pass_data.z[-1],75)
        param2='\nstart=  ' + start + '\nfinish=  ' + finish
        titlelsl=programname+param1 + param2
        plt.title(titlelsl, fontsize=8)
        plt.show(block=False) #IMPORTANT: to SHOW graph but NOT stop execution
      
        
    #rounds numbers for x(start), x(final) in the title of plot x(i) vs. time
    def displayinput(vector1,number):
        #creates string to print from np.array(vector1)
        #that is approximately number characters per line
        c=''
        v1=vector1.tolist()
        v2=[round(v1[i],6) for i in range (len(v1))]
        a=str(v2)
        a2=a.replace(' ','')
        a3=list(a2)
        a3[0],a3[-1]='',''
        numend=0
        for i in range(0,len(a3)):
            if (a3[i]==',' and numend >= number):
                numend=0
                a3[i]=',\n'
            numend=numend+1
        c=''.join(a3)
        c2=c.replace(',',',  ')
        return c2

    
    #clear and refresh ONLY the left initial condition dataframe
    def refreshDataFrame(self):
        self.fixent=1 #UGLY FIX FOR ENTRIES/ENTRIESIJ
        App.ClearFrame(self.framed1)
        #frame and buttons on top
        newframe=tk.Frame(self.framed1)
        newframe.pack(side=tk.TOP,pady=0)
        tk.Label(newframe,text='initial conditions',fg='blue').pack(side=tk.LEFT,padx=30,pady=5)
        tk.Button(newframe,text='original',command= self.resetIC).pack(side=tk.RIGHT,padx=30,pady=5)
        newframe2=tk.Frame(self.framed1)
        newframe2.pack(side=tk.TOP,pady=0)
        cal1=tk.Button(newframe2,text='CALCULATE',command=(lambda: self.recalculate(data)))
        cal1.pack(side=tk.LEFT,padx=30,pady=5)
        tk.Button(newframe2,text='ENTER',command=self.refreshPicFrame).pack(side=tk.LEFT,padx=30,pady=5)      
        #frame for entry widgets for initial conditions
        self.framecanvas=tk.Frame(self.framed1)
        self.framecanvas.pack(side=tk.BOTTOM,pady=0)
        #adding the scroll bar
        sizescroll=31*data.numc
        self.canvas = tk.Canvas(self.framecanvas,width=400,height=800,scrollregion=(0,0,sizescroll,sizescroll)) #FROM LAUNY
        self.canvas.pack(side=tk.LEFT)
        scrollbar = tk.Scrollbar(self.framecanvas, command=self.canvas.yview)
        scrollbar.pack(side=tk.LEFT, fill='y')
        self.canvas.config(width=280,height=800)
        self.canvas.configure(yscrollcommand = scrollbar.set)
        self.frame = tk.Frame(self.canvas)
        self.canvas.create_window((0,0), window=self.frame, anchor='nw')
        # creating the initial condition entry widgets     
        fields=data.labels
        default=[str(i) for i in range(len(data.labels))]
        entries = []
        self.data.zround=[str(round(self.data.z[-1,i],6)) for i in range(len(self.data.z[0]))]                                                           
        for field in fields:
            row = tk.Frame(self.frame)
            lab = tk.Label(row, width=12, text=field, anchor='w')
            ent = tk.Entry(row,width=10)
            row.pack(side=tk.TOP, padx=5, pady=0, expand=1)
            lab.pack(side=tk.LEFT,expand=1)
            ent.pack(side=tk.RIGHT, expand=tk.YES, fill=tk.Y)
            ent.insert(10,self.data.zround[fields.index(field)])
            entries.append((field, ent))
            self.entries=entries
        #TRANSFORM ALL ENTRIES INTO STARTING VALUES FOR COMPUTATION
        self.data.z[0]=[eval((entries[i][1].get())) for i in range(len(entries))]
        self.outsideframed1.pack(expand=1)  #KEEPING THIS FOR THE MOMENT HERE
        return
        
    
    #redraw the textboxes and the arrows connecting them
    def refreshPicFrame(self):
        #UGLY FIX FOR ENTRIES/ENTRIESIJ----------------------------------------
        if self.fixent==1:
            self.data.z[0]=[eval((self.entries[i][1].get())) for i in range(len(self.entries))]
        if self.fixent==2:
            column=[eval((self.entriesIJ[i][1].get())) for i in range(len(self.entriesIJ))]
            self.data.ca[:,self.box_id]=column
        #UGLY FIX FOR ENTRIES/ENTRIESIJ----------------------------------------        
        #scale b's from z[0] - NOT Z[-1] like in A NEW CALCULATION
        vector=data.z[0]
        self.data.b=App.scalebox(vector)
        #set z[0]=z[-1] for the NEXT iteration
        App.ClearFrame(self.framepic)  
        self.canvas=tk.Canvas(self.framepic,width=800, height=2400)
        f=self.createBoxGraph()
        self.canvas = FigureCanvasTkAgg(f, master=self.framepic)
        self.canvas.show()
        self.canvas._tkcanvas.pack()
        cid=f.canvas.mpl_connect('button_press_event',self.onclick)
        
    
    #clear and refresh ONLY the left cij adjacency matrix dataframe
    def refreshCIJFrame(self):
        self.fixent=2 #UGLY FIX FOR ENTRIES/ENTRIESIJ
        App.ClearFrame(self.framed1)
        fromto='FROM    '+data.labels[self.box_id]+'    TO'
        #frame and top buttons
        newframe=tk.Frame(self.framed1)
        newframe.pack(side=tk.TOP,pady=0)
        tk.Label(newframe,text=fromto,bg='thistle1',fg='red').pack(side=tk.LEFT,padx=5)
        tk.Button(newframe,text='ALL Cij',command= self.FullrefreshPicFrame).pack(side=tk.LEFT,padx=5)
        tk.Button(newframe,text='IC',command= self.refreshDataFrame).pack(side=tk.LEFT,padx=5)
        newframe2=tk.Frame(self.framed1)
        newframe2.pack(side=tk.TOP,pady=0)
        cal2=tk.Button(newframe2,text='CALCULATE',command=(lambda: self.recalculate(data)))
        cal2.pack(side=tk.LEFT,padx=30,pady=5)
        tk.Button(newframe2,text='ENTER',command=self.refreshPicFrame).pack(side=tk.LEFT,padx=30,pady=5)  
        #frame for entry widgets for cij adjacency matrix
        self.framecanvas=tk.Frame(self.framed1)
        self.framecanvas.pack(side=tk.BOTTOM,pady=0)
        #adding the scroll bar
        sizescroll=31*data.numc
        self.canvas = tk.Canvas(self.framecanvas,width=400,height=800,scrollregion=(0,0,sizescroll,sizescroll)) #FROM LAUNY
        self.canvas.pack(side=tk.LEFT)
        scrollbar = tk.Scrollbar(self.framecanvas, command=self.canvas.yview)
        scrollbar.pack(side=tk.LEFT, fill='y')
        self.canvas.config(width=280,height=800)
        self.canvas.configure(yscrollcommand = scrollbar.set)
        self.frame = tk.Frame(self.canvas)
        self.canvas.create_window((0,0), window=self.frame, anchor='nw')
        # creating the cij adjacency matrix entry widgets
        fields=self.data.labels
        entriesIJ = []                                                         
        for field in fields:
            row = tk.Frame(self.frame)
            lab = tk.Label(row, width=15, text=field, anchor='w',bg='thistle1')
            entIJ = tk.Entry(row,bg='thistle1')
            row.pack(side=tk.TOP, padx=5, pady=1, expand=1)
            lab.pack(side=tk.LEFT,expand=1)
            entIJ.pack(side=tk.RIGHT, expand=tk.YES, fill=tk.Y)
            entIJ.insert(10,self.data.ca[fields.index(field)][self.box_id])
            entriesIJ.append((field, entIJ))
            self.entriesIJ=entriesIJ
        #TRANSFORM ALL ENTRIES INTO STARTING VALUES FOR COMPUTATION
        column=[eval((self.entriesIJ[i][1].get())) for i in range(len(self.entriesIJ))]
        self.data.ca[:,self.box_id]=column
        self.outsideframed1.pack(expand=1)
        return


    #return the textbox id that was clicked
    def onclick(self,event):
        for box in TextBox.list_box:
            contains, attrd = box.text.contains(event)
            if(contains):
                id=box.id
                print('\nid,bname(id)=  ',id, data.labels[id])
                # print('box_%d'  % id)
                # print('box_' + data.bname[id])
                # print('show vars ')
                # self.update_dataFrame(id)
                self.box_id=id
                self.fewarrows=1
                self.refreshCIJFrame()
                # TextBox.selected_box_id=id
                return;
                
    
    #reset the initial conditions to the input data ic(i) default values
    def resetIC(self):
        self.data.z[-1]=[self.data.ica[i] for i in range(len(self.data.z[0]))]
        self.refreshDataFrame()
    
    
    #not used
    def FullrefreshPicFrame(self):
        self.fewarrows=0
        self.refreshPicFrame()
    
    
    #not used, but nice to have to end execution
    def myquit(self):
        print ('\n I did press CLOSE!')
        self.root.destroy()
        
    
    #removes ALL widgets in frame
    #seemed a better option than forget
    def ClearFrame(frame):
        for widget in frame.winfo_children():
            widget.destroy()
        # frame.pack_forget()
        
    
    #not used
    #thought needed for binding scroll bar, apparently not
    def on_configure(event):
    # update scrollregion after starting 'mainloop'
    # when all widgets are in canvas
#         self.canvas=canvas
        canvas.configure(scrollregion=canvas.bbox('all'))
        
#summing postive and negtive into two seperate arrays  
#   pass_data.negindex/posindex are not needed
# to excute run App.sumpn(pass_data)        
    def sumpn(pass_data):
        negkeys={} # will be used for get the keys to be used in the summing
        poskeys={}
        pass_data.avg=0
        pass_data.avgpos=0
        pass_data.avgneg=0
        for x in range(0,len(pass_data.btextbxydata)):
            if (pass_data.btextbxydata[x][1]=="gray"):
                #pass_data.negindex.append(x)
                pass_data.negfin[x]=pass_data.z[-1][x]
                negkeys=list(pass_data.negfin.keys())
            else:
                #pass_data.posindex.append(x)
                pass_data.posfin[x]=pass_data.z[-1][x]
                poskeys=list(pass_data.posfin.keys())
        #adding the positve and negative values
        for i in range(0,len(negkeys)):
            pass_data.sumneg+=pass_data.negfin[negkeys[i]]
            pass_data.avgneg=(pass_data.sumneg/len(negkeys))
            if(i==(len(negkeys)-1)): 
                pass_data.sumneg=0
                pass_data.negfin={}
        for j in range(0,len(poskeys)):
            pass_data.sumpos+=pass_data.posfin[poskeys[j]]
            
            pass_data.avgpos=(pass_data.sumpos/len(poskeys))
            if(j==(len(poskeys)-1)):
                pass_data.sumpos=0
                pass_data.posfin={}
        pass_data.avg=pass_data.avgpos-pass_data.avgneg
        pass_data.avgpos=0
        pass_data.avgneg=0
Example #2
0
class Treadmill:
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#d9d9d9'  # X11 color: 'gray85'
        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.', background=_bgcolor)
        self.style.configure('.', foreground=_fgcolor)
        self.style.configure('.', font="TkDefaultFont")
        self.style.map('.',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])

        top.geometry("1024x600+0+0")
        top.attributes("-fullscreen", True)
        top.title("Treadmill")
        top.configure(highlightcolor="black")

        self.style.configure('TNotebook.Tab', background=_bgcolor)
        self.style.configure('TNotebook.Tab', foreground=_fgcolor)
        self.style.map('TNotebook.Tab',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])
        self.TNotebook1 = ttk.Notebook(top)
        self.TNotebook1.place(relx=0.019,
                              rely=0.1,
                              relheight=0.887,
                              relwidth=0.967)
        self.TNotebook1.configure(width=1002)
        self.TNotebook1.configure(takefocus="")
        self.TNotebook1_t0 = Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t0, padding=3)
        self.TNotebook1.tab(
            0,
            text="Graph",
            compound="left",
            underline="-1",
        )
        self.TNotebook1_t1 = Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t1, padding=3)
        self.TNotebook1.tab(
            1,
            text="Recap",
            compound="left",
            underline="-1",
        )

        ## grafik kanvas
        ##        f = Figure(figsize=(8,4), dpi=100)
        ##        a = f.add_subplot(111)
        ####t = arange(0.0, 3.0, 0.01)
        ####s = sin(2*pi*t)
        ####
        ####a.plot(t, s)
        ##        a.plot([1,2,3,4,5,6,7,8],[60,65,85,90,92,95,94,90])
        ##        a.set_title('BPM')
        ##        a.set_xlabel('X axis label')
        ##        a.set_ylabel('Y label')

        # data
        ##        global waktu

        ##        dir = open('path.txt', 'r', os.O_NONBLOCK).read()
        ##        data_dir = open(dir, 'r', os.O_NONBLOCK).read()
        data_dir = open(
            '/home/pi/Downloads/page/logs/log_22-12-2018 23:32:22.txt', 'r',
            os.O_NONBLOCK).read()
        lines = data_dir.split('\n')
        batas = len(lines) - 2

        waktu = []
        bpm = []
        step = []
        spd = []
        dist = []
        kal = []
        mn = []
        mx = []
        spdm = []

        for line in lines:
            ##    for line in lines:
            ##     (timeString, hr, steps, speed, jarak, cal, min, max, speed_mode)
            if len(line) >= 1:
                a, b, c, d, e, f, g, h, i = line.split(',')
                waktu.append(str(a))
                bpm.append(str(b))
                step.append(str(c))
                spd.append(str(d))
                dist.append(str(e))
                kal.append(str(f))
                mn.append(str(g))
                mx.append(str(h))
                spdm.append(str(i))


##        print (bpm, len(lines))
        numbering = []
        selector = []
        max_cal = max(kal)
        max_bpm = max(bpm)

        ##        print (bpm, kal)

        for min in range(0, len(bpm), 5):
            selector.append(int(bpm[min]))
            numbering.append(len(selector))

        average = int(sum(selector) / len(selector))
        ##        maxhr = max(selector)
        # a tk.DrawingArea
        currentDT = datetime.datetime.now()
        time_stamp = currentDT.strftime("%d-%m-%Y %H:%M:%S")
        file_path = '/home/pi/Downloads/page/recap/log_' + time_stamp + '.txt'
        fp = open(file_path, 'a', os.O_NONBLOCK)
        data = "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n" % (
            waktu[batas], step[batas], spd[batas], dist[batas], max_cal, mn[0],
            mx[0], spdm[0], max_bpm, average)
        result = firebase.post(
            '/data', {
                'mode': spdm[0],
                'time': waktu[batas],
                'timestamp': time_stamp,
                'step': step[batas],
                'speed': spd[batas],
                'distance': dist[batas],
                'calories': max_cal,
                'THRmin': mn[0],
                'THRmax': mx[0],
                'maximum_bpm': max_bpm,
                'average': average
            })
        print(result)
        fp.write(data)
        ##    print (data)
        fp.close

        self.Canvas1 = Canvas(self.TNotebook1_t0)
        self.Canvas1.place(relx=0.08,
                           rely=0.118,
                           relheight=0.865,
                           relwidth=0.821)
        self.Canvas1.configure(borderwidth="2")
        self.Canvas1.configure(relief=RIDGE)
        self.Canvas1.configure(selectbackground="#c4c4c4")
        self.Canvas1.configure(width=821)
        self.f = Figure(figsize=(8, 4), dpi=100)
        self.a = self.f.add_subplot(111)
        self.a.plot(numbering, selector)
        self.a.set_title('BPM')
        self.a.set_xlabel('time')
        self.a.set_ylabel('Heart Rate (Bpm)')
        self.Canvas1 = FigureCanvasTkAgg(self.f, self.Canvas1)
        self.Canvas1.draw()
        self.Canvas1.get_tk_widget().pack()
        self.Canvas1._tkcanvas.pack(fill=BOTH, expand=1)

        self.Label1 = Label(self.TNotebook1_t0)
        self.Label1.place(relx=0.08, rely=0.059, height=17, width=84)
        self.Label1.configure(activebackground="#f9f9f9")
        self.Label1.configure(text='''Heart Rate''')

        self.Label2 = Label(self.TNotebook1_t0)
        self.Label2.place(relx=0.21, rely=0.059, height=17, width=34)
        self.Label2.configure(activebackground="#f9f9f9")
        self.Label2.configure(text='''Max :''')

        self.max_hr = Label(self.TNotebook1_t0)
        self.max_hr.place(relx=0.27, rely=0.059, height=17, width=78)
        self.max_hr.configure(activebackground="#f9f9f9")
        self.max_hr.configure(text=max_bpm)

        self.Label4 = Label(self.TNotebook1_t0)
        self.Label4.place(relx=0.4, rely=0.059, height=17, width=58)
        self.Label4.configure(activebackground="#f9f9f9")
        self.Label4.configure(text='''Average :''')

        self.avg_hr = Label(self.TNotebook1_t0)
        self.avg_hr.place(relx=0.48, rely=0.059, height=17, width=108)
        self.avg_hr.configure(activebackground="#f9f9f9")
        self.avg_hr.configure(text=average)

        self.Labelframe1 = LabelFrame(self.TNotebook1_t1)
        self.Labelframe1.place(relx=0.02,
                               rely=0.02,
                               relheight=0.951,
                               relwidth=0.96)
        self.Labelframe1.configure(relief=GROOVE)
        self.Labelframe1.configure(text='''Labelframe''')
        self.Labelframe1.configure(width=960)

        self.Labelframe2 = LabelFrame(self.Labelframe1)
        self.Labelframe2.place(relx=0.229,
                               rely=0.247,
                               relheight=0.299,
                               relwidth=0.156,
                               bordermode='ignore')
        self.Labelframe2.configure(relief=GROOVE)
        self.Labelframe2.configure(text='''Average Heart Rate''')
        self.Labelframe2.configure(width=150)

        self.avg_heart = Label(self.Labelframe2)
        self.avg_heart.place(relx=0.133,
                             rely=0.207,
                             height=37,
                             width=114,
                             bordermode='ignore')
        self.avg_heart.configure(activebackground="#f9f9f9")
        self.avg_heart.configure(text=average)

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.552,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''BPM''')

        self.Labelframe2 = LabelFrame(self.Labelframe1)
        self.Labelframe2.place(relx=0.417,
                               rely=0.247,
                               relheight=0.299,
                               relwidth=0.156,
                               bordermode='ignore')
        self.Labelframe2.configure(relief=GROOVE)
        self.Labelframe2.configure(text='''Total Steps''')
        self.Labelframe2.configure(width=150)

        self.step_val = Label(self.Labelframe2)
        self.step_val.place(relx=0.133,
                            rely=0.207,
                            height=37,
                            width=114,
                            bordermode='ignore')
        self.step_val.configure(activebackground="#f9f9f9")
        self.step_val.configure(text=step[batas])

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.552,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Steps''')

        self.Labelframe2 = LabelFrame(self.Labelframe1)
        self.Labelframe2.place(relx=0.604,
                               rely=0.247,
                               relheight=0.299,
                               relwidth=0.156,
                               bordermode='ignore')
        self.Labelframe2.configure(relief=GROOVE)
        self.Labelframe2.configure(text='''Burned Calories''')
        self.Labelframe2.configure(width=150)

        self.cal_val = Label(self.Labelframe2)
        self.cal_val.place(relx=0.133,
                           rely=0.207,
                           height=37,
                           width=114,
                           bordermode='ignore')
        self.cal_val.configure(activebackground="#f9f9f9")
        self.cal_val.configure(text=max_cal)

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.552,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Cal''')

        self.Labelframe2 = LabelFrame(self.Labelframe1)
        self.Labelframe2.place(relx=0.229,
                               rely=0.557,
                               relheight=0.299,
                               relwidth=0.156,
                               bordermode='ignore')
        self.Labelframe2.configure(relief=GROOVE)
        self.Labelframe2.configure(text='''Maximum Heart Rate''')
        self.Labelframe2.configure(width=150)

        self.max_heart_val = Label(self.Labelframe2)
        self.max_heart_val.place(relx=0.133,
                                 rely=0.207,
                                 height=37,
                                 width=114,
                                 bordermode='ignore')
        self.max_heart_val.configure(activebackground="#f9f9f9")
        self.max_heart_val.configure(text=max_bpm)

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.552,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''BPM''')

        self.Labelframe2 = LabelFrame(self.Labelframe1)
        self.Labelframe2.place(relx=0.417,
                               rely=0.557,
                               relheight=0.299,
                               relwidth=0.156,
                               bordermode='ignore')
        self.Labelframe2.configure(relief=GROOVE)
        self.Labelframe2.configure(text='''Treadmill Mode''')
        self.Labelframe2.configure(width=150)

        self.step_per_min_val = Label(self.Labelframe2)
        self.step_per_min_val.place(relx=0.133,
                                    rely=0.207,
                                    height=37,
                                    width=114,
                                    bordermode='ignore')
        self.step_per_min_val.configure(activebackground="#f9f9f9")
        self.step_per_min_val.configure(text=spdm[0])

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.552,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Steps''')

        self.Labelframe2 = LabelFrame(self.Labelframe1)
        self.Labelframe2.place(relx=0.604,
                               rely=0.557,
                               relheight=0.299,
                               relwidth=0.156,
                               bordermode='ignore')
        self.Labelframe2.configure(relief=GROOVE)
        self.Labelframe2.configure(text='''Distance''')
        self.Labelframe2.configure(width=150)

        self.dist_val = Label(self.Labelframe2)
        self.dist_val.place(relx=0.133,
                            rely=0.207,
                            height=37,
                            width=114,
                            bordermode='ignore')
        self.dist_val.configure(activebackground="#f9f9f9")
        self.dist_val.configure(text=dist[batas])

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.552,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Km''')

        self.Labelframe2 = LabelFrame(self.Labelframe1)
        self.Labelframe2.place(relx=0.052,
                               rely=0.392,
                               relheight=0.299,
                               relwidth=0.156,
                               bordermode='ignore')
        self.Labelframe2.configure(relief=GROOVE)
        self.Labelframe2.configure(text='''Speed''')
        self.Labelframe2.configure(width=150)

        self.speed_val = Label(self.Labelframe2)
        self.speed_val.place(relx=0.133,
                             rely=0.207,
                             height=37,
                             width=114,
                             bordermode='ignore')
        self.speed_val.configure(activebackground="#f9f9f9")
        self.speed_val.configure(text=spd[batas])

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.552,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Km/hr''')

        self.Labelframe2 = LabelFrame(self.Labelframe1)
        self.Labelframe2.place(relx=0.781,
                               rely=0.392,
                               relheight=0.299,
                               relwidth=0.156,
                               bordermode='ignore')
        self.Labelframe2.configure(relief=GROOVE)
        self.Labelframe2.configure(text='''Time''')
        self.Labelframe2.configure(width=150)

        self.time_val = Label(self.Labelframe2)
        self.time_val.place(relx=0.067,
                            rely=0.345,
                            height=37,
                            width=114,
                            bordermode='ignore')
        self.time_val.configure(activebackground="#f9f9f9")
        self.time_val.configure(text=waktu[batas])

        self.back = Button(top)
        self.back.place(relx=0.019, rely=0.017, height=35, width=62)
        self.back.configure(activebackground="#d9d9d9")
        self.back.configure(command=recap_support.destroy_window)
        self.back.configure(text='''Back''')
        self.back.configure(width=62)