
February 2nd, 2013, 10:30 AM
|
 |
Contributing User
|
|
|
|
|
scrolled text example
Also investigate events and bindings
Code:
import sys
if '2' == sys.version[0]:
import Tkinter as tkinter
else:
import tkinter
root = tkinter.Tk()
canvas = tkinter.Canvas(root,width=400,height=100)
canvas.pack()
y = 100
scroll = canvas.create_text(0,y,anchor=tkinter.NW,text="""$ python3 q.py
Traceback (most recent call last):
File "q.py", line 12, in <module>
scroll.pack(tkinter.BOTTOM)
File "/usr/lib/python3.2/tkinter/__init__.py", line 1819, in pack_configure
+ self._options(cnf, kw))
File "/usr/lib/python3.2/tkinter/__init__.py", line 1066, in _options
for k, v in cnf.items():
AttributeError: 'str' object has no attribute 'items'""")
def f(*args,**kwargs):
global y
y -= 1
canvas.coords(scroll,0,y)
if y < -160:
root.destroy()
else:
canvas.after(20,f)
canvas.after(40,f)
root.mainloop()
__________________
[code] Code tags[/code] are essential for python code!
|