By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,903 Members | 1,977 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,903 IT Pros & Developers. It's quick & easy.

tkinter<< placing dot>>

P: 3
hi everybody...i'm trying to place an oval with a mouse click on my tkinter interface.
can anyone please give me the code of how should i do it.
i just want the part that i should add so that by clicking on interface an initial oval appear.
thank you in advance..
here is my code.


from Tkinter import *
import Tkinter
from Tkconstants import *
import random


frame=Tkinter.Frame()
frame.pack()



canvas =Tkinter.Canvas(frame,bg = 'white',width=200, height=400)
canvas.pack()



def generate():
for i in range(50):

x1=random.randrange(500)
y1=random.randrange(500)
x2=x1+5
y2= y1+5

canvas.create_oval(x1,y1,x2,y2,fill ="red")







button=Tkinter.Button(frame,fg="blue", text="GENERATE", activebackground='red',font=('verdana', 10, 'bold'),command=generate).pack(padx =50,side = LEFT)
#button2=Tkinter.Button(frame,fg ="blue",activebackground='red',font=('verdana', 10, 'bold'),command=generate).pack(padx =50,side = LEFT)



root = Tkinter.Tk()

# kick off the window's event loop
root.mainloop()
Jan 30 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.