Beispiel #1
0
                    print(error)
            else:
                engine = Dlae(configs)
                if any(engine.errors):
                    print('Level 3 errors encountered.')
                    print(
                        "Please fix the level 3 errors below before continuing:"
                    )
                    for error in engine.errors:
                        print(error)
                else:
                    engine.run()
                    if any(engine.errors):
                        print('Level 3 errors encountered.')
                        print(
                            "Please fix the level 3 errors below before continuing:"
                        )
                        for error in engine.errors:
                            print(error)

    else:
        root = tk.Tk()
        root.resizable(width=False, height=False)
        root.tk.call('wm', 'iconphoto', root._w,
                     tk.PhotoImage(file="src/gui/button_figs/other/icon.png"))
        DlaeGui(root).grid()
        try:
            root.mainloop()
        except KeyboardInterrupt:
            quit()
Beispiel #2
0
    def __init__(self, parent):
        self.myParent = parent

        self.myContainer1 = ttk.Frame(parent)
        self.myContainer1.pack()

        # Layout constants #
        button_width = 6
        buttons_padx = "2m"
        buttons_pady = "1m"
        buttons_frame_padx = "6m"
        buttons_frame_pady = "2m"
        buttons_frame_ipadx = "3m"
        buttons_frame_ipady = "1m"

        self.output_frame = ttk.Frame(self.myContainer1)
        self.output_frame.pack()

        self.outputPlot = tk.Canvas(self.output_frame)
        self.outputPlot.configure(height='650',
                                  width='650',
                                  bg='#1D1D1D',
                                  bd=0)
        self.outputPlot.pack(side=tk.LEFT)

        self.img = tk.PhotoImage(file='sidebar.gif')
        self.sidebar = ttk.Label(self.output_frame, image=self.img)
        self.sidebar.pack(side=tk.LEFT)
        self.labelFrame = ttk.Frame(self.output_frame)
        self.labelFrame.pack(side=tk.LEFT, fill=tk.Y)

        self.sideLabel0 = ttk.Label(self.labelFrame, text="24a₀")
        self.sideLabel0.pack(side=tk.TOP)
        self.sideLabel2 = ttk.Label(self.labelFrame, text="-24a₀")
        self.sideLabel2.pack(side=tk.BOTTOM)

        self.input_frame = ttk.Frame(self.myContainer1)
        self.input_frame.pack(side=tk.BOTTOM,
                              ipadx=buttons_frame_ipady,
                              ipady=buttons_frame_ipady,
                              padx=buttons_frame_padx,
                              pady=buttons_frame_pady,
                              fill=tk.X)

        self.nLabel = ttk.Label(self.input_frame, text="Principal (n):")
        self.nLabel.pack(side=tk.LEFT)
        self.nInput = ttk.Entry(self.input_frame)
        self.nInput.configure(
            width=3,
            validate='key',
            #Add validation for values#
            validatecommand='')
        self.nInput.pack(side=tk.LEFT)

        self.lLabel = ttk.Label(self.input_frame, text="   Orbital (l):")
        self.lLabel.pack(side=tk.LEFT)
        self.lInput = ttk.Entry(self.input_frame)
        self.lInput.configure(
            width=3,
            validate='key',
            #Validation
            validatecommand='')
        self.lInput.pack(side=tk.LEFT)

        self.mlLabel = ttk.Label(self.input_frame, text="   Magnetic (m):")
        self.mlLabel.pack(side=tk.LEFT)
        self.mlInput = ttk.Entry(self.input_frame)
        self.mlInput.configure(width=3)
        self.mlInput.pack(side=tk.LEFT)

        self.iterationLabel = ttk.Label(self.input_frame,
                                        text="   Iterations (x1000):")
        self.iterationLabel.pack(side=tk.LEFT)
        self.iterationInput = ttk.Entry(self.input_frame)
        self.iterationInput.configure(width=6)
        self.iterationInput.pack(side=tk.LEFT)

        self.goButton = ttk.Button(self.input_frame,
                                   text='Go!',
                                   command=self.goClick)
        self.goButton.pack(side=tk.LEFT)
            title="Non-solvable puzzle",
            message="The algorithm did not manage to find a" +
            " solution for the submitted puzzle. It's pretty" +
            " smart so you better check input for errors.")

        return

    # end of fx
    return


""" MAIN """
# create a root window
root = tk.Tk()
root.wm_title("sudoku-solver")
root.call('wm', 'iconphoto', root._w, tk.PhotoImage(file='res/sudoku.png'))
#root.geometry("400x400")
frame = tk.Frame(root)
#frame.config(bg="#FFFFFF")
frame.pack()

# menu bar:
mainMenu = tk.Menu(root)
root.config(menu=mainMenu)
fileMenu = tk.Menu(mainMenu, tearoff=0)
mainMenu.add_cascade(label="File", menu=fileMenu)
# add commands to file menu:
fileMenu.add_command(label="New", command=New)
fileMenu.add_command(label="Open", command=Open)
fileMenu.add_separator()
fileMenu.add_command(label="Quit", command=root.destroy)
def support():
    entry.delete(1.0, tk.END)
    file_s = open("support/support.txt", "r", encoding='utf-8')
    contents = file_s.read()
    entry.insert(tk.END, contents)
    file_s.close()
    winsound.PlaySound("windows.wav", winsound.SND_ASYNC)


# satrt the GUI
root = tk.Tk()
root.title('voice to text')

canvas = tk.Canvas(root, height=500, width=900)
canvas.pack()
background_image = tk.PhotoImage(file='image/bg.png')
background_label = tk.Label(root, image=background_image)
background_label.place(relwidth=1, relheight=1)

frame = tk.Frame(root, bg='#3498DB', bd=5)
frame.place(relx=0.41, rely=0.08, relwidth=0.76, relheight=0.86, anchor='n')

#=============================================================================

entry = tk.Text(frame, font=("jameel noori nastaleeq", 14))
entry.place(relx=0, rely=0, relwidth=1, relheight=1)
show_file()


# copy data inside file.txt to clipboard
def copy():
Beispiel #5
0
            outputLabel['text'] += "\nShoulder to hips ratio: " + str(ratioSH)
            
        # Resize window
        cv2.namedWindow('Image', cv2.WINDOW_NORMAL)
        cv2.resizeWindow('Image', 300,500)
        cv2.imshow('Image', img)

if __name__ == "__main__":
    # Main part of the program
    # Creation of GUI
    root = tk.Tk()

    canvas = tk.Canvas(root, height=HEIGHT, width=WIDTH)
    canvas.pack()

    bgImage = tk.PhotoImage(file='./images/background.png')
    bgLabel = tk.Label(root, image=bgImage)
    bgLabel.place(relwidth=1, relheight=1)

    frameInput = tk.Frame(root, bg='#f97235', bd=5)
    frameInput.place(relx=0.125, rely=0.1, relwidth=0.75, relheight=0.075)

    entry = tk.Entry(frameInput)
    entry.place(relwidth=0.8, relheight=1)

    buttonBrowse = tk.Button(frameInput, text="Browse", command=getImage)
    buttonBrowse.place(relx=0.85, relwidth=0.15, relheight=1)

    frameOutput = tk.Frame(root, bg='#f97235', bd=5)
    frameOutput.place(relx=0.125, rely=0.25, relwidth=0.75, relheight=0.55)
