6

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:

Code like this is ugly:

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

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

guettli
  • 25,042
  • 81
  • 346
  • 663

1 Answers1

7

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.

James Holderness
  • 22,721
  • 2
  • 40
  • 52