"aug dawg" <augdaw...@gmail.com> wrote

How would I go about creating custom GUI elements? For example, if I wanted to make a simple LEGO maker app, how would I write the code for the bricks
so that the user could drag them around and then build LEGO models?

You find the nearest widget to what you want then you create a new subclass of that widget. Then you override all the methods that act differently. Then you
add any new methods that are unique to your widget.

If there is nothing really like it you may need to go up to the abstract
widgets like Window and use composition to build a new widget built
from the standard ones. Thats even harder because thre is less you
get to reuse for free.

If its a 3D widget you may want to start with Pygame rather than a
standard GUI tooklit...

Warning, it's a non trivial exercise thats a pain to get exactly right unless its a very minor tweak to an existing widget. But there is no real alternative. The good news is that once you get it right the final app that uses it will be
a snap by comparison!

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to