Beispiel #6
0
def loop():                       #GUI
    global tcpClicSock,BtnIP,led_status,BtnVIN,l_VIN,TestMode     #The value of tcpClicSock changes in the function loop(),would also changes in global so the other functions could use it.
    while True:
        root = tk.Tk()            #Define a window named root
        root.title('Adeept')      #Main window title
        root.geometry('917x630')  #Main window size, middle of the English letter x.
        root.config(bg=color_bg)  #Set the background color of root window
    
        var_spd = tk.StringVar()  #Speed value saved in a StringVar
        var_spd.set(1)            #Set a default speed,but change it would not change the default speed value in the car,you need to click button'Set' to send the value to the car

        var_x_scan = tk.IntVar()  #Scan range value saved in a IntVar
        var_x_scan.set(2)         #Set a default scan value

        logo =tk.PhotoImage(file = 'logo.png')         #Define the picture of logo,but only supports '.png' and '.gif'
        l_logo=tk.Label(root,image = logo,bg=color_bg) #Set a label to show the logo picture
        l_logo.place(x=30,y=13)                        #Place the Label in a right position

        BtnC1 = tk.Button(root, width=15, text='Camera Middle',fg=color_text,bg=color_btn,relief='ridge')
        BtnC1.place(x=785,y=10)
        E_C1 = tk.Entry(root,show=None,width=16,bg="#37474F",fg='#eceff1',exportselection=0,justify='center')
        E_C1.place(x=785,y=45)                             #Define a Entry and put it in position

        BtnC2 = tk.Button(root, width=15, text='Ultrasonic Middle',fg=color_text,bg=color_btn,relief='ridge')
        BtnC2.place(x=785,y=100)
        E_C2 = tk.Entry(root,show=None,width=16,bg="#37474F",fg='#eceff1',exportselection=0,justify='center')
        E_C2.place(x=785,y=135)                             #Define a Entry and put it in position

        BtnM1 = tk.Button(root, width=15, text='Motor A Speed',fg=color_text,bg=color_btn,relief='ridge')
        BtnM1.place(x=785,y=190)
        E_M1 = tk.Entry(root,show=None,width=16,bg="#37474F",fg='#eceff1',exportselection=0,justify='center')
        E_M1.place(x=785,y=225)                             #Define a Entry and put it in position

        BtnM2 = tk.Button(root, width=15, text='Motor B Speed',fg=color_text,bg=color_btn,relief='ridge')
        BtnM2.place(x=785,y=280)
        E_M2 = tk.Entry(root,show=None,width=16,bg="#37474F",fg='#eceff1',exportselection=0,justify='center')
        E_M2.place(x=785,y=315)                             #Define a Entry and put it in position

        BtnT1 = tk.Button(root, width=15, text='Look Up Max',fg=color_text,bg=color_btn,relief='ridge')
        BtnT1.place(x=785,y=370)
        E_T1 = tk.Entry(root,show=None,width=16,bg="#37474F",fg='#eceff1',exportselection=0,justify='center')
        E_T1.place(x=785,y=405)                             #Define a Entry and put it in position

        BtnT2 = tk.Button(root, width=15, text='Look Down Max',fg=color_text,bg=color_btn,relief='ridge')
        BtnT2.place(x=785,y=460)
        E_T2 = tk.Entry(root,show=None,width=16,bg="#37474F",fg='#eceff1',exportselection=0,justify='center')
        E_T2.place(x=785,y=495)                             #Define a Entry and put it in position

        BtnLED = tk.Button(root, width=15, text='Lights ON',fg=color_text,bg=color_btn,relief='ridge')
        BtnLED.place(x=300,y=420)

        BtnOCV = tk.Button(root, width=15, text='OpenCV',fg=color_text,bg=color_btn,relief='ridge',command=call_opencv)
        BtnOCV.place(x=30,y=420)

        BtnFL = tk.Button(root, width=15, text='Find Line',fg=color_text,bg=color_btn,relief='ridge')
        BtnFL.place(x=165,y=420)

        BtnSR3 = tk.Button(root, width=15, text='Sphinx SR',fg=color_text,bg=color_btn,relief='ridge',command=call_SR3)
        BtnSR3.place(x=300,y=495)

        E_C1.insert ( 0, 'Default:425' ) 
        E_C2.insert ( 0, 'Default:425' ) 
        E_M1.insert ( 0, 'Default:100' ) 
        E_M2.insert ( 0, 'Default:100' )
        E_T1.insert ( 0, 'Default:662' ) 
        E_T2.insert ( 0, 'Default:295' )

        can_scan = tk.Canvas(root,bg=color_can,height=250,width=320,highlightthickness=0) #define a canvas
        can_scan.place(x=440,y=330) #Place the canvas
        line = can_scan.create_line(0,62,320,62,fill='darkgray')   #Draw a line on canvas
        line = can_scan.create_line(0,124,320,124,fill='darkgray') #Draw a line on canvas
        line = can_scan.create_line(0,186,320,186,fill='darkgray') #Draw a line on canvas
        line = can_scan.create_line(160,0,160,250,fill='darkgray') #Draw a line on canvas
        line = can_scan.create_line(80,0,80,250,fill='darkgray')   #Draw a line on canvas
        line = can_scan.create_line(240,0,240,250,fill='darkgray') #Draw a line on canvas
        x_range = var_x_scan.get()
        can_tex_11=can_scan.create_text((27,178),text='%sm'%round((x_range/4),2),fill='#aeea00')     #Create a text on canvas
        can_tex_12=can_scan.create_text((27,116),text='%sm'%round((x_range/2),2),fill='#aeea00')     #Create a text on canvas
        can_tex_13=can_scan.create_text((27,54),text='%sm'%round((x_range*0.75),2),fill='#aeea00')  #Create a text on canvas

        def spd_set():                 #Call this function for speed adjustment
            tcpClicSock.send(('spdset:%s'%var_spd.get()).encode())   #Get a speed value from IntVar and send it to the car
            l_ip_2.config(text='Speed:%s'%var_spd.get())             #Put the speed value on the speed status label

        def EC1_set(event):            #Call this function for speed adjustment
            tcpClicSock.send(('EC1set:%s'%E_C1.get()).encode())   #Get a speed value from IntVar and send it to the car

        def EC2_set(event):            #Call this function for speed adjustment
            tcpClicSock.send(('EC2set:%s'%E_C2.get()).encode())   #Get a speed value from IntVar and send it to the car

        def EM1_set(event):            #Call this function for speed adjustment
            tcpClicSock.send(('EM1set:%s'%E_M1.get()).encode())   #Get a speed value from IntVar and send it to the car

        def EM2_set(event):            #Call this function for speed adjustment
            tcpClicSock.send(('EM2set:%s'%E_M2.get()).encode())   #Get a speed value from IntVar and send it to the car

        def ET1_set(event):            #Call this function for speed adjustment
            tcpClicSock.send(('LUMset:%s'%E_T1.get()).encode())   #Get a speed value from IntVar and send it to the car

        def ET2_set(event):            #Call this function for speed adjustment
            tcpClicSock.send(('LDMset:%s'%E_T2.get()).encode())   #Get a speed value from IntVar and send it to the car

        def connect(event):       #Call this function to connect with the server
            if ip_stu == 1:
                sc=thread.Thread(target=socket_connect) #Define a thread for connection
                sc.setDaemon(True)                      #'True' means it is a front thread,it would close when the mainloop() closes
                sc.start()                              #Thread starts

        def connect_2():          #Call this function to connect with the server
            if ip_stu == 1:
                sc=thread.Thread(target=socket_connect) #Define a thread for connection
                sc.setDaemon(True)                      #'True' means it is a front thread,it would close when the mainloop() closes
                sc.start()                              #Thread starts

        def socket_connect():     #Call this function to connect with the server
            global ADDR,tcpClicSock,BUFSIZ,ip_stu,ipaddr
            ip_adr=E1.get()       #Get the IP address from Entry

            if ip_adr == '':      #If no input IP address in Entry,import a default IP
                ip_adr=num_import('IP:')
                l_ip_4.config(text='Connecting')
                l_ip_4.config(bg='#FF8F00')
                l_ip_5.config(text='Default:%s'%ip_adr)
                pass
            
            SERVER_IP = ip_adr
            SERVER_PORT = 10223   #Define port serial 
            BUFSIZ = 1024         #Define buffer size
            ADDR = (SERVER_IP, SERVER_PORT)
            tcpClicSock = socket(AF_INET, SOCK_STREAM) #Set connection value for socket

            for i in range (1,6): #Try 5 times if disconnected
                try:
                    if ip_stu == 1:
                        print("Connecting to server @ %s:%d..." %(SERVER_IP, SERVER_PORT))
                        print("Connecting")
                        tcpClicSock.connect(ADDR)        #Connection with the server
                    
                        print("Connected")
                    
                        l_ip_5.config(text='IP:%s'%ip_adr)
                        l_ip_4.config(text='Connected')
                        l_ip_4.config(bg='#558B2F')

                        replace_num('IP:',ip_adr)
                        E1.config(state='disabled')      #Disable the Entry
                        Btn14.config(state='disabled')   #Disable the Entry
                    
                        ip_stu=0                         #'0' means connected
                    
                        at=thread.Thread(target=code_receive) #Define a thread for data receiving
                        at.setDaemon(True)                    #'True' means it is a front thread,it would close when the mainloop() closes
                        at.start()                            #Thread starts

                        SR_threading=thread.Thread(target=voice_command_thread)         #Define a thread for ultrasonic tracking
                        SR_threading.setDaemon(True)                              #'True' means it is a front thread,it would close when the mainloop() closes
                        SR_threading.start()                                      #Thread starts

                        video_thread=thread.Thread(target=video_show) #Define a thread for data receiving
                        video_thread.setDaemon(True)                    #'True' means it is a front thread,it would close when the mainloop() closes
                        print('Video Connected')
                        video_thread.start()                            #Thread starts

                        ipaddr=tcpClicSock.getsockname()[0]
                        break
                    else:
                        break
                except Exception:
                    print("Cannot connecting to server,try it latter!")
                    l_ip_4.config(text='Try %d/5 time(s)'%i)
                    l_ip_4.config(bg='#EF6C00')
                    print('Try %d/5 time(s)'%i)
                    ip_stu=1
                    time.sleep(1)
                    continue
            if ip_stu == 1:
                l_ip_4.config(text='Disconnected')
                l_ip_4.config(bg='#F44336')

        def code_receive():     #A function for data receiving
            global led_status,ipcon,findline_status,auto_status,opencv_status,speech_status,TestMode
            while True:
                code_car = tcpClicSock.recv(BUFSIZ) #Listening,and save the data in 'code_car'
                l_ip.config(text=code_car)          #Put the data on the label
                #print(code_car)
                if not code_car:
                    continue
                elif 'SET' in str(code_car):
                    print('set get')
                    set_list=code_car.decode()
                    set_list=set_list.split()
                    s1,s2,s3,s4,s5,s6=set_list[1:]
                    E_C1.delete(0,50)
                    E_C2.delete(0,50)
                    E_M1.delete(0,50)
                    E_M2.delete(0,50)
                    E_T1.delete(0,50)
                    E_T2.delete(0,50)

                    E_C1.insert ( 0, '%d'%int(s1) ) 
                    E_C2.insert ( 0, '%d'%int(s2) ) 
                    E_M1.insert ( 0, '%d'%int(s3) ) 
                    E_M2.insert ( 0, '%d'%int(s4) )
                    E_T1.insert ( 0, '%d'%int(s5) ) 
                    E_T2.insert ( 0, '%d'%int(s6) )

                elif 'list' in str(code_car):         #Scan result receiving start
                    dis_list=[]
                    f_list=[]
                    list_str=code_car.decode()
                    
                    while  True:                    #Save scan result in dis_list
                        code_car = tcpClicSock.recv(BUFSIZ)
                        if 'finished' in str(code_car):
                            break
                        list_str+=code_car.decode()
                        l_ip.config(text='Scanning')
                    
                    dis_list=list_str.split()       #Save the data as a list
                    l_ip.config(text='Finished')
                    
                    for i in range (0,len(dis_list)):   #Translate the String-type value in the list to Float-type
                        try:
                            new_f=float(dis_list[i])
                            f_list.append(new_f)
                        except:
                            continue
                    
                    dis_list=f_list
                    #can_scan.delete(line)
                    #can_scan.delete(point_scan)
                    can_scan_1 = tk.Canvas(root,bg=color_can,height=250,width=320,highlightthickness=0) #define a canvas
                    can_scan_1.place(x=440,y=330) #Place the canvas
                    line = can_scan_1.create_line(0,62,320,62,fill='darkgray')   #Draw a line on canvas
                    line = can_scan_1.create_line(0,124,320,124,fill='darkgray') #Draw a line on canvas
                    line = can_scan_1.create_line(0,186,320,186,fill='darkgray') #Draw a line on canvas
                    line = can_scan_1.create_line(160,0,160,250,fill='darkgray') #Draw a line on canvas
                    line = can_scan_1.create_line(80,0,80,250,fill='darkgray')   #Draw a line on canvas
                    line = can_scan_1.create_line(240,0,240,250,fill='darkgray') #Draw a line on canvas

                    x_range = var_x_scan.get()          #Get the value of scan range from IntVar

                    for i in range (0,len(dis_list)):   #Scale the result to the size as canvas
                        try:
                            len_dis_1 = int((dis_list[i]/x_range)*250)                          #600 is the height of canvas
                            pos     = int((i/len(dis_list))*320)                                #740 is the width of canvas
                            pos_ra  = int(((i/len(dis_list))*140)+20)                           #Scale the direction range to (20-160)
                            len_dis = int(len_dis_1*(math.sin(math.radians(pos_ra))))           #len_dis is the height of the line

                            x0_l,y0_l,x1_l,y1_l=pos,(250-len_dis),pos,(250-len_dis)             #The position of line
                            x0,y0,x1,y1=(pos+3),(250-len_dis+3),(pos-3),(250-len_dis-3)         #The position of arc

                            if pos <= 160:                                                      #Scale the whole picture to a shape of sector
                                pos = 160-abs(int(len_dis_1*(math.cos(math.radians(pos_ra)))))
                                x1_l= (x1_l-math.cos(math.radians(pos_ra))*130)
                            else:
                                pos = abs(int(len_dis_1*(math.cos(math.radians(pos_ra)))))+160
                                x1_l= x1_l+abs(math.cos(math.radians(pos_ra))*130)

                            y1_l = y1_l-abs(math.sin(math.radians(pos_ra))*130)              #Orientation of line

                            line = can_scan_1.create_line(pos,y0_l,x1_l,y1_l,fill=color_line)   #Draw a line on canvas
                            point_scan = can_scan_1.create_oval((pos+3),y0,(pos-3),y1,fill=color_oval,outline=color_oval) #Draw a arc on canvas
                        except:
                            pass
                    can_tex_11=can_scan_1.create_text((27,178),text='%sm'%round((x_range/4),2),fill='#aeea00')     #Create a text on canvas
                    can_tex_12=can_scan_1.create_text((27,116),text='%sm'%round((x_range/2),2),fill='#aeea00')     #Create a text on canvas
                    can_tex_13=can_scan_1.create_text((27,54),text='%sm'%round((x_range*0.75),2),fill='#aeea00')  #Create a text on canvas

                elif '1' in str(code_car):               #Translate the code to text
                    l_ip.config(text='Moving Forward')   #Put the text on the label
                elif '2' in str(code_car):               #Translate the code to text
                    l_ip.config(text='Moving Backward')  #Put the text on the label
                elif '3' in str(code_car):               #Translate the code to text
                    l_ip.config(text='Turning Left')     #Put the text on the label
                elif '4' in str(code_car):               #Translate the code to text
                    l_ip.config(text='Turning Right')    #Put the text on the label
                elif '5' in str(code_car):               #Translate the code to text
                    l_ip.config(text='Look Up')          #Put the text on the label
                elif '6' in str(code_car):               #Translate the code to text
                    l_ip.config(text='Look Down')        #Put the text on the label
                elif '7' in str(code_car):               #Translate the code to text
                    l_ip.config(text='Look Left')        #Put the text on the label
                elif '8' in str(code_car):               #Translate the code to text
                    l_ip.config(text='Look Right')       #Put the text on the label
                elif '9' in str(code_car):               #Translate the code to text
                    l_ip.config(text='Stop')             #Put the text on the label
                
                elif '0' in str(code_car):               #Translate the code to text
                    l_ip.config(text='Follow Mode On')     #Put the text on the label
                    Btn5.config(text='Following',fg='#0277BD',bg='#BBDEFB')
                    auto_status = 1
                
                elif 'findline' in str(code_car):        #Translate the code to text
                    BtnFL.config(text='Finding',fg='#0277BD',bg='#BBDEFB')
                    l_ip.config(text='Find Line') 
                    findline_status = 1
                
                elif 'lightsON' in str(code_car):        #Translate the code to text
                    BtnLED.config(text='Lights ON',fg='#0277BD',bg='#BBDEFB')
                    led_status=1
                    l_ip.config(text='Lights On')        #Put the text on the label
                
                elif 'lightsOFF' in str(code_car):        #Translate the code to text
                    BtnLED.config(text='Lights OFF',fg=color_text,bg=color_btn)
                    led_status=0
                    l_ip.config(text='Lights OFF')        #Put the text on the label

                elif 'oncvon' in str(code_car):
                    if TestMode == 0:
                        BtnOCV.config(text='OpenCV ON',fg='#0277BD',bg='#BBDEFB')
                        BtnFL.config(text='Find Line',fg=color_text,bg=color_btn)
                        l_ip.config(text='OpenCV ON')
                        opencv_status = 1

                elif 'auto_status_off' in str(code_car):
                    if TestMode == 0:
                        BtnSR3.config(fg=color_text,bg=color_btn,state='normal')
                        BtnOCV.config(text='OpenCV',fg=color_text,bg=color_btn,state='normal')
                    BtnFL.config(text='Find Line',fg=color_text,bg=color_btn)
                    Btn5.config(text='Follow',fg=color_text,bg=color_btn,state='normal')
                    findline_status = 0
                    speech_status   = 0
                    opencv_status   = 0
                    auto_status     = 0

                elif 'voice_3' in str(code_car):
                    BtnSR3.config(fg='#0277BD',bg='#BBDEFB')
                    #BtnSR1.config(state='disabled')
                    #BtnSR2.config(state='disabled')
                    l_ip.config(text='Sphinx SR')        #Put the text on the label
                    speech_status = 1

                elif 'TestVersion' in str(code_car):
                    TestMode = 1
                    BtnSR3.config(fg='#FFFFFF',bg='#F44336')
                    BtnOCV.config(fg='#FFFFFF',bg='#F44336')

        s1 = tk.Scale(root,label="               < Slow   Speed Adjustment   Fast >",
        from_=0.4,to=1,orient=tk.HORIZONTAL,length=400,
        showvalue=0.1,tickinterval=0.1,resolution=0.2,variable=var_spd,fg=color_text,bg=color_bg,highlightthickness=0)
        s1.place(x=200,y=100)                            #Define a Scale and put it in position

        s3 = tk.Scale(root,label="< Near   Scan Range Adjustment(Meter(s))   Far >",
        from_=1,to=5,orient=tk.HORIZONTAL,length=300,
        showvalue=1,tickinterval=1,resolution=1,variable=var_x_scan,fg=color_text,bg=color_bg,highlightthickness=0)
        s3.place(x=30,y=320)    

        l_ip=tk.Label(root,width=18,text='Status',fg=color_text,bg=color_btn)
        l_ip.place(x=30,y=110)                           #Define a Label and put it in position

        l_ip_2=tk.Label(root,width=18,text='Speed:%s'%(var_spd.get()),fg=color_text,bg=color_btn)
        l_ip_2.place(x=30,y=145)                         #Define a Label and put it in position

        l_ip_4=tk.Label(root,width=18,text='Disconnected',fg=color_text,bg='#F44336')
        l_ip_4.place(x=637,y=110)                         #Define a Label and put it in position

        l_ip_5=tk.Label(root,width=18,text='Use default IP',fg=color_text,bg=color_btn)
        l_ip_5.place(x=637,y=145)                         #Define a Label and put it in position

        l_inter=tk.Label(root,width=45,text='< Car Adjustment              Camera Adjustment>\nW:Move Forward                 Look Up:I\nS:Move Backward            Look Down:K\nA:Turn Left                          Turn Left:J\nD:Turn Right                      Turn Right:L\nZ:Auto Mode On          Look Forward:H\nC:Auto Mode Off      Ultrasdonic Scan:X' ,
        fg='#212121',bg='#90a4ae')
        l_inter.place(x=240,y=180)                       #Define a Label and put it in position

        E1 = tk.Entry(root,show=None,width=16,bg="#37474F",fg='#eceff1')
        E1.place(x=170,y=40)                             #Define a Entry and put it in position

        l_ip_3=tk.Label(root,width=10,text='IP Address:',fg=color_text,bg='#000000')
        l_ip_3.place(x=165,y=15)                         #Define a Label and put it in position

        Btn14= tk.Button(root, width=8, text='Connect',fg=color_text,bg=color_btn,command=connect_2,relief='ridge')
        Btn14.place(x=300,y=35)                          #Define a Button and put it in position

        BtnVIN = tk.Button(root, width=15, text='Voice Input',fg=color_text,bg=color_btn,relief='ridge')
        BtnVIN.place(x=30,y=495)

        l_VIN=tk.Label(root,width=16,text='Voice commands',fg=color_text,bg=color_btn)
        l_VIN.place(x=30,y=465)      

        #Define buttons and put these in position
        Btn0 = tk.Button(root, width=8, text='Forward',fg=color_text,bg=color_btn,relief='ridge')
        Btn1 = tk.Button(root, width=8, text='Backward',fg=color_text,bg=color_btn,relief='ridge')
        Btn2 = tk.Button(root, width=8, text='Left',fg=color_text,bg=color_btn,relief='ridge')
        Btn3 = tk.Button(root, width=8, text='Right',fg=color_text,bg=color_btn,relief='ridge')
        Btn4 = tk.Button(root, width=8, text='Stop',fg=color_text,bg=color_btn,relief='ridge')
        Btn5 = tk.Button(root, width=8, text='Follow',fg=color_text,bg=color_btn,relief='ridge')
        
        Btn6 = tk.Button(root, width=8, text='Left',fg=color_text,bg=color_btn,relief='ridge')
        Btn7 = tk.Button(root, width=8, text='Right',fg=color_text,bg=color_btn,relief='ridge')
        Btn8 = tk.Button(root, width=8, text='Down',fg=color_text,bg=color_btn,relief='ridge')
        Btn9 = tk.Button(root, width=8, text='Up',fg=color_text,bg=color_btn,relief='ridge')
        Btn10 = tk.Button(root, width=8, text='Home',fg=color_text,bg=color_btn,relief='ridge')
        Btn11 = tk.Button(root, width=8, text='Exit',fg=color_text,bg=color_btn,relief='ridge')

        Btn12 = tk.Button(root, width=8, text='Set',command=spd_set,fg=color_text,bg=color_btn,relief='ridge')
        Btn13 = tk.Button(root, width=8,height=3, text='Scan',fg=color_text,bg=color_btn,relief='ridge')

        Btn0.place(x=100,y=195)
        Btn1.place(x=100,y=230)
        Btn2.place(x=30,y=230)
        Btn3.place(x=170,y=230)
        Btn4.place(x=170,y=275)
        Btn5.place(x=30,y=275)
        
        Btn6.place(x=565,y=230)
        Btn7.place(x=705,y=230)
        Btn8.place(x=635,y=265)
        Btn9.place(x=635,y=195)
        Btn10.place(x=635,y=230)
        Btn11.place(x=705,y=10)

        Btn12.place(x=535,y=107)
        Btn13.place(x=350,y=330)


        # Bind the buttons with the corresponding callback function
        Btn0.bind('<ButtonPress-1>', call_forward)
        Btn1.bind('<ButtonPress-1>', call_back)
        Btn2.bind('<ButtonPress-1>', click_call_Left)
        Btn3.bind('<ButtonPress-1>', click_call_Right)
        Btn4.bind('<ButtonPress-1>', call_Stop)
        Btn5.bind('<ButtonPress-1>', call_auto)
        Btn6.bind('<ButtonPress-1>', call_look_left)
        Btn7.bind('<ButtonPress-1>', call_look_right)

        Btn8.bind('<ButtonPress-1>', call_look_down)
        Btn9.bind('<ButtonPress-1>', call_look_up)
        Btn10.bind('<ButtonPress-1>', call_ahead)
        Btn11.bind('<ButtonPress-1>', call_exit)
        Btn13.bind('<ButtonPress-1>', scan)

        Btn0.bind('<ButtonRelease-1>', call_stop)
        Btn1.bind('<ButtonRelease-1>', call_stop)
        Btn2.bind('<ButtonRelease-1>', call_stop)
        Btn3.bind('<ButtonRelease-1>', call_stop)
        Btn4.bind('<ButtonRelease-1>', call_stop)

        BtnC1.bind('<ButtonPress-1>', EC1_set)
        BtnC2.bind('<ButtonPress-1>', EC2_set)
        BtnM1.bind('<ButtonPress-1>', EM1_set)
        BtnM2.bind('<ButtonPress-1>', EM2_set)
        BtnT1.bind('<ButtonPress-1>', ET1_set)
        BtnT2.bind('<ButtonPress-1>', ET2_set)
        BtnFL.bind('<ButtonPress-1>', find_line)
        BtnVIN.bind('<ButtonPress-1>', voice_command)

        BtnLED.bind('<ButtonPress-1>', lights_ON)
        # Bind the keys with the corresponding callback function
        root.bind('<KeyPress-w>', call_forward) 
        root.bind('<KeyPress-a>', call_Left)
        root.bind('<KeyPress-d>', call_Right)
        root.bind('<KeyPress-s>', call_back)

        # When these keys is released,call the function call_stop()
        root.bind('<KeyRelease-w>', call_stop)
        root.bind('<KeyRelease-a>', call_stop_2)
        root.bind('<KeyRelease-d>', call_stop_2)
        root.bind('<KeyRelease-s>', call_stop)
        root.bind('<KeyRelease-f>', lights_ON)
        root.bind('<KeyRelease-e>', find_line)
        root.bind('<KeyRelease-q>', voice_command)

        # Press these keyss to call the corresponding function()
        root.bind('<KeyPress-c>', call_Stop)
        root.bind('<KeyPress-z>', call_auto) 
        root.bind('<KeyPress-j>', call_look_left)
        root.bind('<KeyPress-l>', call_look_right)
        root.bind('<KeyPress-h>', call_ahead)
        root.bind('<KeyPress-k>', call_look_down)
        root.bind('<KeyPress-i>', call_look_up)
        root.bind('<KeyPress-x>', scan)
        root.bind('<Return>', connect)
        root.bind('<Shift_L>',call_stop)
        
        global stat
        if stat==0:              # Ensure the mainloop runs only once
                root.mainloop()  # Run the mainloop()
                stat=1           # Change the value to '1' so the mainloop() would not run again.
