Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

python,tkinter>>placing an oval by mouse

Status
Not open for further replies.

frozenevil

Programmer
Nov 6, 2007
4
MU
hi....i'm working on an simulation and initially i have to place an oval with a mouse click on an tkinter interface. can someone please help me to slove this problem or if possible give me piece of codes to create the oval y mouse click.

thank 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)



root = Tkinter.Tk()


root.mainloop()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top