The code calls the setResultAs(..)
and use the return value of the function as the callback (handler).
Use following form (gobject.GObject.connect
):
object.connnect("signla_name", handler, arg1, arg2, ...)
For example, replace following line
plusBtn.connect("clicked", setResultAs("plus"))
with:
plusBtn.connect("clicked", setResultAs, "plus")
UPDATE
In addition to the above, the callback function setResultAs
should receive widget (the widget that emit the signal) as the first parameter.
Replace following line:
def setResultAs(operation):
with:
def setResultAs(widget, operation):
And there's a typo:
divideBtn = gtk.Button("Divide by")
btnbox.pack_start(plusBtn) # <-------- `plusBtn` should be `divideBtn`
divideBtn.connect("clicked", setResultAs("divide"))