import gtk

from kiwi.controllers import BaseController
from kiwi.ui.views import BaseView
from kiwi.ui.gadgets import quit_if_last

class FarenControl(BaseController):

    def on_quitbutton__clicked(self, *args):
        self.view.hide_and_quit()

    def after_temperature__changed(self, entry, *args):
        try:
            temp = float(entry.get_text())
        except ValueError:
            temp = 0
        celsius = (temp - 32) * 5/9.0
        farenheit = (temp * 9/5.0) + 32
        self.view.celsius.set_text("%.2f" % celsius)
        self.view.farenheit.set_text("%.2f" % farenheit)

widgets = ["quitbutton", "temperature", "celsius", "farenheit"]
view = BaseView(gladefile="faren", delete_handler=quit_if_last,
                widgets=widgets)
ctl = FarenControl(view)
view.show()
gtk.main()

import gtk

from kiwi.controllers import BaseController
from kiwi.ui.views import BaseView
from kiwi.ui.gadgets import quit_if_last

class FarenControl(BaseController):

    def on_quitbutton__clicked(self, *args):
        self.view.hide_and_quit()

    def after_temperature__insert_text(self, entry, *args):
        try:
            temp = float(entry.get_text())
        except ValueError:
            temp = 0
        celsius = (temp - 32) * 5/9.0
        farenheit = (temp * 9/5.0) + 32
        self.view.celsius.set_text("%.2f" % celsius)
        self.view.farenheit.set_text("%.2f" % farenheit)

widgets = ["quitbutton", "temperature", "celsius", "farenheit"]
view = BaseView(gladefile="faren", delete_handler=quit_if_last,
                widgets=widgets)
ctl = FarenControl(view)
view.show()
gtk.main()

Use insert_text instead of changed
Use insert_text instead of changed


  import gtk
  
  from kiwi.controllers import BaseController
  from kiwi.ui.views import BaseView
  from kiwi.ui.gadgets import quit_if_last
  
  class FarenControl(BaseController):
  
      def on_quitbutton__clicked(self, *args):
          self.view.hide_and_quit()
  
-     def after_temperature__changed(self, entry, *args):
+     def after_temperature__insert_text(self, entry, *args):
          try:
              temp = float(entry.get_text())
          except ValueError:
              temp = 0
          celsius = (temp - 32) * 5/9.0
          farenheit = (temp * 9/5.0) + 32
          self.view.celsius.set_text("%.2f" % celsius)
          self.view.farenheit.set_text("%.2f" % farenheit)
  
  widgets = ["quitbutton", "temperature", "celsius", "farenheit"]
  view = BaseView(gladefile="faren", delete_handler=quit_if_last,
                  widgets=widgets)
  ctl = FarenControl(view)
  view.show()
  gtk.main()
  
Use insert_text instead of changed
## Code Before:
import gtk

from kiwi.controllers import BaseController
from kiwi.ui.views import BaseView
from kiwi.ui.gadgets import quit_if_last

class FarenControl(BaseController):

    def on_quitbutton__clicked(self, *args):
        self.view.hide_and_quit()

    def after_temperature__changed(self, entry, *args):
        try:
            temp = float(entry.get_text())
        except ValueError:
            temp = 0
        celsius = (temp - 32) * 5/9.0
        farenheit = (temp * 9/5.0) + 32
        self.view.celsius.set_text("%.2f" % celsius)
        self.view.farenheit.set_text("%.2f" % farenheit)

widgets = ["quitbutton", "temperature", "celsius", "farenheit"]
view = BaseView(gladefile="faren", delete_handler=quit_if_last,
                widgets=widgets)
ctl = FarenControl(view)
view.show()
gtk.main()

## Instruction:
Use insert_text instead of changed
## Code After:
import gtk

from kiwi.controllers import BaseController
from kiwi.ui.views import BaseView
from kiwi.ui.gadgets import quit_if_last

class FarenControl(BaseController):

    def on_quitbutton__clicked(self, *args):
        self.view.hide_and_quit()

    def after_temperature__insert_text(self, entry, *args):
        try:
            temp = float(entry.get_text())
        except ValueError:
            temp = 0
        celsius = (temp - 32) * 5/9.0
        farenheit = (temp * 9/5.0) + 32
        self.view.celsius.set_text("%.2f" % celsius)
        self.view.farenheit.set_text("%.2f" % farenheit)

widgets = ["quitbutton", "temperature", "celsius", "farenheit"]
view = BaseView(gladefile="faren", delete_handler=quit_if_last,
                widgets=widgets)
ctl = FarenControl(view)
view.show()
gtk.main()