Beispiel #7
0
import tkinter as tk
window = tk.Tk()

f = tk.Frame(bg="navy")
f.pack()

press = tk.PhotoImage(file="CFinger.png")
img = tk.Label(master=window,image=press)
img.pack(side=tk.BOTTOM)

lbl=tk.Label(master = f,text="How Fast can you click?",bg="navy",fg="white",width=34)
lbl.pack()

lbl=tk.Label(master = f,text="Click the button and see the indicator.",bg="navy",fg="white",width=34)
lbl.pack()

x = 0

def onClick (event):
    global x
    x = x+1
    lbl.config(text=x)

Btn=tk.Button(width=20,text="Click me!")
Btn.pack()

Btn.bind("<Button-1>",onClick)

lbl=tk.Label(master = f,text= (x),bg="orange")
lbl.pack()
Beispiel #8
0
 def widgets(self):
     self.road = tk.PhotoImage(file='images/'+self.road_name+'.gif')
     self.road_height = self.road.height()
     self.road_width = self.road.width()
     self.side_ground = tk.PhotoImage(file='images/'+self.side_ground_name+'.gif')
     self.side_ground_height = self.side_ground.height()
     self.side_ground_width = self.side_ground.width()
     self.car_height = self.car.height()
     self.car_width = self.car.width()
     self.bag=tk.PhotoImage(file='images/bag.gif')
     self.bag_height = self.bag.height()
     self.bag_width = self.bag.width()
     self.pump = tk.PhotoImage(file='images/pump.gif')
     self.pump_height = self.pump.height()
     self.pump_width = self.pump.width()
     self.theroad1 = self.canvas.create_image(self.side_ground_width, 0, image=self.road, anchor='nw')
     self.theroad2 = self.canvas.create_image(self.side_ground_width,self.road_height , image=self.road, anchor='nw')
     self.theside_ground1 = self.canvas.create_image(0, 0, image=self.side_ground, anchor='nw')
     self.theside_ground2 = self.canvas.create_image(0,self.side_ground_height , image=self.side_ground, anchor='nw')
     self.theside_ground3 = self.canvas.create_image(self.side_ground_width+self.road_width,0 ,image=self.side_ground, anchor='nw')
     self.theside_ground4 = self.canvas.create_image( self.side_ground_width+self.road_width,self.side_ground_height,
                                                      image=self.side_ground, anchor='nw')
     self.thebag=self.canvas.create_image(int(self.canvas['width']), int(self.canvas['height']), image=self.bag, anchor='se')
     self.thepump = self.canvas.create_image(int(self.canvas['width']), int(self.canvas['height'])-self.bag_height,
                                                                                     image=self.pump,anchor='se')
     self.thecar = self.canvas.create_image(self.side_ground_width+self.road_width/2+130,
                                            int(self.canvas['height'])- self.car_height-20,image=self.car, anchor='nw')
     self.f1 = tk.Frame(self.canvas)
     self.save = tk.PhotoImage(file='images/save.gif')
     self.button_save_score = tk.Button(self.f1,image=self.save,command=self.save_score)
     self.button_save_score.pack(side='left', fill='both', expand=1)
     self.button_save_score.config(state="disable")
     self.button_pause = tk.Button(self.f1, text='| |', font="Arial 20", command=self.pause,width=3)
     self.button_pause.pack(side='left', fill='y', expand=0)
     self.button_pause.config(state="disable")
     self.canvas.create_window(0,0, window=self.f1, anchor="nw")
     self.stars=Star(self.canvas,self.thecar,self.road_width,self.side_ground_width)
     self.fuels=Fuel(self.canvas,self.thecar,self.road_width,self.side_ground_width)
     if self.level == 2 or self.level == 3:
         self.tool = tk.PhotoImage(file='images/tool.gif')
         self.thetool = self.canvas.create_image(int(self.canvas['width']),int(self.canvas['height'])-self.bag_height
                                                     -self.pump_height-10,image=self.tool, anchor='se')
         self.rocks = Rock(self.root,self.canvas, self.thecar, self.road_width, self.side_ground_width)
         self.rocks.show_damage()
     if self.level==3:
         self.tire=tk.PhotoImage(file='images/tire.gif')
         self.thetire = self.canvas.create_image(int(self.canvas['width'])-5,int(self.canvas['height']) - self.bag_height
                                                 - self.pump_height - self.tool.height()-15, image=self.tire, anchor='se')
         self.glasses = Glass(self,self.root, self.canvas, self.thecar, self.road_width, self.side_ground_width)
         self.glasses.show_tires()
     self.show_time()
     self.show_username()
     self.stars.show_points()
     self.fuels.show_fuel()
     self.my_message = self.canvas.create_text(int(self.canvas['width']) / 2, int(self.canvas['height']) / 2,
                                               fill="black", text="", font="Arial 45", anchor='nw')
     self.canvas.update()
     if speaker:sound.PlaySound("countdown", sound.SND_ASYNC )
     time.sleep(1)
     self.count_down(3)
     self.start_game()
