PyGTK-2 Full-Screen mode.
David M. Cook
davecook at nowhere.net
Tue Mar 4 03:33:02 EST 2003
In article <14bd1399.0303031047.6032597b at posting.google.com>, kkennedy wrote:
> Question: How in the world did you interpret those two method calls
> from the documentation? In the documentation the method names are
> different and they both require that the GtkWindow be passed as the
> first argument. However, what you have written in Python are
> different method names and the exclusion of the GtkWindow argument.
> How did you come up with this?
Better docs specifically for the Python API are being worked on.
Until then here are some rules for translating from C to Python:
Namespaces:
o gtk_ -> gtk.
o gnome_ -> gnome. or gnome.ui. (depending on header file)
o g_ -> gobject.
o gdk_ -> gtk.gdk.
Class names are in "StudlyCaps" (same as the C typenames without the "Gtk"
part):
o gtk_class_name_new() -> gtk.ClassName() e.g. gtk.TreeView()
o gtk_class_name_new_with_foo(myfoo) -> gtk.ClassName(myfoo)
e.g. gtk.TreeView(model)
Method names are generally the same as C method names.
gtk_class_name_method_name(instance, params)
-> instance.method_name(params)
e.g. gtk_tree_view_get_column(treeview, 4) -> treeview.get_column(4)
In general, in/out parameters become return values. Usually in cases where a
"failure" would be returned, None is returned.
gtk_class_name_method_name(instance, a, b, &c, &d)
-> c, d = instance.method_name(a, b)
e.g.
gtk_tree_view_get_path_at_pos(treeview, x, y, &path, &column, &cell_x,
&cell_y)
-> path, column, cell_x, cell_y = treeview.get_path_at_pos(x, y)
Constants, e.g.:
GTK_WINDOW_TOPLEVEL -> gtk.WINDOW_TOPLEVEL
GDK_KEY_PRESS -> gtk.gdk.KEY_PRESS
FALSE, TRUE -> gtk.FALSE, gtk.TRUE
Others:
o instance.connect() instead of signal_connect()
o paths in TreeView/Models are just tuples.
o string lengths do not need to be specified
o The TreeViewColumn constructor can take named parameters for the
CellRenderer properties:
cell = gtk.CellRendererText()
column = gtk.TreeViewColumn(colname, cell, text=i, editable=j)
Dave Cook
More information about the Python-list
mailing list