Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python and different Operating Systems

I am about to start a personal project using python and I will be using it on both Linux(Fedora) and Windows(Vista), Although I might as well make it work on a mac while im at it. I have found an API for the GUI that will work on all 3. The reason I am asking is because I have always heard of small differences that are easily avoided if you know about them before starting. Does anyone have any tips or suggestions that fall along these lines?

like image 884
corymathews Avatar asked Mar 02 '23 02:03

corymathews


2 Answers

In general:

  • Be careful with paths. Use os.path wherever possible.
  • Don't assume that HOME points to the user's home/profile directory.
  • Avoid using things like unix-domain sockets, fifos, and other POSIX-specific stuff.

More specific stuff:

  • If you're using wxPython, note that there may be differences in things like which thread certain events are generated in. Don't assume that events are generated in a specific thread. If you're calling a method which triggers a GUI-event, don't assume that event-handlers have completed by the time your method returns. (And vice versa, of course.)
  • There are always differences in how a GUI will appear. Layouts are not always implemented in the exact same way.
like image 67
JesperE Avatar answered Mar 05 '23 15:03

JesperE


Some things I've noticed in my cross platform development in Python:

  • OSX doesn't have a tray, so application notifications usually happen right in the dock. So if you're building a background notification service you may need a small amount of platform-specific code.
  • os.startfile() apparently only works on Windows. Either that or Python 2.5.1 on Leopard doesn't support it.
  • os.normpath() is something you might want to consider using too, just to keep your paths and volumes using the correct slash notation and volume names.
  • icons are dealt with in fundamentally different ways in Windows and OSX, be sure you provide icons at all the right sizes for both (16x16, 24x24, 32x32, 48x48, 64x64, 128x128 and 256x256) and be sure to read up on setting up icons with wx widgets.
like image 30
Soviut Avatar answered Mar 05 '23 15:03

Soviut