Features/GTK3/Porting: Difference between revisions
DanielDrake (talk | contribs) |
DanielDrake (talk | contribs) |
||
| Line 94: | Line 94: | ||
=== Constructor considerations === | === Constructor considerations === | ||
With PyGI it is possible to use Python-like constructors, or "new" functions e.g. the following are ( | With PyGI it is possible to use Python-like constructors, or "new" functions e.g. the following are (usually) equivalent: | ||
label = Gtk. | label = Gtk.Button() | ||
label = Gtk. | label = Gtk.Button.new() | ||
However, the first form is preferred: it is more Python-like. Internally, the difference is that Gtk.Label.new() translates to a call to gtk_label_new(), whereas Gtk.Label() (the preferred form) will directly construct an instance of GtkLabel at the GObject level. | However, the first form is preferred: it is more Python-like. Internally, the difference is that Gtk.Label.new() translates to a call to gtk_label_new(), whereas Gtk.Label() (the preferred form) will directly construct an instance of GtkLabel at the GObject level. | ||
| Line 110: | Line 110: | ||
expander = Gtk.Expander(label="my expander") | expander = Gtk.Expander(label="my expander") | ||
Combining the two points above, if you wish to call a construct-like function such as gtk_button_new_with_label(), you do have the option of calling Gtk.Button.new_with_label(), however if we check the [http://developer.gnome.org/gtk3/3.2/GtkButton.html#GtkButton.properties GtkButton Construct parameters] we see one called "label" which is equivalent. Therefore gtk_button_new_with_label("foo") should be called as: | |||
button = Gtk.Button(label="foo") | |||
==Make a release== | ==Make a release== | ||