[Tutor] wxPython newbie

Magnus Lycka magnus@thinkware.se
Thu Jan 9 18:39:02 2003


At 15:12 2003-01-09 +0000, alan.gauld@bt.com wrote:
>Sure but a good way to find out whats happening
>in Python code is via python... Its one of its strongest
>features that almost anything can be printed.

But a problem with using an approach that you have
figured out through experiments is that you can't be
sure if it works by design or by accident... Will it
continue to work in the next version of Python? Might
it have unexpected side effects?

I agree in general (of course) that experimentaion is
useful, educational, and very convenient in Python. On
the other hand, it's very good if we know not only how
to do something, but also why etc. I guess It takes some
experience to figure out when experiments are enough,
and when we must consult the "scriptures"...

> > Because it will just be a stupid digit that doesn't
> > mean anything to whoever reads the code.
>
>Well, it might be, but then again it could be a string
>"Yes" or "No" which is, ISTR, how TKinter dialogs respond...

wxPython is just a wrapper for the C++ toolkit wxWindows,
and it it uses integers for all such things, as C and C++
programs typically do.

> > >See what gets printed and substitute in your program...
> > Better to use wxID_YES, wxID_NO, wxID_OK or wxID_CANCEL.
>
>Absolutely. If there are defined constats then use the
>definitions - or at least define your own if they don't
>already exist. But when you don't even know what type of
>response youll get, print is the best solution.

Unless there is documentation... ;)

For wxPython, the demo code is really useful. The answer to
this question is clear from looking at the wxDialog Demo Code
for instance. For more obscure parts, one might need to download
the C++ version wxWindows and look at the C++ demos as well.

The docs are unfortunately not always entirely up do date, and
they are C++ docs with a few Python (and recently Perl) notes
in them.

As with Linux, odd second numbers in the version are development
versions, but since 2.2 wasn't very good, everybody uses 2.3.x
now, which is tracking a wxWindows development version with
rapidly changing APIs etc. Hopefuly, this will get better as
we approach 2.4 soon.



-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se