Hello!
I'm new to the Python language(about 2 months). Having done C programming for 2 years I find out I need Python for a final project, and have been trying to do get my head around object oriented programming. At the moment I'm simply trying to get the colour of a circle to change when you press a button. I've got this so far:
I know the problem is with the defcolour(self) , but don't really know how to proceed. If anyone could point me in the right direction, or a link to a tutorial that would help it would be very much appreciated!
Mel
I'm new to the Python language(about 2 months). Having done C programming for 2 years I find out I need Python for a final project, and have been trying to do get my head around object oriented programming. At the moment I'm simply trying to get the colour of a circle to change when you press a button. I've got this so far:
Code:
from Tkinter import *
class Op:
def __init__(self, master):
frame = Frame(master)
frame.pack()
self.button = Button(frame, text="Bye Bye", fg="green", bg="black", command=frame.quit)
self.button.pack(side=RIGHT)
self.button2 = Button(frame, text="circle", fg="red", bg="black", command=self.circle)
self.button2.pack(side=LEFT)
def circle(self):
canvas = Canvas(width=210, height=210)
canvas.pack()
self.button4=Button(canvas, text="colour blue", command=self.colour)
self.button4.pack()
canvas = Canvas(width=210, height=210, bg='black')
canvas.pack(expand=YES, fill=BOTH)
canvas.create_oval(10, 10, 200, 200, width=2, fill='red')
def colour(self):
canvas.create_oval(10, 10, 200, 200, width=2, fill='blue')
create_oval.pack()
root = Tk()
op = Op(root)
root.mainloop()
Mel
Comment