Beispiel #9
0

#________________________________    Main Menu    ______________________________

# Creating main menu object....
main_menu = tk.Menu()


# .... File Menu STARTS ....

# Creating file menu object.....
file_menu = tk.Menu(main_menu, tearoff=False)

# File menu icons
# Setting all the icons for file menu....
new_icon = tk.PhotoImage(file="icons/new.png")
open_icon = tk.PhotoImage(file="icons/open.png")
save_icon = tk.PhotoImage(file="icons/save.png")
save_as_icon = tk.PhotoImage(file="icons/save_as.png")
exit_icon = tk.PhotoImage(file="icons/exit.png")

# .... File Menu ENDS ....


# ... Edit Menu STARTS ...

# Creating object for the edit menu...
edit_menu = tk.Menu(main_menu, tearoff=False)

# Edit Menu Icons...
copy_icon = tk.PhotoImage(file="icons/copy.png")
Beispiel #10
0
 def set_icon(self):
     icon = tk.PhotoImage(data=self.engine.get_icon("app"))
     self.call("wm", "iconphoto", self._w, "-default", icon)
    def __init__(self, master,parent):
       """
       Constructor for intialization of this page
       """
       pages.page.Page.__init__(self,master)
       self.parent=parent

       #Top row for Custom Variable selection
       self.varsVar=tk.StringVar(self)
       self.varsVar.trace("w",self._varsVarSelectionChanged)
       self.cBoxVars=tk.OptionMenu(self, self.varsVar, *parent.getCustomvarsString())
       self.cBoxVars.pack(side="top", expand="true")


       #Stack panels for individual rows
       self.customFrame1=tk.Frame(self)
       self.customFrame1.pack(side="top",expand="true")
       self.customFrame2=tk.Frame(self)
       self.customFrame2.pack(side="top",expand="true")
       self.customFrame3=tk.Frame(self)
       self.customFrame3.pack(side="top",expand="true")
       self.customFrame4=tk.Frame(self)
       self.customFrame4.pack(side="top",expand="true")
       self.customFrame5=tk.Frame(self)
       self.customFrame5.pack(side="top",expand="true")
       self.customFrame6=tk.Frame(self)
       self.customFrame6.pack(side="top",expand="true")
       self.customFrame7=tk.Frame(self)
       self.customFrame7.pack(side="top",expand="true")
       self.customFrame8=tk.Frame(self)
       self.customFrame8.pack(side="top",expand="true")
       self.customFrame9=tk.Frame(self)
       self.customFrame9.pack(side="top",expand="true")
       self.customFrame10=tk.Frame(self)
       self.customFrame10.pack(side="top",expand="true")

       #Buttons Images
       self.imgAddColumn=tk.PhotoImage(file="images/btnAddColumns.gif")
       self.imgFillMean=tk.PhotoImage(file="images/btnFillMissingWithMean.gif")
       self.imgFillMedian=tk.PhotoImage(file="images/btnFillMissingWithMedian.gif")
       self.imgFillMeanGrouped=tk.PhotoImage(file="images/btnFillMissingWithMeanGrouped.gif")
       self.imgFillMedianGrouped=tk.PhotoImage(file="images/btnFillMissingWithMedianGrouped.gif")
       self.imgLogTransform=tk.PhotoImage(file="images/btnLogTransform.gif")
       
       #Row: Add Columns
       self.varAddColumn1=tk.StringVar(self.customFrame1)
       self.cBoxAddColumn1=tk.OptionMenu(self.customFrame1, self.varAddColumn1, *parent.getColumns(parent.getVarValue(self.varsVar.get())))
       self.cBoxAddColumn1.pack(side="left", expand="true")
       self.varAddColumn2=tk.StringVar(self.customFrame1)
       self.cBoxAddColumn2=tk.OptionMenu(self.customFrame1, self.varAddColumn2, *parent.getColumns(parent.getVarValue(self.varsVar.get())))
       self.cBoxAddColumn2.pack(side="left", expand="true")
       self.varAddColumnOut=tk.StringVar(self.customFrame1)
       self.txtAddColumnOut=tk.Entry(self.customFrame1,textvariable=self.varAddColumnOut)
       self.txtAddColumnOut.pack(side="left")
       self.btnAddColumn=tk.Button(self.customFrame1,text="Add Column",command=self._btnAddColumnClicked, image=self.imgAddColumn)
       self.btnAddColumn.pack(side="left")

       #Row: Fill Missing With Mean 
       self.varFillMean=tk.StringVar(self.customFrame2)
       self.cBoxFillMean=tk.OptionMenu(self.customFrame2, self.varFillMean, *parent.getColumns(parent.getVarValue(self.varsVar.get())))
       self.cBoxFillMean.pack(side="left", expand="true")
       self.btnFillMean=tk.Button(self.customFrame2,text="Fill Missing With Mean",command=self._btnFillMeanClicked, image=self.imgFillMean)
       self.btnFillMean.pack(side="left")

       #Row: Fill Missing With Median
       self.varFillMedian=tk.StringVar(self.customFrame3)
       self.cBoxFillMedian=tk.OptionMenu(self.customFrame3, self.varFillMedian, *parent.getColumns(parent.getVarValue(self.varsVar.get())))
       self.cBoxFillMedian.pack(side="left", expand="true")
       self.btnFillMedian=tk.Button(self.customFrame3,text="Fill Missing With Median",command=self._btnFillMedianClicked, image=self.imgFillMedian)
       self.btnFillMedian.pack(side="left")

       #Row: Fill Missing With Mean Grouped and Fill Missing With Median Grouped
       self.varFillMeanGroup=tk.StringVar(self.customFrame4)
       self.cBoxFillMeanGroup=tk.OptionMenu(self.customFrame4, self.varFillMeanGroup, *parent.getColumns(parent.getVarValue(self.varsVar.get())))
       self.cBoxFillMeanGroup.pack(side="left", expand="true")
       columns=parent.getColumns(parent.getVarValue(self.varsVar.get()))
       self.lstFillMeanIndex=tk.Listbox(self.customFrame4, selectmode=tk.MULTIPLE,exportselection=0)
       for column in columns:
           self.lstFillMeanIndex.insert(tk.END, column)
       self.lstFillMeanIndex.pack(side="left")
       self.lstFillMeanCol=tk.Listbox(self.customFrame4, selectmode=tk.MULTIPLE,exportselection=0)
       for column in columns:
           self.lstFillMeanCol.insert(tk.END, column)
       self.lstFillMeanCol.pack(side="left")
       self.btnFillMeanGroup=tk.Button(self.customFrame4,text="Fill Missing With Mean Grouped",command=self._btnFillMeanGroupClicked, image=self.imgFillMeanGrouped)
       self.btnFillMeanGroup.pack(side="left")
       self.btnFillMedianGroup=tk.Button(self.customFrame4,text="Fill Missing With Median Grouped",command=self._btnFillMedianGroupClicked, image=self.imgFillMedianGrouped)
       self.btnFillMedianGroup.pack(side="top")

       #Row: Log Transform
       self.varLogColumn=tk.StringVar(self.customFrame5)
       self.cBoxLogColumn=tk.OptionMenu(self.customFrame5, self.varLogColumn, *parent.getColumns(parent.getVarValue(self.varsVar.get())))
       self.cBoxLogColumn.pack(side="left", expand="true")
       self.varLogColumnOut=tk.StringVar(self.customFrame5)
       self.txtLogColumnOut=tk.Entry(self.customFrame5,textvariable=self.varLogColumnOut)
       self.txtLogColumnOut.pack(side="left")
       self.btnLogColumn=tk.Button(self.customFrame5,text="Log Transform",command=self._btnLogColumnClicked, image=self.imgLogTransform)
       self.btnLogColumn.pack(side="left")

       #Impute
       #tk.Label(self.customFrame6,text="Fit Model:  ").pack(side="left")
       #self.varFitModel=tk.StringVar(self.customFrame6)
       #self.cBoxFitModel=tk.OptionMenu(self.customFrame6, self.varFitModel, *parent.getCustomvarsString())
       #self.cBoxFitModel.pack(side="left", expand="true")
       #tk.Label(self.customFrame6,text="Strategy:  ").pack(side="left")
       #self.varImputeStrategy=tk.StringVar(self.customFrame6)
       #options=['mean','median']
       #self.cBoxImputeStrategy=tk.OptionMenu(self.customFrame6, self.varImputeStrategy, *options)
       #self.cBoxImputeStrategy.pack(side="left", expand="true")
       #self.btnImpute=tk.Button(self.customFrame6,text="Impute",command=self._btnImputeClicked)
       #self.btnImpute.pack(side="left")

       #Multi Impute
       #tk.Label(self.customFrame7,text="Fit Model:  ").pack(side="left")
       #self.varMFitModel=tk.StringVar(self.customFrame7)
       #self.cBoxMFitModel=tk.OptionMenu(self.customFrame7, self.varMFitModel, *parent.getCustomvarsString())
       #self.cBoxMFitModel.pack(side="left", expand="true")
       #tk.Label(self.customFrame7,text="Imputation Order:  ").pack(side="left")
       #self.varMImputeOrder=tk.StringVar(self.customFrame7)
       #options=['ascending']
       #self.cBoxMImputeOrder=tk.OptionMenu(self.customFrame7, self.varMImputeOrder, *options)
       #self.cBoxMImputeOrder.pack(side="left", expand="true")
       #tk.Label(self.customFrame7,text="Strategy:  ").pack(side="left")
       #self.varMImputeStrategy=tk.StringVar(self.customFrame7)
       #options=['mean','median']
       #self.cBoxMImputeStrategy=tk.OptionMenu(self.customFrame7, self.varMImputeStrategy, *options)
       #self.cBoxMImputeStrategy.pack(side="left", expand="true")
       #Multi Impute Row 2
       #tk.Label(self.customFrame8,text="Burn In:  ").pack(side="left")
       #self.varBurnIn=tk.StringVar(self.customFrame8)
       #self.varBurnIn.set(10)
       #self.txtBurnIn=tk.Spinbox(self.customFrame8, from_ = 1, to = 300,textvariable=self.varBurnIn)
       #self.txtBurnIn.pack(side="left")
       #tk.Label(self.customFrame8,text="Imputations:  ").pack(side="left")
       #self.varImputations=tk.StringVar(self.customFrame8)
       #self.varImputations.set(10)
       #self.txtImputations=tk.Spinbox(self.customFrame8, from_ = 1, to = 300,textvariable=self.varImputations)
       #self.txtImputations.pack(side="left")
       #tk.Label(self.customFrame8,text="Nearest Features:  ").pack(side="left")
       #self.varNFeatures=tk.StringVar(self.customFrame8)
       #self.txtNFeatures=tk.Spinbox(self.customFrame8, from_ = 1, to = 300,textvariable=self.varNFeatures)
       #self.txtNFeatures.pack(side="left")
       #Multi Impute Row 3
       #self.btnMImpute=tk.Button(self.customFrame9,text="Multi Impute",command=self._btnMImputeClicked)
       #self.btnMImpute.pack(side="left")
       

       #Row: Output Console
       self.txtOutput=tk.Text(self.customFrame10)
       self.txtOutput.config(font=("consolas",8),bg='green',wrap="none")
       self.txtOutput.pack(side="top")
       self.sbTxtOutputY=tk.Scrollbar(self.customFrame10,command=self.txtOutput.yview)
       self.txtOutput['yscrollcommand']=self.sbTxtOutputY.set
       self.sbTxtOutputY.pack(side="left", expand=True,fill="y")
       self.sbTxtOutputX=tk.Scrollbar(self.customFrame10,command=self.txtOutput.xview)
       self.txtOutput['xscrollcommand']=self.sbTxtOutputX.set
       self.sbTxtOutputX.pack(side="top", expand=True,fill="x")
    global display
    calc_num = calc_num.replace("×", "*")
    calc_num = calc_num.replace("÷", "/")
    if process_permutation_combination() and calc_num != "" and valid_calc(
            calc_num):
        try:
            display = str(round(eval(calc_num), 6))
        except:
            display = "Invalid Syntax... Please Try Again"
    text.set(display)
    display = ""
    calc_num = ""


