Created
October 11, 2016 15:09
-
-
Save lvidarte/a5d9d8ae2efe28cd308e27ed32ebe18c to your computer and use it in GitHub Desktop.
TK Interface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import time | |
import Tkinter as tk | |
from serial import Serial | |
from minirobots import Turtle | |
try: | |
serial = Serial('/dev/rfcomm0', 57600) | |
time.sleep(1) | |
except OSError: | |
print "Can't connect to serial device on", args.port | |
sys.exit(1) | |
turtle = Turtle(serial) | |
turtle.pen_down() | |
root = tk.Tk() | |
root.title('Tortuga') | |
button_forward = tk.Button(root, text='Adelante', command=lambda:turtle.forward(20)) | |
button_left = tk.Button(root, text='Izquierda', command=lambda:turtle.left(90)) | |
button_right = tk.Button(root, text='Derecha', command=lambda:turtle.right(90)) | |
button_backward = tk.Button(root, text='Atrás', command=lambda:turtle.backward(20)) | |
options = dict(padx=10, pady=10, ipadx=20, ipady=20) | |
button_forward.grid(row=0, columnspan=2, **options) | |
button_left.grid(row=1, column=0, **options) | |
button_right.grid(row=1, column=1, **options) | |
button_backward.grid(row=2, columnspan=2, **options) | |
tk.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment