Raspberry Pi 10 interface

 

from guizero import App, Text, TextBox, PushButton, Slider, Picture, Combo, Window 

import serial 

palce1_name = "Beijing" 
palce1_num = "001" 
palce2_name = "Tokyo" 
palce2_num = "002" 
palce3_name = "Nanjing" 
palce3_num = "003" 

ser = serial.Serial ('/ dev / ttyUSB0', 9600) 
if ser.isOpen == False: 
    ser.open () # open the serial port 



class gui_1_denglu: 
     
    def __init __ (self): 
        pass 
     
    # -------- --------------------------------------- 
    #Query 
    button def admin_test (self): 
      
        
        if self .zhanghu_in.get () == palce1_name: 
            self.show_msg.set ('Express query succeeded!') 
            self.bianhao_value.value=palce1_num
            self.didian_value.value = palce1_name 
            self.bianhao_value.value = 'No such package number'
            ser.write (b "motor1") # Serial transmission control motor 1 
        elif self.zhanghu_in.get () == palce2_name: 
            self.show_msg.set ('Express query succeeded!') 
            self.bianhao_value.value = palce2_num 
            self.didian_value .value = palce2_name 
            ser.write (b "motor2") # Serial port sends control motor 2 
        elif self.zhanghu_in.get () == palce3_name: 
            self.show_msg.set ('Express query succeeded!') 
            self.bianhao_value.value = palce3_num 
            self.didian_value.value = palce3_name 
            ser.write (b "motor3") # serial transmission control motor 3 
        else: 
            self.show_msg.set ('Express query failed!') 
            self.didian_value.value = 'No such package information'
         
    # 
    1Main interface login        def set_gui (self):
        
        1Main 
        # Create window title self.app = App (layout = "grid", title = "Face recognition system login interface", width = 400, height = 350) 
        #window = Window (app, title = "Second window") 
        # window.show (wait = True) 
         
        # 4 Picture 
        self.my_cat = Picture (self.app, image = "3.jpg", grid = [0 , 0,3,1]) #Create 
 
        input box and display font 
        self.zhanghu = Text (self.app, text = "Please enter express information:", grid = [0,1], align = "center", size = 10, 
                       font = "Times New Roman", color = "black") 
        self.zhanghu_in = TextBox (self.app, grid = [1,1], width = 20) 
       
        self.denglu_button = PushButton (self.app, grid = [2,1],command = self.admin_test, text = "query") #prompt 
 
     
        message
        self.show_msg = Text (self.app, text = "Query results", grid = [0,2,3,1], align = "center", size = 10, 
                    font = "Times New Roman", color = " red ") 
        #Prompt 
        message self.bianhao = Text (self.app, text =" Express Number: ", grid = [0,3,1,1], align =" center ", size = 10, 
                    font =" Times New Roman ", color =" red ") 
        #prompt 
        
         message self.bianhao_value = Text (self.app, text =" waiting for result ", grid = [1,3,1,1], align =" center ", size = 10, 
                    font = "Times New Roman", color = "blue") 
        
        self.didian = Text (self.app, text = "express location:", grid = [0,4,1,1], align = "center ", size = 10, 
                    font ="Times New Roman", color="red")
           
        self.didian_value = Text (self.app, text = "waiting for results", grid = [1,4,1,1], align="center",size=10,
                    font="Times New Roman", color="blue")
        
        self.app.display () 
     
d = gui_1_denglu () 
d.set_gui ()

  

Guess you like

Origin www.cnblogs.com/kekeoutlook/p/12677386.html