Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Python Hildon Widgets - Part 1

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.


Article Metadata
Article
Created: User:Raulherbster (02 May 2008)
Last edited: lpvalente (20 Apr 2013)

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.

A hildon.CalendarPopup

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.

A hildon.FontSelectionDialog

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.

A hildon.GetPasswordDialog

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

This page was last modified on 20 April 2013, at 22:44.
179 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×