Hello good afternoon I am making an interface that can show the data of the xbee connected via usb.
I followed several videos that I have seen on informational pills, which have helped me get here.
But I have come to a problem, which I have not been able to get out.
I want to make a button that when I strip it, it sends a message to all the xbes of the network (that if it does) and this signal will start the reception of data. What I mean is that after removing the button, I will also start receiving data from the xbees.
I want to present this data on screen.
That is why I call a function and that function will give me the voltage date and time data, they are all strings and all those I indicate as StringVar (). And then I print it on some labels.
THE PROBLEM:
The button does not appear to me and the data is not printed on the labels.
You should mention that the button does appear to me if I "tie it to the root" but I did a FRAME to put all the labels there and I wanted to put the button there and it did not appear.
I followed several videos that I have seen on informational pills, which have helped me get here.
But I have come to a problem, which I have not been able to get out.
I want to make a button that when I strip it, it sends a message to all the xbes of the network (that if it does) and this signal will start the reception of data. What I mean is that after removing the button, I will also start receiving data from the xbees.
I want to present this data on screen.
That is why I call a function and that function will give me the voltage date and time data, they are all strings and all those I indicate as StringVar (). And then I print it on some labels.
THE PROBLEM:
The button does not appear to me and the data is not printed on the labels.
You should mention that the button does appear to me if I "tie it to the root" but I did a FRAME to put all the labels there and I wanted to put the button there and it did not appear.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
#-----------------------------Se importan las librerias------------------------------ from tkinter import * from digi.xbee.devices import XBeeDevice #-----------------------------Se inicializan Variables y puertos----------------- PORT = "COM5" BAUD_RATE = 9600 device = XBeeDevice(PORT, BAUD_RATE) #-----------------------------Se crea la pantalla principal-------------------- raiz = Tk() raiz.title( "Sistema de Monitoreo de Paneles Solares del SESLab" ) raiz.config(bg = "#032539" ) width_of_window = 600 height_of_window = 280 screen_width = raiz.winfo_screenwidth() screen_height = raiz.winfo_screenheight() x_coordinate = (screen_width / 2 ) - (width_of_window / 2 ) y_coordinate = (screen_height / 2 ) - (height_of_window / 2 ) raiz.geometry( "%dx%d+%d+%d" % (width_of_window, height_of_window, x_coordinate, y_coordinate )) miframe = Frame(raiz,width = "1200" ,height = "600" ) miframe.pack() miframe.config(bg = "#1C768F" ) #-----------------------------Valores por Mostrar en la Pantallas----------------- voltage = StringVar() hora = StringVar() fecha = StringVar() #------------------------------Cuadros donde se muestran datos----------------------- cuadroVisual1 = Label(miframe, textvariable = fecha, fg = "black" ,justify = "center" , relief = "ridge" , width = 20 ) cuadroVisual1.pack() cuadroVisual1.grid(row = 1 , column = 1 , padx = 2 , pady = 5 ) cuadroVisual2 = Label(miframe, textvariable = fecha, fg = "black" ,justify = "center" , relief = "ridge" , width = 20 ) cuadroVisual2.grid(row = 2 , column = 1 , padx = 2 , pady = 5 ) cuadroVisual3 = Label(miframe, textvariable = fecha, fg = "black" ,justify = "center" , relief = "ridge" , width = 20 ) cuadroVisual3.grid(row = 4 , column = 1 , padx = 2 , pady = 5 ) cuadroVisual4 = Label(miframe, textvariable = fecha, fg = "black" ,justify = "center" , relief = "ridge" , width = 20 ) cuadroVisual4.grid(row = 5 , column = 1 , padx = 2 , pady = 5 ) cuadroVisual5 = Label(miframe, textvariable = fecha, fg = "black" ,justify = "center" , relief = "ridge" , width = 20 ) cuadroVisual5.grid(row = 6 , column = 1 , padx = 2 , pady = 5 ) cuadroVisual6 = Label(miframe, textvariable = fecha, fg = "black" ,justify = "center" , relief = "ridge" , width = 20 ) cuadroVisual6.grid(row = 7 , column = 1 , padx = 2 , pady = 5 ) cuadroVisual7 = Label(miframe, textvariable = fecha, fg = "black" ,justify = "center" , relief = "ridge" , width = 20 , anchor = CENTER) cuadroVisual7.grid(row = 9 , column = 1 , padx = 2 , pady = 5 ) #---------------------------Cuadros donde esta el Texto------------------------ miLabel1 = Label(miframe, text = "Sistema de monitoreo de Paneles del SESLab" , font = 18 ) miLabel1.grid(row = 0 , column = 0 , padx = 5 , pady = 5 , columnspan = 2 ) nombrePanel2 = Label(miframe, text = "Fecha de medición : " , relief = "raised" ) nombrePanel2.grid(row = 1 , column = 0 , padx = 2 , pady = 5 ) nombrePanel3 = Label(miframe, text = "Hora de medición : " , relief = "raised" ) nombrePanel3.grid(row = 2 , column = 0 , padx = 2 , pady = 5 ) nombrePanel4 = Label(miframe, text = "Voltage de Panel 1 : " , relief = "raised" ) nombrePanel4.grid(row = 4 , column = 0 , padx = 2 , pady = 5 ) nombrePanel5 = Label(miframe, text = "Voltage de Panel 2 : " , relief = "raised" ) nombrePanel5.grid(row = 5 , column = 0 , padx = 2 , pady = 5 ) nombrePanel6 = Label(miframe, text = "Voltage de Panel 3 : " , relief = "raised" ) nombrePanel6.grid(row = 6 , column = 0 , padx = 2 , pady = 5 ) nombrePanel7 = Label(miframe, text = "Promedio : " , relief = "raised" ) nombrePanel7.grid(row = 7 , column = 0 , padx = 2 , pady = 5 ) nombrePanel8 = Label(miframe, text = "Panel con Menor Voltaje : " , relief = "raised" ) nombrePanel8.grid(row = 9 , column = 0 , padx = 2 , pady = 5 ) #------------------------Función que manda un mensaje Broadcast a Xbees--------- #------------------------Mensaje recibido---------------------------------------- def codigoIniciar(): device. open () DATA_TO_SEND = "Hola XBee!" device.send_data_broadcast(DATA_TO_SEND) try : device.flush_queues() while True : xbee_message = device.read_data() if xbee_message is not None : ##direccion.set(xbee_message.remote_device.get_64bit_addr()) data = xbee_message.data.decode() voltage. set (data.split( "," )[ 0 ]) hora. set (data.split( "," )[ 1 ]) #fecha.set(data.split(",")[2]) cuadroVisual1[ "text" ] = data.split( "," )[ 2 ] finally : if device is not None and device.is_open(): device.close() #--------------------Boton que llama a la función CodigoIniciar-------------- botonEnvio = Button(miframe, text = " Iniciar " ,command = codigoIniciar) botonEnvio.grid(row = 10 , column = 10 , padx = 5 , pady = 5 , columnspan = 2 , ) botonEnvio.config(bg = "#FA991C" ) botonEnvio.pack() #----------------Loop de la ventana -------------- raiz.mainloop() |