I am trying to build a simple app that calculates the farenhit to celsius converter. Here is my code..

from gi.repository import Gtk, GObject

class DemoWindow(Gtk.Window):

  def __init__(self):
    Gtk.Window.__init__(self, title="Demo Example")
    self.set_size_request(300, 400)
    vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
    self.entry = Gtk.Entry()
    self.entry.set_text("Enter Farenhit")

    self.button1 = Gtk.Button(label="Calculate")
    self.button1.connect("clicked", self.on_button1_clicked)
    vbox.pack_start(self.entry, True, True, 0)
    vbox.pack_start(self.button1, True, True, 0)

  def on_button1_clicked(self, widget):
        return (ftemp-32) * 5 / 9

win = DemoWindow()
win.connect("delete-event", Gtk.main_quit)

Now the problem is i am getting the following error.

TypeError: unsupported operand type(s) for -: 'str' and 'int'

So How to resolve this error? All I am trying to return here is value taken from the entry box.

Any pointers?

ftemp is a string, you will need to convert it into an integer in order to calculate (ftemp - 32)*5 / 9
why not try ftemp = int(self.entry.get_text()) in your current code :).

return (float(ftemp)-32) * 5 / 9
would also help you with the integer division problem with Python2

Code does compile but the output is not visible on the console :( . I wonder what could be wrong with the return statement?