Editing PyMaemo/UI tutorial/Additions to GTK+

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 1: Line 1:
-
{{main|Legacy Maemo 5 Documentation/Graphical UI Tutorial/Additions to GTK+}}
+
== Additions to GTK+ ==
-
A Hildon application might use any GTK+ widget but in some cases could be needed to adapt those widgets to get that they fit perfectly.
+
A Hildon application might use any Gtk widget but in some cases could be needed to adapt those widgets to get that they fit perfectly.
Hildon provides a set of convenience functions to do that. The next sections explains these additions.
Hildon provides a set of convenience functions to do that. The next sections explains these additions.
-
== Hildon Size Types ==
+
=== Hildon Size Types ===
Hildon defines the following sizes to be used as sizes for widgets such as buttons or entries in your Hildon application.
Hildon defines the following sizes to be used as sizes for widgets such as buttons or entries in your Hildon application.
-
Note: these constants are all defined in the <code>gtk</code> module.
+
Note: these constants are all defined in the gtk module.
-
{| class="wikitable"
+
{| class="wikitable"  
-
|+ Hildon constants
+
|-
|-
-
! Constant !! Description
+
! Const !! Description
|-
|-
-
| <code>HILDON_SIZE_HALFSCREEN_WIDTH</code> || set to 50% screen width
+
| HILDON_SIZE_HALFSCREEN_WIDTH || set to 50% screen width
|-
|-
-
| <code>HILDON_SIZE_FULLSCREEN_WIDTH</code> || set to 100% screen width
+
| HILDON_SIZE_FULLSCREEN_WIDTH || set to 100% screen width
|-
|-
-
| <code>HILDON_SIZE_AUTO_HEIGHT</code> || set to automatic height
+
| HILDON_SIZE_AUTO_HEIGHT || set to automatic height
|-
|-
-
| <code>HILDON_SIZE_FINGER_HEIGHT</code> || set to finger height
+
| HILDON_SIZE_FINGER_HEIGHT || set to finger height
|-
|-
-
| <code>HILDON_SIZE_THUMB_HEIGHT</code> || set to thumb height
+
| HILDON_SIZE_THUMB_HEIGHT || set to thumb height
|-
|-
-
| <code>HILDON_SIZE_AUTO</code> || set to automatic width and automatic height
+
| HILDON_SIZE_AUTO || set to automatic width and automatic height
|}
|}
Hildon widgets allows to set their sizes in their construction functions, but in case you want to set the size of a GTK+ widget, Hildon also provides functions to do that:
Hildon widgets allows to set their sizes in their construction functions, but in case you want to set the size of a GTK+ widget, Hildon also provides functions to do that:
-
<source lang="python">
+
 
     GtkButton(size)
     GtkButton(size)
     GtkToggleButton(size)
     GtkToggleButton(size)
     GtkRadioButton(type_size, group)
     GtkRadioButton(type_size, group)
     hildon_gtk_radio_button_new_from_widget(size, radio_group_member)
     hildon_gtk_radio_button_new_from_widget(size, radio_group_member)
-
</source>
 
-
== UI Modes ==
+
=== UI Modes ===
 +
 
Hildon defines two modes in the UI that change the way user interacts with certain widgets. The main purpose of these modes is to enable direct manipulation of items, while still allowing user to select single or multiple items, when it is necessary. The following modes are supported:
Hildon defines two modes in the UI that change the way user interacts with certain widgets. The main purpose of these modes is to enable direct manipulation of items, while still allowing user to select single or multiple items, when it is necessary. The following modes are supported:
-
'''Normal mode'''
+
Normal mode
:It is the default mode. In lists and grids, tapping on an item causes a direct action. In views, this direct action could open a new subview to perform a certain action with the item.
:It is the default mode. In lists and grids, tapping on an item causes a direct action. In views, this direct action could open a new subview to perform a certain action with the item.
-
'''Edit mode'''
+
Edit mode
:Edit mode is used in views. The purpose of this mode is providing multiple selection functionality in list or grid and providing standard UI for editing single content item.
:Edit mode is used in views. The purpose of this mode is providing multiple selection functionality in list or grid and providing standard UI for editing single content item.
Hildon provides the following functions to set mode for a treeview or icon view:
Hildon provides the following functions to set mode for a treeview or icon view:
-
<source lang="python">
+
 
     GtkTreeView(mode)
     GtkTreeView(mode)
     GtkTreeView(mode, model)
     GtkTreeView(mode, model)
Line 55: Line 54:
     GtkIconView(mode, model)
     GtkIconView(mode, model)
     hildon_gtk_icon_view_set_ui_mode(iconview, mode)
     hildon_gtk_icon_view_set_ui_mode(iconview, mode)
