firstly can i run tkinter over VNC and secondly when i press the button (when you press it it goes to the forwards command) i get an error which says
Code: Select all
TypeError: forwards() takes no arguments (1 given)and if I can't run my code over VNC how else can I control it with a graphical interface?
This is the code
Code: Select all
from Tkinter import *
import tkMessageBox
import RPi.GPIO as gpio
import time
gpio.setwarnings(False)
gpio.setmode(gpio.BOARD)
gpio.setup(7, gpio.OUT)
gpio.setup(11, gpio.OUT)
gpio.setup(13, gpio.OUT)
gpio.setup(15, gpio.OUT)
gpio.output(7, False)
gpio.output(11, False)
gpio.output(13, False)
gpio.output(15, False)
def forwards():
gpio.output(7, True)
gpio.output(11, False)
gpio.output(13, True)
gpio.output(15, False)
def left():
gpio.output(7, True)
gpio.output(11, False)
gpio.output(13, False)
gpio.output(15, True)
def right():
gpio.output(7, False)
gpio.output(11, True)
gpio.output(13, True)
gpio.output(15, False)
def backwards():
gpio.output(7, False)
gpio.output(11, True)
gpio.output(13, False)
gpio.output(15, True)
def stopProg(e):
root.destroy()
def login():
if u.get() == 'p' and p.get() == 'p':
distance_var = 'this will be added later'
size = 512
stealthmodevar = StringVar()
root = Tk()
root.title('Robot Controller')
top.destroy()
commandlineframe = Frame(root, width=size, height=size)
commandlineframe.grid(row=0, column=1)
piliteframe = Frame(root, width=size, height=size)
piliteframe.grid(row=0, column=0)
padup = Canvas(root, height=200, width=512)
padup.create_rectangle(206, 100, 306, 200, fill='blue', width=0)
padup.create_polygon(256, 0, 356, 150, 156, 150, fill='blue', width=0)
padup.bind('<Button-1>', forwards)
padup.grid(row=1, column=1)
#piliteframe section
pilitetext = Label(piliteframe, text = 'Pi-Lite text entry')
pilitetext.grid(row=0, column=0)
piliteentry = Entry(piliteframe)
piliteentry.grid(row=0, column=1)
pilitepicture = Label(piliteframe, text = 'Pi-Lite pictures')
LCDtext = Label(piliteframe, text = 'LCD display text')
LCDtext.grid(row=2, column=0)
LCDtext1 = Label(piliteframe, text = 'LCD display text')
LCDtext1.grid(row=3, column=0)
LCDent = Entry(piliteframe)
LCDent.grid(row=2, column=1)
pilitepicture.grid(row=1, column=0)
#make the camera frame
cameraframe = Frame(root, height=size, width=size)
cameraframe.grid(row=1, column=0)
#make the buttons
lengthent = Entry(cameraframe)
lengthent.grid(row=1, column=3)
length = Label(cameraframe, text='Video Length')
length.grid(row=1, column=2)
video = Button(cameraframe, text = 'Record Video')
video.grid(row=1, column=1)
stealth = Checkbutton(cameraframe, text='Stealth Mode', variable=stealthmodevar, onvalue='Y', offvalue='N')
stealth.grid(row=0, column=0)
photo = Button(cameraframe, text='Take Photo')
photo.grid(row=1, column=0)
distance = Label(cameraframe, text='Distance from Robot:')
distance.grid(row=2, column=0)
distancelabel = Label(cameraframe, text=distance_var)
distancelabel.grid(row=2, column=1)
# quitroot = Button(cameraframe, text='Quit')
# quitroot.grid(row=3, column=0)
# quitroot.bind('<Button-1>', stopProg)
root.mainloop()
else:
tkMessageBox.showwarning('Incorrect Username or Password', 'You have typed in your Username or Password incorrectly please try again')
#create window
top=Tk()
top.title('Login')
top.configure(background='yellow')
#make the username label
username = Label(top, text='Username:', bg='yellow')
username.pack()
#make the username entry widget
u = Entry(top)
u.pack()
#make the password label
password = Label(top, text='Password:', bg='yellow')
password.pack()
#make the password entry widget
p = Entry(top)
p.pack()
#make the login button
login = Button(top, text='Login:', command=login, fg='white', bg='red')
login.pack()
top.mainloop()
Olly