hildon.SortDialog

A sort dialog

A widget for defining sorting order of items.

Description

Sort Dialog is used to define the order in which items are shown in a list.

Ancestry

Up to the first non-hildon ancestor:

...
 +-- gtk.Dialog
      +-- hildon.SortDialog

Usage Example

import gtk
import hildon

def sort(widget, label, window):
    dialog = hildon.SortDialog(window)
    
    sort_keys = ("ham", "spam", "eggs")
    dialog.add_sort_key(sort_keys[0])
    dialog.add_sort_key(sort_keys[1])
    dialog.add_sort_key(sort_keys[2])
    
    response = dialog.run()
    dialog.hide()
    
    if response == gtk.RESPONSE_OK:
    
        if (dialog.get_sort_order() == gtk.SORT_ASCENDING):
            sort_order = "ascending"
        else:
            sort_order = "descending"
    
        label.set_text("Sort by %s, %s" % (sort_keys[dialog.get_sort_key()], sort_order))
    else:
        label.set_text("Canceled")
        
    dialog.destroy()

window = hildon.Window()
window.set_title("Test App")

label = gtk.Label("No sorting yet.")

button = gtk.Button("Click to sort")
button.connect("clicked", sort, label, window)

vbox = gtk.VBox(False, 10)
vbox.pack_start (button)
vbox.pack_start (label)
window.add(vbox)

window.show_all()

gtk.main()
      

Properties

Name Access Description
"sort-key" Read/Write The currently active sort key.
"sort-order" Read/Write The current sorting order.

Constructor

Creates a new hildon.SortDialog.

hildon.SortDialog(parent)
parent Its parent window.
Returns A new hildon.SortDialog.

Methods

get_sort_key

Gets index to currently active sort key.

hildon.SortDialog.get_sort_key()
Returns An integer which is the index value of the "Sort by" field.

set_sort_key

Sets index to currently active sort key.

hildon.SortDialog.set_sort_key(key)
key An integer which is the index value of the "Sort by" field.

get_sort_order

Gets current sorting order from "Sort order" field.

hildon.SortDialog.get_sort_order()
Returns Current sorting order as a GTK Sort Type constant. That is, either gtk.SORT_ASCENDING or gtk.SORT_DESCENDING.

set_sort_order

Sets current sorting order for "Sort order" field.

hildon.SortDialog.set_sort_order(order)
order Current sorting order as a GTK Sort Type constant. That is, either gtk.SORT_ASCENDING or gtk.SORT_DESCENDING.

add_sort_key

Adds a new sort key and returns its respective index in sort key combobox.

hildon.SortDialog.add_sort_key(sort_key)
sort_key A new combo box's key value.
Returns An integer which is the index of the added combo box's item.


Improve this page