# CREATE FRAMES
background_image = tk.PhotoImage(file="blue_background.png")
background_label = tk.Label(root, image=background_image)
background_label.place(relwidth=1, relheight=1)

high_frame = tk.Frame(root, bg="red", bd=3)
high_frame.place(relx=0.5, rely=0.05, relwidth=0.8, relheight=0.15, anchor="n")
low_frame = tk.Frame(root, bg="green", bd=5)
low_frame.place(relx=0.5, rely=0.25, relwidth=0.8, relheight=0.7, anchor="n")

# CREATE HIGH_FRAME
text_box = tk.Label(high_frame, textvariable=text, font=("arial", 20, "bold"))
text_box.place(relwidth=1, relheight=1)

# CREATE LOW_FRAME BUTTONS
button_fact = tk.Button(low_frame, text="!", command=lambda: btn_factorial())
button_fact.place(relx=0, rely=0, relwidth=0.25, relheight=0.2)
Beispiel #13
0
# move an Image on the canvas with tkinter

import tkinter as tk

# Create the window with the Tk class
root = tk.Tk()

# Create the canvas and make it visible with pack()
canvas = tk.Canvas(root, width=800, height=800)
canvas.pack()  # this makes it visible

# Loads and create image (put the image in the folder)
img = tk.PhotoImage(file="mega.png")
image = canvas.create_image(10, 10, anchor=tk.NW, image=img)


