I forgot the most important thing: the attachment.
-------- Original Message --------
Subject:        self-modification
Date:   Mon, 21 Aug 2006 16:04:19 +0200
From:   Zsiros Levente <[EMAIL PROTECTED]>
To:     python tutor <[email protected]>



I'm a newbie to Python. I wanted to write a graphical interface which would show the built-in documentation (I mean dir() and __doc__ ) of Python. The code shows how far I got before realizing that I had to use some self-modification feature (converting a string to a function or to an object; i'm not sure you would call it self-modification in an interpreted language).

I was googling around, and searching in the maillist archives and found this:
http://mail.python.org/pipermail/tutor/2004-October/032388.html
Unanswered for two years. Not too promising :)

P.S.: I'm new to this mailing list, so I don't know whether it is allowed to send code as attachment. (I didn't found anything about your policy in the subscription site. ) If not, I'm sorry.


#!/usr/bin/python

# In this program I wanted to write the event <B1-Motion> on my own, combining <Button-1>, <Motion> and <ButtonRelease-1>

from Tkinter import *


def handler(event):
	if buttonpressed == 1 :
		#if the mousebutton is pressed and moved, circles should appear, but they do not
		can.create_oval(event.x-r, event.y-r, event.x+r, event.y+r, fill="orange")
	lab.config(text='buttonpressed=' + str(buttonpressed) )

def press(event):
	buttonpressed=1
	lab2.config(text=buttonpressed)
	
def release(event):
	buttonpressed=0
	lab2.config(text=buttonpressed)	


r=5
#global buttonpressed
buttonpressed=0

root = Tk()
root.geometry('600x500+200+200')

# both labels are used to check the status of the variable buttonpressed
lab = Label(root, text='cucc')
lab2 = Label(root, text='cucc2')

can = Canvas(root, width='500', height='400', bg='white')
can.bind("<Motion>",handler)
can.bind("<Button-1>",press)
can.bind("<ButtonRelease-1>",release)

lab.pack()
lab2.pack()
can.pack()

root.mainloop()
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to