Python Forum
[PyGUI] Getting values from ButtonGroup
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGUI] Getting values from ButtonGroup
#1
Hi,
I have just started using guizero on a Raspberry Pi4 and I have hit a wall. I followed the tutorial for theater tickets and it worked as stated. I am trying to use the GUI as a basis for relay control and I substituted GPIO statements to turn on relays. What doesn't work is that when I try to use the value of "row_choice" in an IF statement I get no results from the GPIO. If I substitute print statements for the GPIO.output statement nothing prints. It seems that I can only print the value befor the If statement. I must have something wrong in the IF statement but after consulting the manual i can't find it.
Thanks in advance for any help.
Chris
from guizero import App,ButtonGroup,PushButton,info
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(14,GPIO.OUT)
GPIO.setup(15,GPIO.OUT)
GPIO.setup(18,GPIO.OUT)
app = App(title="Antenna", width=300, height=200, layout="grid")
row_choice = ButtonGroup(app, options=[ ["Long wire", 1], ["SlimJim", 2],["10m", 3],["Off", 0] ],selected=0, horizontal=True, grid=[1,2], align="left")

def do_booking():
    info("", "Selected")
    print(row_choice.value)
    if (row_choice.value)==1:
        GPIO.output(18,GPIO.HIGH)
    elif (row_choice.value)==0:
        GPIO.output(18,GPIO.LOW)

book_seats = PushButton(app, command=do_booking, text="Select", grid=[1,3], align="left")

app.display()
Reply


Messages In This Thread
Getting values from ButtonGroup - by cnjosack - Mar-30-2021, 02:14 PM
RE: Getting values from ButtonGroup - by joe_momma - Mar-30-2021, 02:50 PM
RE: Getting values from ButtonGroup - by cnjosack - Mar-30-2021, 06:23 PM
RE: Getting values from ButtonGroup - by deanhystad - Mar-30-2021, 06:58 PM
RE: Getting values from ButtonGroup - by cnjosack - Apr-01-2021, 07:45 PM
RE: Getting values from ButtonGroup - by deanhystad - Apr-02-2021, 04:20 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020