[Tutor] is it legal to have a class within a def

Alan Gauld alan.gauld at btinternet.com
Thu Jan 3 09:22:25 CET 2008

"johnf" <jfabiani at yolo.com> wrote

> 1 and 3 are my reasons.  I'm creating a Dabo app.  When I attempted 
> to create
> a special class that contained a dialog box I discovered that the 
> dialog
> class created an indepentant type of window and allowed my program 
> to
> continue running without waiting for the dialog to return a value 
> first.

Are you sure you made it a modal dialog?
Any dialog will do that if it is opened modelessly, you need to
use the modal version to make it block the app.

Putting the class code in a functiion is legal but very inefficient
and also prevents you from storing state etc in the dialog - you
would need to reinitialise all valuues on each use. Thats OK if
its simple but a lot of work(and slow)  if its complex.


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list