Hildon framework provides a considerable amount of widgets. The following code has a function callback that is called every time the button generates a "clicked" event. We just change the body of button_callback function.
import gtk
import hildon
class HelloWorldApp(hildon.Program):
def __init__(self):
hildon.Program.__init__(self)
self.window = hildon.Window()
self.window.connect("delete_event", self.quit)
self.add_window(self.window)
button = gtk.Button("Widget")
self.window.add(button)
button.connect("clicked", self.button_callback, self.window)
button.show()
def quit(self, *args):
gtk.main_quit()
def button_callback(widget, button, window):
#PERFORM YOUR ACTION HERE
print "Callback function"
def run(self):
self.window.show_all()
gtk.main()
if __name__ == "__main__":
app = HelloWorldApp()
app.run()
A hildon.CalendarPopup is a dialog which contains a GtkCalendar. It also contains arrow buttons for changing month/year.
def button_callback(widget, button, window): dialog = hildon.CalendarPopup(window, 2008, 04, 29) dialog.run() date_tuple = dialog.get_date() dialog.destroy()
Provides the user with the possiblity to choose a different font and change its attributes, such as family, font size, font color, font weight, etc.
def button_callback(widget, button, window):
fontDialog = hildon.FontSelectionDialog(window, "Choose a font...")
fontDialog.set_preview_text ("Hildon Widgets")
fontDialog.run()
fontDialog.hide()
This dialog displays a text field to enter a password. The code shows a password dialog.
def button_callback(widget, button, window):
passwordDialog = hildon.GetPasswordDialog(window, True)
passwordDialog.set_property("password", "")
response = passwordDialog.run()
passwordDialog.hide()
if response == gtk.RESPONSE_OK:
print passwordDialog.get_password()
Bold text
No related wiki articles found