Gtk/python and portability
Question: How do programmers write portable UI code that works on multiple
distributions? I am considering desktop distributions and not
specialized/embedded distributions. For writing UI applications, you have to
assume certain things will be available on the platform either as standard or
by means of added dependencies. Is there a "minimum" UI/widget standard that
Linux distributions own?

How does Gnome vs KDE distributions come into picture when you are writing the
code?

I have a python script that uses Gtk and Webkit. Following are imports that my
script uses.

    
    
    import os
    import threading
    from gi.repository import WebKit 
    from gi.repository import Gtk 
    from gi.repository import GLib, GObject
    

What will be the best source to find out on which distributions my code will
work?


Answer: There is not much stuff you have to consider for writing a cross-distribution
UI.  
Actually the only incompatibility issue that I can remember is:

Tray Icon or Notification Area or App Indicator (so called in Ubuntu)  
For example standard tray icon (created by `gtk.StatusIcon` does not work in
Ubuntu's Unity by default  
You better use `appindicator.Indicator` if appindicator module was found,
otherwise just use classic `StatusIcon`

And if you care too much about the style/theme of your program, you may have
issues on other environments like KDE  
Unless you use suitable Theme Engines to act like a bridge, take a look at:  
<https://wiki.archlinux.org/index.php/Uniform_Look_for_Qt_and_GTK_Applications>

For finding out about the distribution / OS, I have written such a function:

    
    
    def getOsFullDesc():
        name = ''
        if os.path.isfile('/etc/lsb-release'):
            lines = open('/etc/lsb-release').read().split('\n')
            for line in lines:
                if line.startswith('DISTRIB_DESCRIPTION='):
                    name = line.split('=')[1]
                    if name[0]=='"' and name[-1]=='"':
                        return name[1:-1]
        if os.path.isfile('/suse/etc/SuSE-release'):
            return open('/suse/etc/SuSE-release').read().split('\n')[0]
        try:
            import platform
            return ' '.join(platform.dist()).strip().title()
            #return platform.platform().replace('-', ' ')
        except ImportError:
            pass
        if os.name=='posix':
            osType = os.getenv('OSTYPE')
            if osType!='':
                return osType
        ## sys.platform == 'linux2'
        return os.name
    

