Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

default arguments removed in gtk3?

Tags:

pygtk

pyside

gtk3

I try to port my pygtk code to gtk3. I get this error:

TypeError: pack_start() takes exactly 5 argument(s) (2 given)

It seams that the default arguments have been removed.

Does gtk3 (accessed from python) not support default arguments?

Since the app is not big, I ask myself if I should port to gtk3 or pyside ...

Removing the default arguments looks like a pointless "job creation programm" for programmers...

I could not find a good porting guide (pygtk to python-gtk3). Only this:

  • http://wiki.sugarlabs.org/go/Features/GTK3/Porting#HBox.2C_VBox.2C_pack_start_and_pack_end

Code like this is ugly:

box.pack_start(widget, True, True, 0)

I know how to search+replace .... but I don't want to.

like image 543
guettli Avatar asked Jun 11 '13 09:06

guettli


1 Answers

There are two options that I can suggest. One is you use the pygtkcompat compability module. This is probably not a good long term solution though.

The other option is to patch just the pack_start method in the same way the compatbility module does. Something like this:

orig_pack_start = Gtk.Box.pack_start
def pack_start(self, child, expand=True, fill=True, padding=0):
    orig_pack_start(self, child, expand, fill, padding)
Gtk.Box.pack_start = pack_start

This assumes you only want to patch one or two methods. More than that and it's probably better to stick with the compatibility module.

like image 135
James Holderness Avatar answered Sep 28 '22 18:09

James Holderness