Re: [Tutor] visualization

2006-07-30 Thread Сергій
Thanks for your remarks, Alan. And " Law of Demeter" was something new and useful for me. This is corrected code (I hope I've understand all your remarks right):       # -*- coding: windows-1251 -*- import random, time, Tkinter class Agent:    def __init__ (self, x=100, y=100):    self.name = r

Re: [Tutor] visualization

2006-07-30 Thread Alan Gauld
Glad you got it working. A couple of observations: > This is the working version of my visualization: > class Agent: >def __init__ (self, x=100, y=100): >self.name = random.randint(0, 10) >self.x = x >self.y = y > >def __repr__ (self): >return str(self.

Re: [Tutor] visualization

2006-07-29 Thread Сергій
For a quick overview of Model/View (and sometimes Controller)take a look at the Apple web site. their default GUI design uses the paradigm and there is a good visual description  in theoverview: http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/chapter02/chapter_2_section_3.h

Re: [Tutor] visualization

2006-07-29 Thread Alan Gauld
> You will need to create a module that draws the GUI and >> handles the user events. That module will probably >> import this one (rather than this one importing Tkinter) >> You can then just pass the canvas object to each object >> in your environment and ask it to draw itself... > > You might li

Re: [Tutor] visualization

2006-07-29 Thread Сергій
Probably good to change the name, there is a built in class"object" and this could cause confusion...   Ok, I'll do this. You already import Tkinter so presumabnly you want to usethat as your GUI? What other kinds of modules do you want? You already have a display method in your object so youjust

Re: [Tutor] visualization

2006-07-29 Thread Alan Gauld
> class Object: Probably good to change the name, there is a built in class "object" and this could cause confusion... >def __init__ (self, x=10, y=10): >def __repr__ (self): >def display(self, canvas, x, y, width, height): >def rand_vec(self): > > > class Environment: >def __

[Tutor] visualization

2006-07-28 Thread Сергій
I have a world (environment), where live different objects. And all objects like to move.   This is the code: """ import random, time, Tkinter class Object:    def __init__ (self, x=10, y=10):    self.name = random.randint(0, 10)    self.x = x    self.y = y     def __repr__ (self):