+ def weight_dialog(button):
+ dialog = gtk.Dialog("Weight", self.dialog)
+ dialog.add_button("OK", gtk.RESPONSE_OK)
+
+ label = gtk.Label("Weight:")
+ entry = gtk.Entry()
+ entry.set_text(str(self.controller.get_weight()))
+
+ suffixLabel = gtk.Label(self.controller.get_str_weight_unit())
+
+ hbox = gtk.HBox()
+ hbox.add(label)
+ hbox.add(entry)
+ hbox.add(suffixLabel)
+
+ dialog.vbox.add(hbox)
+ dialog.show_all()
+ while 1:
+ response = dialog.run()
+ if response != gtk.RESPONSE_OK:
+ break
+ try:
+ value = int(entry.get_text())
+ if value <= 0:
+ raise ValueError
+ self.controller.set_weight(value)
+ self.client.set_int(WEIGHT, value)
+ weightButton.set_value(str(self.controller.get_weight()) + \
+ " " + self.controller.get_str_weight_unit() )
+ break
+ except:
+ hildon.hildon_banner_show_information(self, "None", "Invalid weight")
+ dialog.destroy()
+