def move(event):
    """Move the sprite image with a d w and s when click them"""
    if event.char == "a":
        canvas.move(image, -10, 0)
    elif event.char == "d":
        canvas.move(image, 10, 0)
    elif event.char == "w":
        canvas.move(image, 0, -10)
    elif event.char == "s":
        canvas.move(image, 0, 10)


# This bind window to keys so that move is called when you press a key
root.bind("<Key>", move)
Beispiel #14
0
    def AboutMsg(self):
        global version
        self.aTop = tk.Toplevel()
        self.aTop.resizable(0, 0)

        noteb = ttk.Notebook(self.aTop, padding=(5, 1, 5, 5))
        notebTab1 = ttk.Frame(noteb)
        notebTab2 = ttk.Frame(noteb)
        noteb.add(notebTab1, text='About')
        noteb.add(notebTab2, text='Description')
        noteb.pack(fill='both')

        # ABOUT tab
        aLabel = tk.Label(notebTab1,
                          pady=10,
                          text=f"\n\npCalc",
                          font=("Biome 20 bold"))
        aLabel.pack(fill='both')

        aLabel = tk.Label(notebTab1,
                          pady=10,
                          text=f"version: {version}\n",
                          font=("Biome 16"))
        aLabel.pack(fill='both')

        aBut = ttk.Button(notebTab1, text="Close", command=self.aTop.destroy)
        aBut.pack(side='bottom', pady=10)

        self.img_author = tk.PhotoImage(file="img/programoteq.100.png")
        self.img_Label = tk.Label(notebTab1, image=self.img_author)
        self.img_Label.pack(side='bottom', padx=2, pady=20)

        # DESCRIPTION tab
        textbox = tk.Text(notebTab2,
                          width=70,
                          height=28,
                          font=("Biome 10"),
                          wrap='word',
                          bg='grey95',
                          padx=5,
                          pady=5)
        textbox.pack()

        # Section 1
        textbox.insert(tk.END, "\nMain functions: ", ("h1"))
        textbox.insert(tk.END, "\n\n - Natural Order of Opeartions:", ("h2"))
        textbox.insert(
            tk.END, ''' Calculations can be input in the same form as 
   they are written, the priority sequence of the input calculation will be \
evaluated
   automatically according to the operator precedence, eg. 1 + 2 x 3 = 7.
''')
        textbox.insert(tk.END, " - Equation Input Control Rules:", ("h2"))
        textbox.insert(
            tk.END, ''' advanced supervision mechanism introduced in
   order to minimize number of syntax errors.
''')
        textbox.insert(tk.END, " - Answer Memory (Ans):", ("h2"))
        textbox.insert(
            tk.END, ''' the last calculation result obtained is stored in Ans
   (answer) memory. You can scroll back through all the previous calculation \
results'
   by pressing Ans key.
''')
        textbox.insert(tk.END, " - Calculation Precision Setup:", ("h2"))
        textbox.insert(
            tk.END, ''' The value you specify (from 1 to 5 or FULL)
   controls the number of decimal places for displayed calculation results.
   Calculation results are rounded off to the specified digit before being \
displayed.
''')
        textbox.insert(tk.END, " - Engineering notation", ("h2"))
        textbox.insert(tk.END, ''', eg. 1.2 e+3 = 1.2 x 10^3 = 1200.

''')

        # Section 2
        textbox.insert(tk.END, "Available operators: ", ("h1"))
        textbox.insert(tk.END, "\n\n - basic arithmetic opertors:", ("h2"))
        textbox.insert(
            tk.END, ''' addition, subtraction, multiplication and division
''')
        textbox.insert(tk.END, " - floor division operator", ("h2"))
        textbox.insert(
            tk.END, ''' (integral part of the division), eg. 5 // 3 = 1
''')
        textbox.insert(tk.END, " - modulus opeartor", ("h2"))
        textbox.insert(tk.END, ''' (remainder of the division), eg. 5 mod 3 = 2
''')
        textbox.insert(tk.END, " - exponenet operator", ("h2"))
        textbox.insert(
            tk.END, ''' (raises the left operand to the power of the right),
   eg. 2 ^ 3 = 8
''')
        textbox.insert(tk.END, " - roots:", ("h2"))
        textbox.insert(
            tk.END,
            ''' available using exponent operator, as 1/n exponent is equal to
   n-th root of the number, eg. 8 ^ (1/3) = 2
''')
        textbox.insert(tk.END, " - use of parenthesis:", ("h2"))
        textbox.insert(
            tk.END,
            ''' please note that input of the closing parenthesis is required
''')
        textbox.insert(tk.END, " - Pi number:", ("h2"))
        textbox.insert(tk.END, ''' being equal to 3.141592653

''')

        textbox.tag_config("h1", font=("Biome 13 bold"))
        textbox.tag_config("h2", font=("Tahoma 10 bold"))
        textbox.config(state='disabled')

        aBut = ttk.Button(notebTab2, text="Close", command=self.aTop.destroy)
        aBut.pack(side='bottom', pady=10)
