Editing PyMaemo/UI tutorial/Utilities

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 5: Line 5:
== The Program object ==
== The Program object ==
-
Hildon provides an object to represent a whole application, the <code>hildon.Program</code> object. This object provides several convenience functions that make it easier to develop Hildon applications.
+
Hildon provides an object to represent a whole application, the hildon.Program object. This object provides several convenience functions that make it easier to develop Hildon applications.
-
The <code>hildon.Program</code> provides the programmer with commodities such as applying a common menu or toolbar to every <code>hildon.Window</code> registered to it.
+
The hildon.Program provides the programmer with commodities such as applying a common menu or toolbar to every hildon.Window registered to it.
It is necessary to register all the windows as belonging to the program in order to apply a common menu and toolbar.
It is necessary to register all the windows as belonging to the program in order to apply a common menu and toolbar.
To register or unregister windows you should use the following functions:
To register or unregister windows you should use the following functions:
-
<source lang="python">
+
 
-
def add_window(self, window)
+
    def add_window(self, window)
-
def remove_window(self, window)
+
    def remove_window(self, window)
-
</source>
+
 
And the following functions will take effect over each registered window. This is a convenient way to setup common elements for each registered window in your application.
And the following functions will take effect over each registered window. This is a convenient way to setup common elements for each registered window in your application.
-
<source lang="python">
+
 
-
def set_common_menu(self, menu)
+
    def set_common_menu(self, menu)
-
def get_common_menu(self)
+
    def get_common_menu(self)
-
def set_common_toolbar(self, toolbar)
+
    def set_common_toolbar(self, toolbar)
-
def get_common_toolbar(self)
+
    def get_common_toolbar(self)
-
</source>
+
 
-
<code>hildon.Program</code> also allows users to apply program-wide properties. For example, the property “can-hibernate” that specify whether the program should be set to hibernate by the Task Navigator in a low memory situation or not.
+
hildon.Program also allows users to apply program-wide properties. For example, the property “can-hibernate” that specify whether the program should be set to hibernate by the Task Navigator in a low memory situation or not.
The following convenience functions are provided to set and retrieve the value of the property “can-hibernate”.
The following convenience functions are provided to set and retrieve the value of the property “can-hibernate”.
-
<source lang="python">
+
 
-
def set_can_hibernate(self, can_hibernate)
+
    def set_can_hibernat(self, can_hibernate)
-
def get_can_hibernate(self)
+
    def get_can_hibernate(self)
-
</source>
+
 
== Sound utilities ==
== Sound utilities ==
-
Hildon provides the following function to play a sample. The function receives the sample file name as parameter and the volume level is controlled by the gconf variable <code>/apps/osso/sound/system_alert_volume</code>.
+
Hildon provides the following function to play a sample. The function receives the sample file name as parameter and the volume level is controlled by the gconf variable <code>/apps/osso/sound/system_alert_volume.</code>
-
<source lang="python">
+
 
-
def hildon_play_system_sound (sample)
+
    def hildon_play_system_sound (sample)
-
</source>
+
 
== Miscellaneous Helper Functions ==
== Miscellaneous Helper Functions ==
=== Text Font and Colors ===
=== Text Font and Colors ===
-
The following functions allows you to set a font or color for the text diplayed by a certain widget. The size or color is identified by a logical name which should be defined by the GTK+’s rc files defined as part of the themes definition.
+
The following funtions allows you to set a font or color for the text diplayed by a certain widget. The size or color is identified by a logical name which should be defined by the GTK’s rc files defined as part of the themes definition.
Since logical names are used to identify the colors and font, they are independent from the theme, meaning that if the theme is changed the widget keeps the same logical font or color set by these functions.
Since logical names are used to identify the colors and font, they are independent from the theme, meaning that if the theme is changed the widget keeps the same logical font or color set by these functions.
-
<source lang="python">
+
 
-
def hildon_helper_set_logical_font(widget, logicalfontname)
+
    def hildon_helper_set_logical_font(widget, logicalfontname)
-
def hildon_helper_set_logical_color(widget, rcflags, state, logicalcolorname)
+
    def hildon_helper_set_logical_color(widget, rcflags, state, logicalcolorname)
-
</source>
+
 
These functions achieve to keep the set logical font or color by connecting to “style-set” signal. The returned signal identifier can be used to disconnect the signal.
These functions achieve to keep the set logical font or color by connecting to “style-set” signal. The returned signal identifier can be used to disconnect the signal.
-
To set a logical color is necessary to pass in the <code>gtk.RcFlags</code> and <code>gtk.StateType</code> to indicate which color you want to modify. For example, to modify the foreground color of the widget during normal operations then set rcflags to <code>gtk.RC_BG</code> and state <code>to gtk.STATE_NORMAL</code>.
+
To set a logical color is necessary to pass in the gtk.RcFlags and gtk.StateType to indicate which color you want to modify. For example, to modify the foreground color of the widget during normal operations then set rcflags to <code>gtk.RC_BG</code> and state <code>to gtk.STATE_NORMAL.</code>
=== Finger events ===
=== Finger events ===
The following function can be in callbacks that handle button events to check if the given button event is a finger event, meaning that the event was emitted as a result of a push with the finger somewhere on the touchscreen.
The following function can be in callbacks that handle button events to check if the given button event is a finger event, meaning that the event was emitted as a result of a push with the finger somewhere on the touchscreen.
-
<source lang="python">
+
 
-
def hildon_helper_event_button_is_finger(event)
+
    def hildon_helper_event_button_is_finger(event)
-
</source>
+
 
This function is rarely used in applications development.
This function is rarely used in applications development.
Line 62: Line 62:
The function showed bellow enables a thumb scrollbar on a given scrolled window, converting the existing normal scrollbar into a larger, finger-usable scrollbar that works without a stylus.
The function showed bellow enables a thumb scrollbar on a given scrolled window, converting the existing normal scrollbar into a larger, finger-usable scrollbar that works without a stylus.
-
<source lang="python">
+
 
-
def hildon_helper_set_thumb_scrollbar(win, thumb)
+
    def hildon_helper_set_thumb_scrollbar(win, thumb)
-
</source>
+
[[Category:Python]]
[[Category:Python]]

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)

Templates used on this page: