Sep-01-2020, 06:33 PM
I'm using Python3.8 for my raspberry pi4 project. I have a GUI that initially displays the label within a grid. I also have a button that when clicked, should display the calculated value of CO2 in the label. However, it does not display the CO2 value and there is no error flagged. Below is my code snippet (I removed others as they're not relevant to this question):
frame2 = Frame(root) lblCo2 = Label(frame2, text="CO2 (ppm)") lblCo2.grid(row=4, sticky=W) valCo2 = Label(frame2, bg="white", width=12) valCo2grid(row=4, column=1, sticky=W) btnStart = Button(frame2, text="Start", command=btnStart_callback) btnStart.grid(row=5, column=1, sticky=W) frame2.pack() def btnStart_callback(): CycleCO2() def CycleCO2(): Cmd1 = [0xFE, 0x44, 0x00, 0x08, 0x02, 0x9F, 0x25) high = Cmd1[3] low = Cmd1[4] co2 = (high*256) + low valCo2 = tk.Label(frame2, text=co2)Appreciate any help.