1

I would like to use buttonBox (from Python easyGUI) to trigger functions in Python. But I am not sure how to do it. The buttonbox code is like this:

buttonbox(msg='Robot Moving', title=' ', choices=('MoveFwd', 'MoveBwd', 'TurnR','TurnL'), image=None)

I want to trigger robot to move forward by clicking the button "MoveFwd". The MoveFwd in Python is already down and compiled. See code below.

def MoveFwd():
    ser = serial.Serial(3)
    print ser.name
    print 'Start Moving Fwd...'
    ser.write('SetMotor RWheelDist 200 Speed 100 LWheelDist 200 Speed 100 \n')
moveFwd()

Then my question is, how to link these two together?

pppery
  • 3,731
  • 22
  • 33
  • 46
Amber.G
  • 1,343
  • 5
  • 12
  • 16

1 Answers1

0

EasyGui is just that. Your time might be put to better use learning Tkinter, as it is pretty straight forward and will do these kinds of things, so you don't have to search everywhere for them. With easyGUI you have to roll your own function calls.

def call_function():
    print "call function executed"

choices=('MoveFwd', 'MoveBwd', "Call Function")
value=choicebox('Robot Moving', ' ', choices)
print "value =", value
if value==choices[2]:
    call_function()
else:
    print "nothing called"