GIDForums  

Go Back   GIDForums > Computer Programming Forums > Python Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 04-Feb-2008, 01:00
nish nish is offline
New Member
 
Join Date: Nov 2007
Posts: 3
nish is on a distinguished road

Creating an oval when clicking on a canvas by means of a mouse


Hi!! Actually,i am doing a simulation and i want a dot (small oval) to pop up when i click(by mouse) on the canvas.
can anyone please help me or if possible give me the piece of codes to perform this.
thanks in advance...

Python 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()
Last edited by LuciWiz : 04-Feb-2008 at 15:06. Reason: Please insert your Python code between [py] & [/py] tags
 
 

Recent GIDBlogDeveloping GUIs with wxPython (Part 2) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic mouse moving and clicking Padek78 MS Visual C++ / MFC Forum 2 28-Mar-2005 23:50
[Program/Tutorial] RandMouse aaroncohn C Programming Language 5 17-Dec-2004 19:22

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:20.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.