views:

761

answers:

3

The tutorials I've found on WxPython all use examples from Linux, but there seem to be differences in some details.

For example, in Windows a Panel behind the widgets is mandatory to show the background properly. Additionally, some examples that look fine in the tutorials don't work in my computer.

So, do you know what important differences are there, or maybe a good tutorial that is focused on Windows?

EDIT: I just remembered this: Does anybody know why when subclassing wx.App an OnInit() method is required, rather than the more logical __init__()?

A: 

EDIT: I just remembered this: Does anybody know why when subclassing wx.App an OnInit() method is required, rather than the more logical __init__()?

I use OnInit() for symmetry: there's also an OnExit() method.

Edit: I may be wrong, but I don't think using OnInit() is required.

Bastien Léonard
The docs suggest it _is_ required...
Jon Cage
+2  A: 
Jon Cage
I understand that, but since every object oriented language has constructors, why require an OnInit()?
Javier Badia
BTW, that tutorial is very short.
Javier Badia
That's one of the tutorials I was talking about, but thanks anyway. It's still useful.
Javier Badia
Which bit(s) don't work under windows?
Jon Cage
A: 

I find a number of small differences, but don't remember all of them. Here are two:

1) The layout can be slightly different, for example, causing things to not completely fit in the window in one OS when the do in the other. I haven't investigated the reasons for this, but it happens most often when I use positions rather than sizers to arrange things.

2) I have to explicitly call Refresh more in Windows. For example, if you place one panel over another, you won't see it the top panel in Windows until you call Refresh.

I general, I write apps in Linux and run them in Windows, and things work similarly enough so this is a reasonable approach, but it's rare for me when something runs perfectly straight out of the gate after an OS switch.

tom10
The documentation explicitly says that a Frame will only contain one widget so to add more you need to add a Panel.As for layout, it seems that most "recent" windowing API's recommend that you use sizers to quasi-auto-layout your forms. Once you get used to the idea, it's actually very convenient. Means less work to support the wide range of screen sizes that users are likely to have. No matter what size you optimise for, most users will use different font sizes and size their windows differently so your careful work ends up being wasted.
CyberED