I have code that does multiple place and place hides on labels so I don't have create additional windows.
A problem is showing up when I use the GPIO commands where one of the labels, no matter what I do, will not show up when the screen is changed. The problem doesn't show up when the GPIO commands are removed.
Here's a picture of the entry screen. When the blue button with the ruler is pressed it goes to this screen. Note how all of the white spaces (labels) have text in them. After running the code and pressing the cancel (X) button, it goes back to the previous screen (first shown above).
Now if I press the blue button on the entry screen to re-enter the measure screen, this is what shows up.
Here's the code that handles that part of the processAs I mentioned before, if I comment out all the GPIO text, the label shows up. If I leave it in, the label is empty.
I've double check to make sure that nothing is overwriting that label, have changed the name of the label and even moved it to different parts of the screen. I'm stumped at this point.
Any ideas?
A problem is showing up when I use the GPIO commands where one of the labels, no matter what I do, will not show up when the screen is changed. The problem doesn't show up when the GPIO commands are removed.
Here's a picture of the entry screen. When the blue button with the ruler is pressed it goes to this screen. Note how all of the white spaces (labels) have text in them. After running the code and pressing the cancel (X) button, it goes back to the previous screen (first shown above).
Now if I press the blue button on the entry screen to re-enter the measure screen, this is what shows up.
Here's the code that handles that part of the process
Code:
def measure_length(): global encoder_sleep global rotations_inch global current_menu global encoder_white_pin global encoder_green_pin global encoder_sleep global count_avg current_menu = "measure" close_keyboard_1_C() amount_label.place_forget() amount_entry.place_forget() measure_len_button.place_forget() generic_label_1.configure(text="Pull 1 inch of cord") generic_label_1.config(font=(None, 15)) generic_label_1.place(x=150, y=15) generic_label_2.configure(text="Measure 1: 0") generic_label_2.config(font=(None, 15)) generic_label_2.place(x=150, y=65) generic_label_3.configure(text="Measure 2: 0") generic_label_3.config(font=(None, 15)) generic_label_3.place(x=150, y=105) generic_label_4.configure(text="Measure 3: 0") generic_label_4.config(font=(None, 15)) generic_label_4.place(x=150, y=145) generic_label_5.configure(text="Average Measure: 0") generic_label_5.config(font=(None, 15)) generic_label_5.place(x=150, y=185) counter_1 = 0 counter_2 = 0 counter_3 = 0 count_avg = 0 counter = 0 old_counter = 0 start = 0 end = 0 encoder_white_last = GPIO.input(encoder_white_pin) encoder_white_state = 0 encoder_green_state = 0 measuring =True# First measurement while measuring == True: encoder_white_state = GPIO.input(encoder_white_pin) encoder_green_state = GPIO.input(encoder_green_pin) if encoder_white_state != encoder_white_last: if encoder_green_state != encoder_white_state: counter += 1 else: counter -= 1 generic_label_2.configure(text="Measure 1: " + str(counter)) encoder_white_last = encoder_white_state time.sleep(encoder_sleep) if old_counter != counter: start = timer() old_counter = counter end = timer() if end-start > 5 and old_counter != 0: generic_label_2.configure(text="Measure 1: " + str(counter) + " done") measuring = False counter_1 = counter generic_label_5.configure(text="Average Measure: " + str(counter_1)) root.update_idletasks()# second measurement counter = 0 old_counter = 0 start = 0 end = 0 encoder_white_last = GPIO.input(encoder_white_pin) encoder_white_state = 0 encoder_green_state = 0 measuring =True while measuring == True: encoder_white_state = GPIO.input(encoder_white_pin) encoder_green_state = GPIO.input(encoder_green_pin) if encoder_white_state != encoder_white_last: if encoder_green_state != encoder_white_state: counter += 1 else: counter -= 1 generic_label_3.configure(text="Measure 2: " + str(counter)) encoder_white_last = encoder_white_state time.sleep(encoder_sleep) if old_counter != counter: start = timer() old_counter = counter end = timer() if end-start > 5 and old_counter != 0: generic_label_3.configure(text="Measure 2: " + str(counter) + " done") measuring = False counter_2 = counter count_avg = int(round(float((counter_1 + counter_2)/2),0)) generic_label_5.configure(text="Average Measure: " + str(count_avg)) root.update_idletasks()# third measurement counter = 0 old_counter = 0 start = 0 end = 0 encoder_white_last = GPIO.input(encoder_white_pin) encoder_white_state = 0 encoder_green_state = 0 measuring =True while measuring == True: encoder_white_state = GPIO.input(encoder_white_pin) encoder_green_state = GPIO.input(encoder_green_pin) if encoder_white_state != encoder_white_last: if encoder_green_state != encoder_white_state: counter += 1 else: counter -= 1 generic_label_4.configure(text="Measure 3: " + str(counter)) encoder_white_last = encoder_white_state time.sleep(encoder_sleep) if old_counter != counter: start = timer() old_counter = counter end = timer() if end-start > 5 and old_counter != 0: generic_label_4.configure(text="Measure 3: " + str(counter) + " done") measuring = False counter_3 = counter count_avg = int(round(float((counter_1 + counter_2 + counter_3)/3),0)) generic_label_5.configure(text="Average Measure: " + str(count_avg)) amount_entry.insert('end', str(count_avg)) root.update_idletasks()
I've double check to make sure that nothing is overwriting that label, have changed the name of the label and even moved it to different parts of the screen. I'm stumped at this point.
Any ideas?
Statistics: Posted by gwfami — Mon Dec 18, 2023 8:24 pm