-
</source>
+
 
The enum HildonUIMode defines the following flags:
The enum HildonUIMode defines the following flags:
-
* <code>HILDON_UI_MODE_NORMAL</code>
+
* HILDON_UI_MODE_NORMAL
-
* <code>HILDON_UI_MODE_EDIT</code>
+
* HILDON_UI_MODE_EDIT
-
When you use a list or grid in edit mode inside a window you should use a <code>hildon.EditToolbar</code> to control the edition and set the window to fullscreen, building an Edit subview. To know more about edit views you can check [[../Toolbars|the toolbar chapter]]. In that chapter you can check an example of <code>HildonToolbar</code> which uses the concepts explained above.
+
When you use a list or grid in edit mode inside a window you should use a hildon.EditToolbar to control the edition and set the window to fullscreen, building an Edit subview. To know more about edit views you can check chapter toolbars. In that chapter you can check an example of HildonToolbar which uses the concepts explained above.
-
== Seek bars ==
+
=== Seek bars ===
 +
 
 +
The seek bars are useful to select a value from a range of predetermined values by adjusting the slider with a finger. These seek bars could be horizontal or vertical and are implemented using GtkVScale and GtkHScale. Thus, you can use this GTK+ widget in your Hildon application as seek bar but you should use following creation function instead of the GTK ones:
-
The seek bars are useful to select a value from a range of predetermined values by adjusting the slider with a finger. These seek bars could be horizontal or vertical and are implemented using <code>GtkVScale</code> and <code>GtkHScale</code>. Thus, you can use this GTK+ widget in your Hildon application as seek bar but you should use following creation function instead of the GTK+ ones:
 
-
<source lang="python">
 
     GtkHScale()
     GtkHScale()
     GtkVScale()
     GtkVScale()
-
</source>
+
 
Scales created by using these constructors has a hildonized behavior, meaning that when user tap or click in a point of the bar immediately jumps to the desired position.
Scales created by using these constructors has a hildonized behavior, meaning that when user tap or click in a point of the bar immediately jumps to the desired position.
Line 77: Line 76:
Hildon provides the following function to show a progress icon. This function applies to <code>hildon.Window</code> and <code>gtk.Dialog</code>.
Hildon provides the following function to show a progress icon. This function applies to <code>hildon.Window</code> and <code>gtk.Dialog</code>.
-
<source lang="python">
+
 
-
def hildon_gtk_window_set_progress_indicator(window, state)
+
    def hildon_gtk_window_set_progress_indicator(window, state)
-
</source>
+
 
The argument state should be 1 to show the indicator and 0 to hide it.
The argument state should be 1 to show the indicator and 0 to hide it.
-
Here, a little example that sets a progress indicator in a <code>GtkDialog</code>. Click outside the dialog to close the example.
+
Here, a little example that sets a progress indicator in a GtkDialog. Click outside the dialog to close the example.
-
<source lang="python">
+
-
# Based on C code from:
+
-
# "Hildon Tutorial" version 2009-04-28
+
-
# Example 8.1, "Adding a progress indicator to a dialog"
+
-
import gtk
+
    # Based on C code from:
-
import hildon
+
    # "Hildon Tutorial" version 2009-04-28
 +
    # Example 8.1, "Adding a progress indicator to a dialog"
 +
   
 +
    import gtk
 +
    import hildon
 +
   
 +
    def main():
 +
        dialog = gtk.Dialog()
 +
        dialog.set_title("Performing a long task")
 +
        dialog.show_all()
 +
        hildon.hildon_gtk_window_set_progress_indicator(dialog, 1)
 +
        dialog.run()
 +
   
 +
    if __name__ == "__main__":
 +
        main()
-
def main():
 
-
    dialog = gtk.Dialog()
 
-
    dialog.set_title("Performing a long task")
 
-
    dialog.show_all()
 
-
    hildon.hildon_gtk_window_set_progress_indicator(dialog, 1)
 
-
    dialog.run()
 
-
if __name__ == "__main__":
 
-
    main()
 
-
</source>
 
Additionally, if you consider that aditional text information should be give to the user you could use an informational banner.
Additionally, if you consider that aditional text information should be give to the user you could use an informational banner.
Another convenience way to indicate to users that a long operation is being performed is using the <code>gtk.ProgressBar</code> widget. This is the usual way in GTK+ applications and you can use them like you would use them in a GTK+ application. This widget is specially useful if you need to show the status of the operation.
Another convenience way to indicate to users that a long operation is being performed is using the <code>gtk.ProgressBar</code> widget. This is the usual way in GTK+ applications and you can use them like you would use them in a GTK+ application. This widget is specially useful if you need to show the status of the operation.
-
 
-
[[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: