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.add(vbox)
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):
ftemp=self.entry.get_text()
return (ftemp-32) * 5 / 9
win = DemoWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
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?