Search code examples
pythonwxpython

wxpython gui not showing properly


I wrote a program in python, and I used an absolute positioning, all my sizes and positions are specified in pixels. When I run it on my PC it works fine, but when I run it on another PC it is not showing properly, components are overlapping each other, and their positions aren't the way they should be. Here is an example of ok gui: http://postimg.org/image/e4od9f52f/ And here is bad gui: http://postimg.org/image/jy30nq63r/

This is just one example, every dialog has problems like this.

Anyone knows what is a problem?

Thx in advance, Aleksa


Solution

  • The problem is that you are using absolute positioning. Different OSes use different default sizes for things, such as fonts. Thus the default font size on Windows may be larger or smaller than the default font size on Linux. This is one of the many reasons why using absolute positioning cross-platform can kind of suck. You'll also see this sort of thing on Windows if you change themes or resolution or in Windows 7 when you adjust the size of text overall.

    This is why using sizers is so helpful. Sizers know what size the font is and what size the widgets should be and they do their best to prevent this sort of thing from happening. Here are a few articles to get you started: