Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to change a child of a box's padding; so I am using set_child_packing on the box holding the child. I can't figure out what to use as the constant for for the pack_type. Using PACK_START from gtk2 won't work as using: import gtk causes an error.

What do I use for the pack_type constant? I am using python with GTK3 on Ubuntu 12.04. Thanks, Vance

share|improve this question
    
something like this has been asked a dozen times or so. constants got moved to logical classes within the Gtk module. do a dir(Gtk) from a terminal and examine the results –  hbdgaf Jul 2 '12 at 5:16

1 Answer 1

up vote 1 down vote accepted

It's Gtk.PackType.START.

As @aking1012 is mentioning on his comment, these constants got moved around in Gtk 3.

Unfortunately, there is no good documentation on the Gtk 3 Python bindings, so you'll often have to find these out manually until there is.

A way to do it is to open a terminal and use the interactive Python interpreter get a listing of all methods and subclasses of Gtk, and then try to guess which one resembles best the constants in the C documentation, as such:

$ python
Python 2.7.3 (default, Apr 20 2012, 22:39:59) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi.repository import Gtk
>>> dir(Gtk)

You can also install ipython and do the same as above, but with tab completion instead of using the dir() command above:

$ ipython
Python 2.7.3 (default, Apr 20 2012, 22:39:59) 
Type "copyright", "credits" or "license" for more information.

IPython 0.12.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from gi.repository import Gtk

In [2]: Gtk.(and press TAB here)
share|improve this answer
    
Thanks David. I was using IDLE with the dir, but I'll get ipython. The tabbing will be helpful. –  user72943 Jul 8 '12 at 12:03
    
Cool, glad it helped, remember to accept the answer if it was useful. –  David Planella Jul 8 '12 at 15:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.