Beispiel #15
0
import tkinter as tk
import requests
import random

root = tk.Tk()

HEIGHT = 700
WIDTH = 800

canvas = tk.Canvas(root, height=HEIGHT, width=WIDTH, bg="#b5d6b2")
canvas.pack()

frame = tk.Frame(root, bg="#b5d6b2")
frame.place(relwidth=1, relheight=1)

comb = tk.PhotoImage(file="comb.png", height=400)
comb1 = tk.Label(frame, image=comb, bg="#b5d6b2")
comb1.place(relx=0.2, rely=0, relwidth=0.6, relheight=0.6)

text = tk.PhotoImage(file="text.png")
text1 = tk.Label(frame, image=text, bg="#b5d6b2", height=100, width=500)
text1.place(relx=0.3, rely=0.3, relwidth=0.4, relheight=0.4)

#var = tk.StringVar()
#welcomeMessage = tk.Message(frame, textvariable=var, bg="#b5d6b2", width=500, font="oemfixed")
#var.set("So, you want to practice your times table up to 12... In that case, I have prepared for you, an extremely stressful, super cool, challenging, impossible exam. Press start if you think you have a slight chance of passing. ")
#welcomeMessage.place(relx=0.4)

#QuestionOne = tk.Entry(root)
#QuestionOne.pack()
Beispiel #16
0

root = tkinter.Tk()
root.title("Paint labyrinth")

root.bind("<KeyPress>", key_down)
root.bind("<KeyRelease>", key_up)

canvas = tkinter.Canvas(width=800, height=560, bg="white")
canvas.pack()

meiro = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1, 0, 0, 1],
         [1, 0, 1, 1, 0, 0, 1, 0, 0, 1], [1, 0, 0, 1, 0, 0, 0, 0, 0, 1],
         [1, 0, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
         [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]

for y in range(7):
    for x in range(10):
        if meiro[y][x] == 1:
            canvas.create_rectangle(x * 80,
                                    y * 80,
                                    x * 80 + 79,
                                    y * 80 + 79,
                                    fill="skyblue",
                                    width=0)

img = tkinter.PhotoImage(file="images/mimi_s.png")
canvas.create_image(mx * 80 + 40, my * 80 + 40, image=img, tag="MYCHAR")
main_proc()
root.mainloop()