[pygtk] Couple of easy questions

Lennon Cook lennon at riscque.net
Thu Dec 27 12:47:39 WST 2007


Micah Carrick <email at micahcarrick.com> wrote:
> 2. What's the difference between importing pygtk and just gtk? Is
> that a distribution difference? Just 'import gtk' works for me... but
> I need this code to be nice and universal.
Importing pygtk lets you check the version you're working with, using
pygtk.require to require at least a particular version. The usual
invocation looks like:
try:
	import pygtk
	pygtk.require(version_number)
except:
	# Required version not here, give some error

import gtk

You always need to import gtk  You could probably skip the internal
version checking if the usual way of running the program does it for
you, but the full invocation is safer if you don't know this for sure.
This is portable across distributions.


> 3. I was looking at some PyGTK projects and noticed some have
> everything all in one .py file. Is it common convention to put
> everything into a single file, put each class into it's own file, or
> does it vary from programmer to programmer?
Do what makes sense.


-- 
Lennon Victor Cook
"He who receives an idea from me receives without lessening, as he who
lights his candle at mine receives light without darkening" -- Thomas
Jefferson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20071227/ae3094f0/signature.pgp


More information about the pygtk mailing list