[Tutor] tkinter and visual with objects
Mr Gerard Kelly
s4027340 at student.uq.edu.au
Thu Feb 5 02:21:43 CET 2009
I'm trying to make this very simple program, where the idea is that you
click a tkinter button named "Ball" and then a ball will appear in the
visual window.
Problem is that the window itself doesn't pop up until the button is
pressed and the ball is created. I would like it to start out blank, and
then have the ball appear in it when the button is pressed.
I thought that having "self.display=display()" in the __init__ of the
Application would do this, but it doesn't seem to.
What do I need to add to this code to make it start out with a blank window?
from visual import *
from Tkinter import *
import sys
class Ball:
def __init__(self):
sphere(pos=(0,0,0))
class Application:
def __init__(self, root):
self.frame = Frame(root)
self.frame.pack()
self.display=display()
self.button=Button(self.frame, text="Ball", command=self.ball)
self.button.pack()
def ball(self):
self.ball=Ball()
root=Tk()
app=Application(root)
root.mainloop()
More information about the Tutor
mailing list