Categories: Maemo | Python | Widgets
This page was last modified 07:59, 3 May 2008.
Python Hildon Widgets - Part 1
From Forum Nokia Wiki
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()
hildon.CalendarPopup
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()
hildon.FontSelectionDialog
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()
hildon.GetPasswordDialog
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()
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 3510 Bug | ssacl05 | General Browsing | 0 | 2003-03-26 17:31 |
| Make a directory | mikebukhin | Python | 3 | 2007-03-29 13:32 |
| Problems with a python wrapper: convert PyObject to Image | pdcb_pdcb | Python | 1 | 2008-03-11 05:32 |
| Problems with a python wrapper: convert PyObject to Image | pdcb_pdcb | Python | 6 | 2008-03-21 22:57 |
| Launching a Python script (with arguments) from Flash? | bouvin | Python | 14 | 2006-08-22 18:33 |



