ui Package

ui Package

User interface: Framework and Widget support

builderloader Module

class kiwi.ui.builderloader.BuilderWidgetTree(view, gladefile, domain=None)[source]
get_sizegroups()[source]
get_widget(name)[source]

Retrieves the named widget from the View (or glade tree)

get_widgets()[source]
signal_autoconnect(obj)[source]

cellrenderer Module

class kiwi.ui.cellrenderer.ComboDetailsCellRenderer[source]

Bases: gtk.GenericCellRenderer

A Cell Renderer for ComboEntry inspired by firefox’s awesome bar

To show some details on each entry of the popup, you should call the method ComboEntry.set_details_callback with a callable that expects an object.

This will be the object that the entry represents if the ComboEntry mode is DATA and will be None if the mode is STRING (in which case, details don’t make sense).

data

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

do_get_property(pspec)
do_set_property(pspec, value)
label

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

on_get_size(widget, cell_area)[source]
on_render(window, widget, background_area, cell_area, expose_area, flags)[source]
set_details_callback(callable)[source]

comboboxentry Module

Reimplementation of GtkComboBoxEntry in Python.

The main difference between the BaseComboBoxEntry and GtkComboBoxEntry is that a {kiwi.ui.widgets.entry.Entry} is used instead of a GtkEntry.

class kiwi.ui.comboboxentry.BaseComboBoxEntry(model=None, text_column=-1)[source]

Bases: gtk.ComboBox

do_grab_focus()[source]
do_mnemnoic_activate(group_cycling)[source]
get_background()[source]
get_text_column()[source]
set_pixbuf(pixbuf)[source]
set_text_column(text_column)[source]
update_background(color)[source]
kiwi.ui.comboboxentry.test()[source]

comboentry Module

Widget for displaying a list of objects

class kiwi.ui.comboentry.ComboEntry(entry=None)[source]

Bases: gtk.VBox

append_item(label, data=None)[source]

See kiwi.interfaces.IEasyCombo.append_item

clear()[source]

Removes all items from list

clicked()[source]
do_grab_focus()[source]
get_active_iter()[source]

Gets the selected iter. :returns: iter selected. :rtype: gtk.TreeIter

get_background()[source]
get_mode()[source]
get_model()[source]

Gets our model. :returns: model :rtype: gtk.TreeModel

get_model_items()[source]

See kiwi.interfaces.IEasyCombo.get_model_items

get_model_strings()[source]

See kiwi.interfaces.IEasyCombo.get_model_strings

get_selected()[source]

See kiwi.interfaces.IEasyCombo.get_selected

get_selected_data()[source]

See kiwi.interfaces.IEasyCombo.get_selected_data

get_selected_label()[source]

See kiwi.interfaces.IEasyCombo.get_selected_label

get_text()[source]

Gets the current text. :returns: the text.

popdown()[source]

Hide the popup window

popup()[source]

Show the popup window

prefill(itemdata, sort=False)[source]

See kiwi.interfaces.IEasyCombo.prefill

select(obj)[source]

See kiwi.interfaces.IEasyCombo.select

select_item_by_data(data)[source]

See kiwi.interfaces.IEasyCombo.select_item_by_data

select_item_by_label(text)[source]

See kiwi.interfaces.IEasyCombo.select_item_by_label

select_item_by_position(position)[source]

See kiwi.interfaces.IEasyCombo.select_item_by_position

set_active(rowno)[source]
set_active_iter(iter)[source]

Set the iter selected. :param iter: iter to select :type iter: gtk.TreeIter

set_details_callback(callable)[source]

Display some details as a second line on each entry

Parameters:callable – a callable that expects an object and returns a string
set_label_text(text)[source]
set_model(model)[source]

Set the tree model to model :param model: new model :type model: gtk.TreeModel

set_pixbuf(pixbuf)[source]
set_text(text)[source]

Sets the text. :param text:

update_background(color)[source]

dateentry Module

class kiwi.ui.dateentry.DateEntry[source]

Bases: gtk.HBox

I am an entry which you can input a date on. In addition to an gtk.Entry I also contain a button with an arrow you can click to get popup window with a gtk.Calendar for which you can use to select the date

do_grab_focus()[source]
get_date()[source]

Get the selected date :returns: the date. :rtype: datetime.date or None

set_date(date)[source]

Sets the date. :param date: date to set :type date: a datetime.date instance or None

delegates Module

Defines the Delegate classes that are included in the Kiwi Framework.

class kiwi.ui.delegates.Delegate(toplevel=None, widgets=(), gladefile=None, toplevel_name=None, delete_handler=None, keyactions=None)[source]

Bases: kiwi.ui.views.BaseView, kiwi.controllers.BaseController

A class that combines view and controller functionality into a single package. The Delegate class possesses a top-level window.

class kiwi.ui.delegates.GladeDelegate(gladefile=None, toplevel_name=None, domain=None, delete_handler=None, keyactions=None)[source]

Bases: kiwi.ui.views.BaseView, kiwi.controllers.BaseController

A class that combines view and controller functionality into a single package. The Delegate class possesses a top-level window.

class kiwi.ui.delegates.GladeSlaveDelegate(gladefile=None, toplevel_name=None, domain=None, keyactions=None)[source]

Bases: kiwi.ui.views.SlaveView, kiwi.controllers.BaseController

A class that combines view and controller functionality into a single package. It does not possess a top-level window, but is instead intended to be plugged in to a View or Delegate using attach_slave().

class kiwi.ui.delegates.ProxyDelegate(model, proxy_widgets=None, gladefile=None, toplevel=None, widgets=(), toplevel_name=None, domain=None, delete_handler=None, keyactions=None)[source]

Bases: kiwi.ui.delegates.Delegate

A class that combines view, controller and proxy functionality into a single package. The Delegate class possesses a top-level window.

Variables:
  • model – the model
  • proxy – the proxy
proxy_updated(widget, attribute, value)[source]
set_model(model)[source]

Set model. :param model:

update(attribute)[source]
class kiwi.ui.delegates.ProxySlaveDelegate(model, proxy_widgets=None, gladefile=None, toplevel_name=None, domain=None, keyactions=None)[source]

Bases: kiwi.ui.delegates.GladeSlaveDelegate

A class that combines view, controller and proxy functionality into a single package. It does not possess a top-level window, but is instead intended to be plugged in to a View or Delegate using attach_slave()

Variables:
  • model – the model
  • proxy – the proxy
proxy_updated(widget, attribute, value)[source]
set_model(model)[source]

Set model. :param model:

update(attribute)[source]
class kiwi.ui.delegates.SlaveDelegate(toplevel=None, widgets=(), gladefile=None, toplevel_name=None, keyactions=None)[source]

Bases: kiwi.ui.views.SlaveView, kiwi.controllers.BaseController

A class that combines view and controller functionality into a single package. It does not possess a top-level window, but is instead intended to be plugged in to a View or Delegate using attach_slave().

dialogs Module

kiwi.ui.dialogs.error(short, long=None, parent=None, buttons=<enum GTK_BUTTONS_OK of type GtkButtonsType>, default=-1)[source]
kiwi.ui.dialogs.info(short, long=None, parent=None, buttons=<enum GTK_BUTTONS_OK of type GtkButtonsType>, default=-1)[source]
kiwi.ui.dialogs.messagedialog(dialog_type, short, long=None, parent=None, buttons=<enum GTK_BUTTONS_OK of type GtkButtonsType>, default=-1)[source]

Create and show a MessageDialog.

Parameters:
  • dialog_type – one of constants - gtk.MESSAGE_INFO - gtk.MESSAGE_WARNING - gtk.MESSAGE_QUESTION - gtk.MESSAGE_ERROR
  • short – A header text to be inserted in the dialog.
  • long – A long description of message.
  • parent (a gtk.Window subclass) – The parent widget of this dialog
  • buttons

    The button type that the dialog will be display, one of the constants:

    • gtk.BUTTONS_NONE
    • gtk.BUTTONS_OK
    • gtk.BUTTONS_CLOSE
    • gtk.BUTTONS_CANCEL
    • gtk.BUTTONS_YES_NO
    • gtk.BUTTONS_OK_CANCEL

    or a tuple or 2-sized tuples representing label and response. If label is a stock-id a stock icon will be displayed.

  • default – optional default response id
kiwi.ui.dialogs.warning(short, long=None, parent=None, buttons=<enum GTK_BUTTONS_OK of type GtkButtonsType>, default=-1)[source]
kiwi.ui.dialogs.yesno(text, parent=None, default=<enum GTK_RESPONSE_YES of type GtkResponseType>, buttons=<enum GTK_BUTTONS_YES_NO of type GtkButtonsType>)[source]
kiwi.ui.dialogs.save(title='', parent=None, current_name='', folder=None)[source]

Displays a save dialog.

kiwi.ui.dialogs.open(title='', parent=None, patterns=None, folder=None, filter=None, with_file_chooser=False)[source]

Displays an open dialog. :param title: the title of the folder, defaults to ‘Select folder’ :param parent: parent gtk.Window or None :param patterns: a list of pattern strings [‘.py’, ‘.pl’] or None :param folder: initial folder or None :param filter: a filter to use or None, is incompatible with patterns

class kiwi.ui.dialogs.HIGAlertDialog(parent, flags, type=<enum GTK_MESSAGE_INFO of type GtkMessageType>, buttons=<enum GTK_BUTTONS_NONE of type GtkButtonsType>)[source]

Bases: gtk.Dialog

set_details(text, use_markup=False)[source]
set_details_widget(widget)[source]
set_primary(text, bold=True)[source]
set_secondary(text)[source]
class kiwi.ui.dialogs.BaseDialog(parent=None, title='', flags=0, buttons=())[source]

Bases: gtk.Dialog

entry Module

An enchanced version of GtkEntry that supports icons and masks

class kiwi.ui.entry.KiwiEntry[source]

Bases: gtk.Entry

The KiwiEntry is a Entry subclass with the following additions:

  • Mask, force the input to meet certain requirements
  • IComboMixin: Allows you work with objects instead of strings Adds a number of convenience methods such as :class:`prefill`().
completion

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

do_get_property(pspec)
do_set_property(pspec, value)
exact_completion

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

get_background()[source]
get_completion()[source]
get_empty_mask(start=None, end=None)[source]

Gets the empty mask between start and end

Parameters:
  • start
  • end
Returns:

mask

Return type:

string

get_field()[source]
get_field_length(field)[source]
get_field_pos(field)[source]

Get the position at the specified field.

get_field_text(field)[source]
get_fields()[source]

Get the fields assosiated with the entry. A field is dynamic content separated by static. For example, the format string 000-000 has two fields separated by a dash. if a field is empty it’ll return an empty string otherwise it’ll include the content

Returns:fields
Return type:list of strings
get_iter_by_data(data)[source]
get_iter_by_label(label)[source]
get_iter_from_obj(obj)[source]
get_mask()[source]

Get the mask. :returns: the mask

get_mode()[source]
get_selected_by_iter(treeiter)[source]
get_selected_data(treeiter)[source]
get_selected_label(treeiter)[source]
is_empty()[source]
mask

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

prefill(itemdata, sort=False)[source]

See kiwi.interfaces.IEasyCombo.prefill

set_completion(completion)[source]
set_exact_completion(value)[source]

Enable exact entry completion. Exact means it needs to start with the value typed and the case needs to be correct.

Parameters:value (boolean) – enable exact completion
set_field(field, select=False)[source]
set_mask(mask)[source]

Sets the mask of the Entry. Supported format characters are:

  • ‘0’ digit
  • ‘L’ ascii letter (a-z and A-Z)
  • ‘&’ alphabet, honors the locale
  • ‘a’ alphanumeric, honors the locale
  • ‘A’ alphanumeric, honors the locale

This is similar to MaskedTextBox: U{http://msdn2.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.mask(VS.80).aspx}

Example mask for a ISO-8601 date >>> entry.set_mask(‘0000-00-00’)

Parameters:mask – the mask to set
set_pixbuf(pixbuf)[source]
set_text(text)[source]
set_tooltip(text)[source]
update_background(color)[source]
exception kiwi.ui.entry.MaskError[source]

Bases: exceptions.Exception

kiwi.ui.entry.main(args)[source]

entrycompletion Module

class kiwi.ui.entrycompletion.KiwiEntryCompletion[source]

Bases: gtk.EntryCompletion

complete()[source]
do_match_selected(model, iter)[source]
get_entry()[source]
get_model()[source]
get_treeview()[source]
popdown()[source]
popup()[source]
set_entry(entry)[source]
set_match_func(function, data=None)[source]
set_model(model)[source]
set_popup_window(window)[source]
set_treeview(treeview)[source]

gadgets Module

Graphical utilities: color management and eyecandy

class kiwi.ui.gadgets.FadeOut(widget)[source]

Bases: gobject._gobject.GObject

I am a helper class to draw the fading effect of the background Call my methods start() and stop() to control the fading.

COMPLAIN_DELAY = 500
ERROR_COLOR = '#ffd5d5'
MERGE_COLORS_DELAY = 100
start(color)[source]

Schedules a start of the countdown. :param color: initial background color :returns: True if we could start, False if was already in progress

stop()[source]

Stops the fadeout and restores the background color

kiwi.ui.gadgets.gdk_color_to_string(color)[source]

Convert a color to a #AABBCC string

kiwi.ui.gadgets.get_background(widget, state=<enum GTK_STATE_NORMAL of type GtkStateType>)[source]

Return the background color of the widget as a string

kiwi.ui.gadgets.get_foreground(widget, state=<enum GTK_STATE_NORMAL of type GtkStateType>)[source]

Return the foreground color of the widget as a string

kiwi.ui.gadgets.quit_if_last(*args)[source]
kiwi.ui.gadgets.register_notebook_shortcuts(dialog, notebook)[source]
kiwi.ui.gadgets.render_pixbuf(color_name, width=16, height=16, radius=4)[source]
kiwi.ui.gadgets.set_background(widget, color, state=<enum GTK_STATE_NORMAL of type GtkStateType>)[source]

Set the background color of a widget:

  • widget: the widget we are changing the color
  • color: a hexadecimal code or a well known color name
  • state: the state we are afecting, see gtk.STATE_*
kiwi.ui.gadgets.set_foreground(widget, color, state=<enum GTK_STATE_NORMAL of type GtkStateType>)[source]

Set the foreground color of a widget:

  • widget: the widget we are changing the color
  • color: a hexadecimal code or a well known color name
  • state: the state we are afecting, see gtk.STATE_*

gaxmlloader Module

gazpacholoader Module

libgladeloader Module

class kiwi.ui.libgladeloader.LibgladeWidgetTree(view, gladefile, domain=None)[source]

Bases: gtk.glade.XML

get_sizegroups()[source]
get_widget(name)[source]

Retrieves the named widget from the View (or glade tree)

get_widgets()[source]

listdialog Module

A dialog to manipulate a sequence of objects

class kiwi.ui.listdialog.ListContainer(columns, orientation=<enum GTK_ORIENTATION_VERTICAL of type GtkOrientation>)[source]

Bases: gtk.HBox

A ListContainer is an ObjectList with buttons to be able to modify the content of the list. Depending on the list_mode, @see set_list_mode you will have add, remove and edit buttons.

  • B{add-item} (returns item): - emitted when the add button is clicked, you’re expected to

    return an object here

  • B{remove-item} (item, returns bool): - emitted when removing an item,

    you can block the removal from the list by returning False

  • B{edit-item} (item): - emitted when editing an item

    you can block the update afterwards by returning False

Variables:
  • add_button – add button
  • remove_button – remove button
  • edit_button – edit button
add_item(item)[source]

Appends an item to the list :param item: item to append

add_items(items)[source]

Appends a list of items to the list :param items: items to add :type items: a sequence of items

clear()[source]

Removes all the items in the list

default_remove(item)[source]

Asks the user confirmation for removal of an item. :param item: a description of the item that will be removed :returns: True if the user confirm the removal, False otherwise

remove_item(item)[source]

Removes an item from the list :param item: item to remove

set_list_type(list_type)[source]

Sets the kind of list type. :param list_type:

update_item(item)[source]

Updates an item in the list. You should call this if you change the object :param item: item to update

class kiwi.ui.listdialog.ListDialog(columns=None)[source]

Bases: gtk.Dialog, kiwi.ui.listdialog.ListSlave

A ListDialog implements a ListContainer in a L{gtk.Dialog} with a close button.

It’s a simple Base class which needs to be subclassed to provide interesting functionality.

Example: >>> class MyListDialog(ListDialog): ... ... columns = [Column(‘name’)] ... list_type = ListType.UNEDITABLE ... ... def populate(self): ... return [Settable(name=’test’)] ... ... def add_item(self): ... return Settable(name=”added”)

>>> dialog = MyListDialog()
>>> dialog.run()
class kiwi.ui.listdialog.ListSlave(columns=None, orientation=<enum GTK_ORIENTATION_VERTICAL of type GtkOrientation>)[source]

Bases: kiwi.ui.delegates.SlaveDelegate

add_item()[source]

This must be implemented in a subclass if you want to be able to add items.

It should return the model you want to add to the list or None if you don’t want anything to be added, eg the user cancelled creation of the model

add_list_item(item)[source]

Add item to list. @see: Listcontainer.add_item

add_list_items(item)[source]

Add items to list. @see: Listcontainer.add_items

columns = None
edit_item(item)[source]

A subclass must implement this if you want to support editing of objects. :returns: False if the item should not be removed

list_type = <ListType value NORMAL>
populate()[source]

This will be called once after the user interface construction is done. It should return a list of objects which will initially be inserted :returns: object to insert :rtype: sequence of objects

refresh()[source]

Updates all the items in the list. Clears the list and calls “populate()”

remove_item(item)[source]

A subclass can implement this to get a notification after an item is removed. If it’s not implemented ListContainer.default_remove will be called :returns: False if the item should not be removed

remove_list_item(item)[source]

Remove item from list. @see: Listcontainer.remove_item

selection_changed(selection)[source]

This will be called when the selection changes in the ListDialog :param selection: selected object or None if nothing is selected

set_list_type(list_type)[source]

Set list type. @see: Listcontainer.set_list_type

update_list_item(item)[source]

Update item in list. @see: Listcontainer.edit_item

objectlist Module

High level wrapper for GtkTreeView

class kiwi.ui.objectlist.ColoredColumn(attribute, title=None, data_type=None, color=None, data_func=None, use_data_model=False, **kwargs)[source]

Bases: kiwi.ui.objectlist.Column

I am a column which can colorize the text of columns under certain circumstances. I take a color and an extra function which will be called for each row

Example, to colorize negative values to red:

>>> def colorize(value):
...   return value < 0
...
... ColoredColumn('age', data_type=int, color='red',
...               data_func=colorize),
on_attach_renderer(renderer)[source]
renderer_func(renderer, data)[source]
class kiwi.ui.objectlist.Column(attribute='', title=None, data_type=None, **kwargs)[source]

Bases: gobject._gobject.GObject

Specifies a column for an ObjectList, see the ObjectList documentation for a simple example.

  • B{title}: string I{mandatory} - the title of the column, defaulting to the capitalized form of

    the attribute

  • B{data-type}: object I{str} - the type of the attribute that will be inserted into the column.

    Supported data types: bool, int, float, str, unicode, decimal.Decimal, datetime.date, datetime.time, datetime.datetime, gtk.gdk.Pixbuf, kiwi.currency.currency, L{kiwi.python.enum}.

  • B{visible}: bool I{True} - specifying if it is initially hidden or shown.

  • B{justify}: gtk.Justification I{None} - one of gtk.JUSTIFY_LEFT, gtk.JUSTIFY_RIGHT or gtk.JUSTIFY_CENTER

    or None. If None, the justification will be determined by the type of the attribute value of the first instance to be inserted in the ObjectList (for instance numbers will be right-aligned).

  • B{format}: string I{“”} - a format string to be applied to the attribute value upon insertion

    in the list.

  • B{width}: integer I{65535} - the width in pixels of the column, if not set, uses the default to

    ObjectList. If no Column specifies a width, columns_autosize() will be called on the ObjectList upon append() or the first add_list().

  • B{sorted}: bool I{False} - whether or not the ObjectList is to be sorted by this column.

    If no Columns are sorted, the ObjectList will be created unsorted.

  • B{order}: GtkSortType I{-1} - one of gtk.SORT_ASCENDING, gtk.SORT_DESCENDING or -1

    The value -1 is mean that the column is not sorted.

  • B{expand}: bool I{False} - if set column will expand. Note: this space is shared equally amongst

    all columns that have the expand set to True.

  • B{tooltip}: string I{“”} - a string which will be used as a tooltip for the column header

  • B{format_func}: object I{None} - a callable which will be used to format the output of a column.

    The function will take one argument which is the value to convert and is expected to return a string. I{Note}: that you cannot use format and format_func at the same time, if you provide a format function you’ll be responsible for converting the value to a string.

  • B{format_func_data}: object I{None} - If format_func_data is not None, format_func will receive the row

    object instead of just the column value, and also receive this value as a second argument.

  • B{editable}: bool I{False} - if true the field is editable and when you modify the contents of

    the cell the model will be updated.

  • B{searchable}: bool I{False} - if true the attribute values of the column can be searched using

    type ahead search. Only string attributes are currently supported.

  • B{radio}: bool I{False} - If true render the column as a radio instead of toggle.

    Only applicable for columns with boolean data types.

  • B{spin_adjustment}: gtk.Adjustment I{None} - A gtk.Adjustment instance. If set, render the column cell as

    a spinbutton.

  • B{use_stock}: bool I{False} - If true, this will be rendered as pixbuf from the value which

    should be a stock id.

  • B{icon_size}: gtk.IconSize I{gtk.ICON_SIZE_MENU}

  • B{editable_attribute}: string I{“”} - a string which is the attribute which should decide if the

    cell is editable or not.

  • B{use_markup}: bool I{False} - If true, the text will be rendered with markup

  • B{expander}: bool I{False} - If True, this column will be used as the tree expander column

  • B{ellipsize}: pango.EllipsizeMode I{pango.ELLIPSIZE_NONE} - One of pango.ELLIPSIZE_{NONE, START, MIDDLE or END}, it describes

    where characters should be removed in case ellipsization (where to put the ...) is needed.

  • B{font-desc}: str I{“”} - A string passed to pango.FontDescription, for instance “Sans” or

  • B{column}: str None - A string referencing to another column. If this is set a new column

    will not be created and the column will be packed into the other.

  • B{sort_func}: object I{None} - a callable which will be used to sort the contents of the column.

    The function will take two values (x and y) from the column and should return negative if x<y, zero if x==y, positive if x>y.

  • B{pack_end}: bool I{False} - If set it will pack the renderer to the end of the column instead

    of the beginning.

  • B{width_chars}: int I{-1} - If set it will specify the number of characters that should displayed

    for the cells in this column.

as_string(data, obj=None)[source]

Formats the column as a string that should be renderd into the cell.

Parameters:
  • data – The column value that will be converted to string.
  • obj – Necessary only when format_func_data is set. This will make format_func receive I{obj} instead of I{data}
attach(objectlist)[source]
attribute

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

cell_data_func = None
column

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

create_renderer(model)[source]

Gusses which CellRenderer we should use for a given type. It also set the property of the renderer that depends on the model, in the renderer.

data_type

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

do_get_property(pspec)
do_set_property(pspec, value)
editable

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

editable_attribute

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

ellipsize

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

expand

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

expander

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

font_desc

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

format

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

format_func

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

format_func_data

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

static get_attribute(model, attr_name, default=<class kiwi.accessor._AttrUnset at 0xb1f1aac>, flat=0, ref=<type 'weakref'>, TupleType=<type 'tuple'>, MethodType=<type 'instancemethod'>, split=<function split at 0x40859d4c>, kgetattr_guard=<function kgetattr_guard at 0xb1f387c>, getattr=<built-in function getattr>, dummycache=<kiwi.accessor.CacheControl object at 0xb1e13ac>, LAMBDA_ACCESS=0, METHOD_ACCESS=1, TUPLE_ACCESS=2, NWR_METHOD_ACCESS=3, NWR_TUPLE_ACCESS=4, FAST_METHOD_ACCESS=5, FAST_TUPLE_ACCESS=6)

Returns the value associated with the attribute in model named by attr_name. If default is provided and model does not have an attribute called attr_name, the default value is returned. If flat=1 is specified, no dot path parsing will be done.

icon_size

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

justify

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

on_attach_renderer = None
order

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

pack_end

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

radio

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

renderer_func = None
searchable

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

set_spinbutton_precision_digits(digits)[source]

Set the number of precision digits to be shown in the spinbutton.

Parameters:digits – the number of precision digits to be set in

spinbutton :type digits: int

sort_func

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

sorted

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

spin_adjustment

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

title

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

tooltip

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

use_markup

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

use_stock

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

visible

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

width

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

width_chars

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

class kiwi.ui.objectlist.ListLabel(klist, column, label='', value_format='%s', font_desc=None)[source]

Bases: gtk.HBox

I am a subclass of a GtkHBox which you can use if you want to vertically align a label with a column

get_label_widget()[source]
get_value_widget()[source]
set_value(value)[source]

Sets the value of the label. Note that it needs to be of the same type as you specified in value_format in the constructor. I also support the GMarkup syntax, so you can use “<b>%d</b>” if you want.

class kiwi.ui.objectlist.ObjectList(columns=None, objects=None, mode=<enum GTK_SELECTION_BROWSE of type GtkSelectionMode>, sortable=False, model=None)[source]

Bases: gtk.HBox

An enhanced version of GtkTreeView, which provides pythonic wrappers for accessing rows, and optional facilities for column sorting (with types) and column selection.

Items in an ObjectList is stored in objects. Each row represents an object and each column represents an attribute in the object. The column description object must be a subclass of Column. Simple example

>>> class Fruit:
>>>    pass
>>> apple = Fruit()
>>> apple.name = 'Apple'
>>> apple.description = 'Worm house'
>>> banana = Fruit()
>>> banana.name = 'Banana'
>>> banana.description = 'Monkey food'
>>> fruits = ObjectList([Column('name'),
>>>                      Column('description')])
>>> fruits.append(apple)
>>> fruits.append(banana)
  • B{row-activated} (list, object): - Emitted when a row is “activated”, eg double clicked or pressing

    enter. See the GtkTreeView documentation for more information

  • B{selection-changed} (list, object): - Emitted when the selection changes for the ObjectList

    enter. See the documentation on GtkTreeSelection::changed for more information

  • B{double-click} (list, object): - Emitted when a row is double-clicked, mostly you want to use

    the row-activated signal instead to be able catch keyboard events.

  • B{right-click} (list, object): - Emitted when a row is clicked with the right mouse button.

  • B{cell-edited} (list, object, attribute): - Emitted when a cell is edited.

  • B{has-rows} (list, bool): - Emitted when the objectlist goes from an empty to a non-empty

    state or vice verse.

  • B{activate-link} (str): - Emitted when the a link in a message is clicked on

  • B{selection-mode}: gtk.SelectionMode I{gtk.SELECTION_BROWSE} - Represents the selection-mode of a GtkTreeSelection of a GtkTreeView.
add_list(instances, clear=True)[source]

Allows a list to be loaded, by default clearing it first. freeze() and thaw() are called internally to avoid flashing.

Parameters:
  • instances – a list to be added
  • clear – a boolean that specifies whether or not to clear the list
append(instance, select=False)[source]

Adds an instance to the list. :param instance: the instance to be added (according to the columns spec) :param select: whether or not the new item should appear selected.

clear()[source]

Removes all the instances of the list

clear_message()[source]
count(item) → integer -- return number of occurrences of value[source]
do_get_property(pspec)
do_set_property(pspec, value)
double_click(rowno)[source]

Same as double clicking on the row rowno

Parameters:rowno – integer
enable_dnd()[source]

Enables Drag and Drop from this object list

extend(iterable)[source]

Extend list by appending elements from the iterable

Parameters:iterable
get_cell_contents()[source]
get_column_by_name(name)[source]

Returns the name of a column

get_columns()[source]
get_dnd_targets()[source]

Get a list of dnd targets ObjectList supports

get_header_titles()[source]
get_model()[source]

Return treemodel of the current list

get_next(instance)[source]

Returns the item after instance in the list. Note that the instance must be inserted before this can be called If there are no instances after, the first item will be returned.

Parameters:instance – the instance
get_previous(instance)[source]

Returns the item before instance in the list. Note that the instance must be inserted before this can be called If there are no instances before, the last item will be returned.

Parameters:instance – the instance
get_selected()[source]

Returns the currently selected object If an object is not selected, None is returned

get_selected_row_number()[source]

Get the selected row number or None if no rows were selected

get_selected_rows()[source]

Returns a list of currently selected objects If no objects are selected an empty list is returned

get_selection_mode()[source]
get_treeview()[source]

Return treeview of the current list

get_treeview_column(column)[source]

Get the treeview column given an objectlist column :param column: a @Column

get_visible_columns()[source]

Returns a list of visibile columns

grab_focus()[source]

Grabs the focus of the ObjectList

index(item, start=None, stop=None)[source]

Return first index of value

Parameters:
  • item
  • start

:param stop

insert(index, instance, select=False)[source]

Inserts an instance to the list :param index: position to insert the instance at :param instance: the instance to be added (according to the columns spec) :param select: whether or not the new item should appear selected.

pop(index)[source]

Remove and return item at index (default last) :param index:

refresh(view_only=False)[source]

Reloads the values from all objects.

Parameters:view_only – if True, only force a refresh of the visible part of this objectlist’s Treeview.
remove(instance, select=False)[source]

Remove an instance from the list. If the instance is not in the list it returns False. Otherwise it returns True.

Parameters:
  • instance
  • select – if true, the previous item will be selected if there is one.
reverse(pos, item)[source]

L.reverse() – reverse IN PLACE

select(instances, scroll=True)[source]
select_paths(paths)[source]

Selects a number of rows corresponding to paths

Parameters:paths – rows to be selected
selection_mode

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

set_cell_data_func(cell_data_func)[source]
set_column_visibility(column_index, visibility)[source]
set_columns(columns)[source]

Set columns. :param columns: a sequence of Column objects.

set_context_menu(menu)[source]

Sets a context-menu (eg, when you right click) for the list. :param menu: context menu :type menu: ContextMenu

set_headers_visible(value)[source]

Show or hide the headers. :param value: if true, shows the headers, if false hide then

set_message(markup)[source]

Adds a message on top of the treeview rows :param markup: PangoMarkup with the text to add

set_selection_mode(mode)[source]
set_spinbutton_digits(column_name, digits)[source]

Set the number of precision digits used by the spinbutton in a column.

Parameters:
  • column_name (str) – the column name which has the spinbutton
  • digits (int) – a number specifying the precision digits
set_visible_rows(rows)[source]

Sets the number of visible rows of the treeview. This is useful to use instead of set_size_request() directly, since you can avoid using raw pixel sizes. :param rows: number of rows to show

sort(pos, item)[source]

L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1

sort_by_attribute(attribute, order=<enum GTK_SORT_ASCENDING of type GtkSortType>)[source]

Sort by an attribute in the object model.

Parameters:
  • attribute (string) – attribute to sort on
  • order (gtk.SortType) – one of gtk.SORT_ASCENDING, gtk.SORT_DESCENDING
unselect_all()[source]
update(instance)[source]
class kiwi.ui.objectlist.ObjectTree(columns=[], objects=None, mode=<enum GTK_SELECTION_BROWSE of type GtkSelectionMode>, sortable=False, model=None)[source]

Bases: kiwi.ui.objectlist.ObjectList

  • B{row-expanded} (list, object): - Emitted when a row is “expanded”, eg the littler arrow to the left

    is opened. See the GtkTreeView documentation for more information.

append(parent, instance, select=False)[source]

Append the selected row in an instance. :param parent: Object or None, representing the parent :param instance: the instance to be added :param select: select the row :returns: the appended object

collapse(instance)[source]

This method collapses the row specified by path (hides its child rows, if they exist). :param instance: an instance to collapse

expand(instance, open_all=True)[source]

This method opens the row specified by path so its children are visible. :param instance: an instance to expand at :param open_all: If True, expand all rows, otherwise just the immediate children

flush()[source]

Update all iterators

get_descendants(root_instance)[source]

This method returns the descendants objects of a certain instance. If the given instance is a leaf, then return an empty sequence. :param root_instance: an instance which we want the descendants :returns: a sequence of descendants objects

get_parent(instance)[source]

This method returns the parent of the specified instance are visible. :returns: the parent of the instance or None

get_root(instance)[source]

This method returns the root object of a certain instance. If the instance is the root, then returns the given instance. :param instance: an instance which we want the root object

prepend(parent, instance, select=False)[source]

Prepend the selected row in an instance. :param parent: Object or None, representing the parent :param instance: the instance to be added :param select: select the row :returns: the prepended object

class kiwi.ui.objectlist.SearchColumn(attribute, title=None, data_type=None, long_title=None, valid_values=None, search_attribute=None, **kwargs)[source]

Bases: kiwi.ui.objectlist.Column

I am a column that should be used in conjunction with kiwi.ui.search.SearchSlaveDelegate

Parameters:
  • long_title – The title to display in the combo for this field. This is usefull if you need to display a small description on the column header, but still want a full description on the advanced search.
  • valid_values – This should be a list of touples (display value, db value). If provided, then a combo with only this values will be shown, instead of a free text entry.
  • search_attribute – Use this if the name of the db column that should be searched is different than the attribute of the model.
class kiwi.ui.objectlist.SequentialColumn(title='#', justify=<enum GTK_JUSTIFY_RIGHT of type GtkJustification>, **kwargs)[source]

Bases: kiwi.ui.objectlist.Column

I am a column which will display a sequence of numbers, which represent the row number. The value is independent of the data in the other columns, so no matter what I will always display 1 in the first column, unless you reverse it by clicking on the column header.

If you don’t give me any argument I’ll have the title of a hash (#) and right justify the sequences.

cell_data_func(tree_column, renderer, model, treeiter, (column, renderer_prop))[source]
class kiwi.ui.objectlist.SummaryLabel(klist, column, label='Total:', value_format='%s', font_desc=None)[source]

Bases: kiwi.ui.objectlist.ListLabel

I am a subclass of ListLabel which you can use if you want to summarize all the values of a specific column. Please note that I only know how to handle number column data types and I will complain if you give me something else.

update_total()[source]

Recalculate the total value of all columns

kiwi.ui.objectlist.str2bool(value, from_string=<bound method ConverterRegistry.from_string of <kiwi.datatypes.ConverterRegistry instance at 0xb1faaec>>)[source]

converts a boolean to a enum

kiwi.ui.objectlist.str2enum(value_name, enum_class)[source]

converts a string to a enum

proxy Module

This module defines the Proxy class, which is a facility that can be used to keep the state of a model object synchronized with a View.

class kiwi.ui.proxy.Proxy(view, model=None, widgets=())[source]

A Proxy is a class that ‘attaches’ an instance to an interface’s widgets, and transparently manipulates that instance’s attributes as the user alters the content of the widgets.

The Proxy takes the widget list and detects what widgets are to be attached to the model by looking if it is a KiwiWidget and if it has the model-attribute set.

add_widget(name, widget)[source]

Adds a new widget to the proxy

Parameters:
  • name – name of the widget
  • widget – widget, must be a gtk.Widget subclass
model
new_model(*args, **kwargs)[source]
proxy_updated(widget, attribute, value)[source]

This is a hook that is called whenever the proxy updates the model. Implement it in the inherited class to perform actions that should be done each time the user changes something in the interface. This hook by default does nothing. :param widget: :param attribute: :param value:

remove_widget(name)[source]

Removes a widget from the proxy

Parameters:name – the name of the widget to remove
set_model(model, relax_type=False)[source]

Updates the model instance of the proxy. Allows a proxy interface to change model without the need to destroy and recreate the UI (which would cause flashing, at least)

Parameters:
  • model
  • relax_type
update(attribute, value=<class kiwi.ValueUnset at 0xabca0ec>, block=False)[source]

Generic frontend function to update the contentss of a widget based on its model attribute name using the internal update functions.

Parameters:
  • attribute – the name of the attribute whose widget we wish to updated. If accessing a radiobutton, specify its group name.
  • value – specifies the value to set in the widget. If unspecified, it defaults to the current model’s value (through an accessor, if it exists, or getattr).
  • block – defines if we are to block cascading proxy updates triggered by this update. You should use block if you are calling update on the same attribute that is currently being updated. This means if you have hooked to a signal of the widget associated to that attribute, and you call update() for the same attribute, use block=True. And pray. 8). If block is set to False, the normal update mechanism will occur (the model being updated in the end, hopefully).
update_many(attributes, value=<class kiwi.ValueUnset at 0xabca0ec>, block=False)[source]

Like update but takes a sequence of attributes

Parameters:
  • attributes – sequence of attributes to update
  • value – see update
  • block – see update
exception kiwi.ui.proxy.ProxyError[source]

Bases: exceptions.Exception

kiwi.ui.proxy.block_widget(widget)[source]

Blocks the signal handler of the ‘content-changed’ signal on widget

kiwi.ui.proxy.unblock_widget(widget)[source]

Unblocks the signal handler of the ‘content-changed’ signal on widget

proxywidget Module

Basic classes for widget support for the Kiwi Framework

class kiwi.ui.proxywidget.ProxyWidgetMixin[source]

Bases: object

This class is a mixin that provide a common interface for KiwiWidgets.

Usually the Proxy class need to set and get data from the widgets. It also need a validation framework.

Variables:allowed_data_types – A list of types which we are allowed to use in this class.
allowed_data_types = ()
get_data_type()[source]
read()[source]

Get the content of the widget. The type of the return value :returns: None if the user input a invalid value :rtype: Must matche the data-type property.

set_data_format(format)[source]
set_data_type(data_type)[source]

Set the data type for the widget

Parameters:data_type – can be None, a type object or a string with the name of the type object, so None, “<type ‘str’>” or ‘str’
set_options_for_datatype(datatype, **options)[source]

Set some options to be passed to the datatype converter. Any additional parameter will be passed the the converter when converting an object to a string, for displaying in the widget. Note that the converter.as_string method should be able to handle such parameters.

Parameters:datatype – the datatype.
update(value)[source]

Update the content value of the widget. :param value:

class kiwi.ui.proxywidget.ValidatableProxyWidgetMixin(widget=None)[source]

Bases: kiwi.ui.proxywidget.ProxyWidgetMixin

Class used by some Kiwi Widgets that need to support mandatory input and validation features such as custom validation and data-type validation.

Mandatory support provides a way to warn the user when input is necessary. The validatation feature provides a way to check the data entered and to display information about what is wrong.

get_background()[source]

Implement in subclass

is_valid()[source]

Verify the widget state. :returns: True if the widget is in validated state

set_blank()[source]

Changes the validation state to blank state, this only applies for mandatory widgets, draw an icon and set a tooltip

set_invalid(text=None, fade=True)[source]

Changes the validation state to invalid. :param text: text of tooltip of None :param fade: if we should fade the background

set_pixbuf(pixbuf)[source]

Implement in subclass

set_tooltip(text)[source]

Implement in subclass

set_valid()[source]

Changes the validation state to valid, which will remove icons and reset the background color

update_background(color)[source]

Implement in subclass

validate(force=False)[source]

Checks if the data is valid. Validates data-type and custom validation.

Parameters:force – if True, force validation
Returns:validated data or ValueUnset if it failed

search Module

Search related widgets

class kiwi.ui.search.Any[source]

Bases: kiwi.ui.search.DateSearchOption

get_interval()[source]
name = 'Any'
class kiwi.ui.search.Between[source]

Bases: kiwi.ui.search.NumberSearchOption

get_interval(start, end)[source]
name = 'Between'
numbers = 2
class kiwi.ui.search.ComboSearchFilter(label='', values=None)[source]

Bases: kiwi.ui.search.SearchFilter

  • a label
  • a combo with a set of predefined item to select from
get_description()[source]
get_mode_combo()[source]
get_state()[source]
get_title_label()[source]
select(data)[source]

selects an item in the combo :param data: what to select

set_state(value, value_id=None)[source]
update_values(values)[source]
class kiwi.ui.search.Contains[source]

Bases: kiwi.ui.search.StringSearchOption

mode = 0
name = 'Contains'
class kiwi.ui.search.DateSearchFilter(label='')[source]

Bases: kiwi.ui.search.SearchFilter

A filter which helps you to search by a date interval. Can be customized through add_option.

class Type[source]

Bases: kiwi.python.enum

USER_DAY = <Type value USER_DAY>
USER_INTERVAL = <Type value USER_INTERVAL>
names = {'USER_DAY': <Type value USER_DAY>, 'USER_INTERVAL': <Type value USER_INTERVAL>}
values = {100: <Type value USER_DAY>, 101: <Type value USER_INTERVAL>}
DateSearchFilter.add_custom_options()[source]

Adds the custom options ‘Custom day’ and ‘Custom interval’ which let the user define its own interval dates.

DateSearchFilter.add_option(option_type, position=-2)[source]

Adds a date option :param option_type: option to add :type option_type: a DateSearchOption subclass

DateSearchFilter.add_option_fixed(name, date, position=-2)[source]

Adds a fixed option, eg one for which date is not possible to modify. :param name: name of the option :param date: fixed data :param position: position to add the option at

DateSearchFilter.add_option_fixed_interval(name, start, end, position=-2)[source]

Adds a fixed option interval, eg one for which the dates are not possible to modify. :param name: name of the option :param start: start of the fixed interval :param end: end of the fixed interval :param position: position to add the option at

DateSearchFilter.clear_options()[source]

Removes all previously added options

DateSearchFilter.get_description()[source]
DateSearchFilter.get_end_date()[source]

Get the end date. :returns: end date :rtype: datetime.date or None

DateSearchFilter.get_mode_combo()[source]
DateSearchFilter.get_start_date()[source]

Get the start date. :returns: start date :rtype: datetime.date or None

DateSearchFilter.get_state()[source]
DateSearchFilter.get_title_label()[source]
DateSearchFilter.select(data=None, position=None)[source]

selects an item in the combo Data or position can be sent in. If nothing is sent in the first item will be selected, if any

Parameters:
  • data – data to select
  • position – position of data to select
DateSearchFilter.set_state(start, end=None)[source]
DateSearchFilter.set_use_date_entries(use_date_entries)[source]

Toggles the visibility of the user selectable date entries :param use_date_entries:

class kiwi.ui.search.DateSearchOption[source]

Bases: object

Base class for Date search options A date search option is an interval of dates :cvar name: name of the search option

get_interval()[source]

Get start and end date. :returns: start date, end date :rtype: datetime.date tuple

get_today_date()[source]
name = None
class kiwi.ui.search.DoesNotContain[source]

Bases: kiwi.ui.search.StringSearchOption

mode = 1
name = 'Does Not Contain'
class kiwi.ui.search.EqualsTo[source]

Bases: kiwi.ui.search.NumberSearchOption

get_interval(start, end)[source]
name = 'Equals to'
numbers = 1
class kiwi.ui.search.FixedDateSearchOption[source]

Bases: kiwi.ui.search.DateSearchOption

date = None
get_interval()[source]
class kiwi.ui.search.FixedIntervalSearchOption[source]

Bases: kiwi.ui.search.DateSearchOption

end = None
get_interval()[source]
start = None
class kiwi.ui.search.GreaterThan[source]

Bases: kiwi.ui.search.NumberSearchOption

get_interval(start, end)[source]
name = 'Greater or Equal'
numbers = 1
class kiwi.ui.search.HintedEntry[source]

Bases: gtk.Entry

do_focus_in_event(event)[source]
do_focus_out_event(event)[source]
do_grab_focus()[source]
get_text()[source]
set_hint(text)[source]
set_text(text)[source]
show_hint()[source]
show_text(text)[source]
class kiwi.ui.search.LastMonth[source]

Bases: kiwi.ui.search.DateSearchOption

get_interval()[source]
name = 'Last month'
class kiwi.ui.search.LastWeek[source]

Bases: kiwi.ui.search.DateSearchOption

get_interval()[source]
name = 'Last week'
class kiwi.ui.search.LowerThan[source]

Bases: kiwi.ui.search.NumberSearchOption

get_interval(start, end)[source]
name = 'Lower or Equal'
numbers = 1
class kiwi.ui.search.NumberSearchFilter(label='')[source]

Bases: kiwi.ui.search.SearchFilter

A filter which helps you to search by a number interval.

add_option(option_type, position=-2)[source]

Adds a date option :param option_type: option to add :type option_type: a NumberSearchOption subclass

get_description()[source]
get_mode_combo()[source]
get_state()[source]
get_title_label()[source]
set_digits(digits)[source]

Number of decimal place to be displayed :param digits: number of decimal places

set_state(start, end)[source]
class kiwi.ui.search.NumberSearchOption[source]

Bases: object

Base class for Number search options A number search option is an interval of numbers :cvar name: name of the search option :cvar numbers: how many numbers must the user input: 0, 1 or 2

get_interval(start, end)[source]

Get start and end interval. :returns: start, end

name = None
numbers = 0
class kiwi.ui.search.SearchContainer(columns=None, chars=25)[source]

Bases: gtk.VBox

A search container is a widget which consists of: - search entry (w/ a label) (StringSearchFilter) - search button - objectlist result (SearchResult) - a query executer (kiwi.db.query.QueryExecuter)

Additionally you can add a number of search filters to the SearchContainer. You can chose if you want to add the filter in the top-left corner of bottom, see SearchFilterPosition

add_filter(search_filter, position=<SearchFilterPosition value BOTTOM>, columns=None, callback=None)[source]

Adds a search filter :param search_filter: the search filter :param postition: a SearchFilterPosition enum :param columns: :param callback:

add_results(results)[source]
disable_search_entry()[source]

Disables the search entry

do_get_child_property(child, property_id, pspec)[source]
do_get_property(pspec)[source]
do_set_child_property(child, property_id, value, pspec)[source]
do_set_property(pspec, value)[source]
filter_label

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

get_filter_position(search_filter)[source]

Get filter by position. :param search_filter:

get_filter_states()[source]
get_primary_filter()[source]

Fetches the primary filter for the SearchContainer. The primary filter is the filter attached to the standard entry normally used to do free text searching :returns: the primary filter

get_query_executer()[source]

Fetchs the QueryExecuter for the SearchContainer :returns: a querty executer :rtype: a QueryExecuter subclass

get_search_filter_by_label(label)[source]
get_search_filters()[source]
remove_filter(filter)[source]
results_class

alias of SearchResults

search()[source]

Starts a search. Fetches the states of all filters and send it to a query executer and finally puts the result in the result class

Enables/Disables auto search which means that the search result box is automatically populated when a filter changes :param auto_search: True to enable, False to disable

set_filter_position(search_filter, position)[source]

Set the the filter position. :param search_filter: :param position:

set_filter_states(dict_state)[source]
set_query_executer(querty_executer)[source]

Ties a QueryExecuter instance to the SearchContainer class :param querty_executer: a querty executer :type querty_executer: a QueryExecuter subclass

set_summary_label(column, label='Total:', format='%s', parent=None)[source]

Adds a summary label to the result set :param column: the column to sum from :param label: the label to use, defaults to ‘Total:’ :param format: the format, defaults to ‘%%s’, must include ‘%%s’ :param parent: the parent widget a label should be added to or

None if it should be added to the SearchContainer
set_text_field_columns(columns)[source]
class kiwi.ui.search.SearchFilter(label='')[source]

Bases: gtk.HBox

A base classed used by common search filters

do_get_property(pspec)[source]
do_set_property(pspec, value)[source]
get_description()[source]

Returns a description of the search filter. :returns: a string describing the search filter.

get_mode_combo()[source]
get_state()[source]

Implement this in a subclass

get_title_label()[source]
label

Creates a new property which in conjunction with GObject subclass will create a property proxy:

>>> class MyObject(gobject.GObject):
>>> ... prop = gobject.property(type=str)
>>> obj = MyObject()
>>> obj.prop = 'value'
>>> obj.prop
'value'

The API is similar to the builtin property:

class AnotherObject(gobject.GObject):

@gobject.property def prop(self):

return ...

Which will create a read-only property called prop.

set_label(label)[source]
set_removable()[source]
class kiwi.ui.search.SearchFilterButton(label=None, stock=None, use_underline=True)[source]

Bases: gtk.Button

set_icon_size(icon_size)[source]
set_label_visible(visible)[source]
class kiwi.ui.search.SearchResults(columns)[source]

Bases: kiwi.ui.objectlist.ObjectList

class kiwi.ui.search.SearchSlaveDelegate(columns)[source]

Bases: kiwi.ui.delegates.SlaveDelegate

add_filter(search_filter, position=<SearchFilterPosition value BOTTOM>, columns=None, callback=None)[source]

See SearchSlaveDelegate.add_filter

clear()[source]

Clears the result list

disable_search_entry()[source]

Disables the search entry

See SearchContainer.enable_advanced_search

focus_search_entry()[source]

Grabs the focus of the search entry

get_columns()[source]

This needs to be implemented in a subclass :returns: columns :rtype: list of kiwi.ui.objectlist.Column

get_primary_filter()[source]

Fetches the primary filter of the SearchSlaveDelegate :returns: primary filter

get_search_filters()[source]
refresh()[source]

Triggers a search again with the currently selected inputs

set_query_executer(querty_executer)[source]

See SearchSlaveDelegate.set_query_executer

set_summary_label(column, label='Total:', format='%s', parent=None)[source]

See SearchContainer.set_summary_label

set_text_field_columns(columns)[source]

See SearchSlaveDelegate.set_text_field_columns

class kiwi.ui.search.StringSearchFilter(label, chars=0)[source]

Bases: kiwi.ui.search.SearchFilter

  • a label
  • an entry
Variables:
  • entry – the entry
  • label – the label
enable_advaced()[source]
get_description()[source]
get_mode_combo()[source]
get_state()[source]
get_title_label()[source]
set_label(label)[source]
set_state(text, mode=None)[source]
class kiwi.ui.search.StringSearchOption[source]

Bases: object

class kiwi.ui.search.Today[source]

Bases: kiwi.ui.search.DateSearchOption

get_interval()[source]
name = 'Today'
class kiwi.ui.search.Yesterday[source]

Bases: kiwi.ui.search.DateSearchOption

get_interval()[source]
name = 'Yesterday'

selectablebox Module

A box which you can select and will have a border around it when you click on any widgets in it

class kiwi.ui.selectablebox.SelectableBox(width=4)[source]

Bases: object

add(child)[source]

Identical to gtk.Container.add

do_button_press_event(event)[source]
do_realize()[source]
get_selected()[source]

Get the currently selected widget. :returns: widget

pack_end(child, expand=True, fill=True, padding=0)[source]

Identical to gtk.Box.pack_end

pack_start(child, expand=True, fill=True, padding=0)[source]

Identical to gtk.Box.pack_start

set_selected(widget)[source]

Set the widget to be selected, must be a children of self. :param widget: widget to select.

update_selection()[source]
class kiwi.ui.selectablebox.SelectableHBox(width=4)[source]

Bases: kiwi.ui.selectablebox.SelectableBox, gtk.HBox

do_button_press_event(event)
do_expose_event(event)[source]
do_realize()
do_size_allocate(allocation)[source]
class kiwi.ui.selectablebox.SelectableVBox(width=4)[source]

Bases: kiwi.ui.selectablebox.SelectableBox, gtk.VBox

do_button_press_event(event)
do_expose_event(event)[source]
do_realize()
do_size_allocate(allocation)[source]

tooltip Module

A tooltip popup window which only pop ups on demand, which makes it possible for us to tie it to a specific gtk.gdk.Window

class kiwi.ui.tooltip.Tooltip(widget)[source]

Bases: gtk.Window

display(widget)[source]
hide()[source]
set_text(text)[source]

views Module

Defines the View classes that are included in the Kiwi Framework, which are the base of Delegates and Proxies.

class kiwi.ui.views.BaseView(toplevel=None, widgets=None, gladefile=None, toplevel_name=None, domain=None, delete_handler=None)[source]

Bases: kiwi.ui.views.SlaveView

A view with a toplevel window.

check_focus()[source]

Tests the focus in the window and prints a warning if no widget is focused.

get_focus_widget()[source]

Returns the currently focused widget in the window

get_glade_adaptor()[source]
hide(*args)[source]

Hide the view’s window

hide_and_quit(*args)[source]

Hides the current window and breaks the GTK+ event loop if this is the last window. Its method signature allows it to be used as a signal handler.

quit_if_last(*args)[source]
set_title(title)[source]

Sets the view’s window title

set_transient_for(view)[source]

Makes the view a transient for another view; this is commonly done for dialogs, so the dialog window is managed differently than a top-level one.

show(parent=None, *args)[source]

Show the view’s window. If the parent argument is supplied and is a valid view, this view is set as a transient for the parent view.

show_all(parent=None, *args)[source]
class kiwi.ui.views.GladeSignalBroker(view, controller)[source]

Bases: kiwi.ui.views.SignalBroker

class kiwi.ui.views.SignalBroker(view, controller)[source]

Bases: object

disconnect_autoconnected()[source]
handler_block(widget, signal_name)[source]
handler_unblock(widget, signal_name)[source]
class kiwi.ui.views.SlaveView(toplevel=None, widgets=None, gladefile=None, toplevel_name=None, domain=None)[source]

Bases: gobject._gobject.GObject

Base class for all View classes. Defines the essential class attributes (controller, toplevel, widgets) and handles initialization of toplevel and widgets. Once AbstractView.__init__() has been called, you can be sure self.toplevel and self.widgets are sane and processed.

When a controller is associated with a View (the view should be passed in to its constructor) it will try and call a hook in the View called _attach_callbacks. See AbstractGladeView for an example of this method.

add_proxy(model=None, widgets=None)[source]

Add a proxy to this view that automatically update a model when the view changes. Arguments:

  • model. the object we are proxing. It can be None if we don’t have a model yet and we want to display the interface and set it up with future models.
  • widgets. the list of widgets that contains model attributes to be proxied. If it is None (or not specified) it will be the whole list of widgets this View has.

This method return a Proxy object that you may want to use to force updates or setting new models. Keep a reference to it since there is no way to get that proxy later on. You have been warned (tm)

attach_slave(name, slave, placeholder_widget=None)[source]

Attaches a slaveview to the current view, substituting the widget specified by placeholder_widget. If placeholder_widget is not specified, an widget with the name specified must exist.

The widget specified must be a eventbox; its child widget will be removed and substituted for the specified slaveview’s toplevel widget:

.-----------------------. the widget that is indicated in the diagram
|window/view (self.view)| as placeholder will be substituted for the
|  .----------------.   | slaveview's toplevel.
|  | eventbox (name)|   |  .-----------------.
|  |.--------------.|      |slaveview (slave)|
|  || placeholder  <----.  |.---------------.|
|  |'--------------'|    \___ toplevel      ||
|  '----------------'   |  ''---------------'|
'-----------------------'  '-----------------'

the original way of attachment (naming the child widget instead of the eventbox) is still supported for compatibility reasons but will print a warning.

check_and_notify_validity(force=False)[source]
connect_multiple(widgets, signal, handler, after=False)[source]

Connect the same handler to the specified signal for a number of widgets.

  • widgets: a list of GtkWidgets
  • signal: a string specifying the signals
  • handler: a callback method
  • after: a boolean; if TRUE, we use connect_after(), otherwise,

connect()

controller = None
detach_slave(name)[source]

Detatch a slave called name from view

disconnect_autoconnected()[source]

Disconnect handlers previously connected with autoconnect_signals()

domain = None
enable_window_controls()[source]

Enables the dialog to have the same controls as a window (eg minimize, maximize and close buttons in its title bar). This method should be called before the window becomes visible.

focus_toplevel()[source]

Focuses the toplevel widget in the view

focus_topmost(widgets=None)[source]

Looks through widgets specified (if no widgets are specified, look through all widgets attached to the view and sets focus to the widget that is rendered in the position closest to the view window’s top and left

  • widgets: a list of widget names to be searched through
force_validation()[source]
get_glade_adaptor()[source]

Special init code that subclasses may want to override.

get_sizegroups()[source]

Get a list of sizegroups for the current view.

get_slave(holder)[source]
get_toplevel()[source]

Returns the toplevel widget in the view

get_topmost_widget(widgets=None, can_focus=False)[source]

A real hack; returns the widget that is most to the left and top of the window.

  • widgets: a list of widget names. If widgets is supplied, it only checks in the widgets in the list; otherwise, it looks at the widgets named in self.widgets, or, if self.widgets is None, looks through all widgets attached to the view.
  • can_focus: boolean, if set only searches through widget that can be focused
get_widget(name)[source]

Retrieves the named widget from the View

gladefile = None
handler_block(widget, signal_name=None)[source]
handler_unblock(widget, signal_name=None)[source]
on_attach(parent)[source]

Hook function called when attach_slave is performed on slave views.

on_startup()[source]

This is a virtual method that can be customized by classes that want to perform additional initalization after a controller has been set for it. If you need this, add this method to your View subclass and BaseController will call it when the controller is set to the proxy.

register_validate_function(function)[source]

The signature of the validate function is:

def function(is_valid):

or, if it is a method:

def function(self, is_valid):

where the ‘is_valid’ parameter is True if all the widgets have valid data or False otherwise.

set_controller(controller)[source]

Sets the view’s controller, checking to see if one has already been set before.

show(*args)[source]

Shows the toplevel widget

show_all(*args)[source]

Shows all widgets attached to the toplevel widget

show_and_loop(parent=None)[source]

Runs show() and runs the GTK+ event loop. If the parent argument is supplied and is a valid view, this view is set as a transient for the parent view

Parameters:parent
toplevel = None
toplevel_name = None
widgets = []

wizard Module

class kiwi.ui.wizard.PluggableWizard(title, first_step, size=None, edit_mode=False)[source]

Bases: kiwi.ui.delegates.GladeDelegate

Wizard controller and view class

cancel(*args)[source]
disable_back()[source]

Disables the back button in the wizard.

disable_finish()[source]

Disables the finish button in the wizard.

disable_next()[source]

Disables the next button in the wizard.

enable_back()[source]

Enables the back button in the wizard.

enable_finish()[source]

Enables the finish button in the wizard.

enable_next()[source]

Enables the next button in the wizard.

finish()[source]
gladefile = 'PluggableWizard'
go_to_next()[source]
on_cancel_button__clicked(button)[source]
on_next_button__clicked(button)[source]
on_ok_button__clicked(button)[source]
on_previous_button__clicked(button)[source]
retval = None
set_message(message)[source]

Set message for nofitication. :param message:

update_view()[source]
class kiwi.ui.wizard.WizardStep(previous=None, header=None)[source]

This class must be inherited by the steps

has_next_step()[source]
has_previous_step()[source]
next_step()[source]
post_init()[source]

A virtual method that must be defined on child when it’s necessary. This method will be called right after the change_step method on PluggableWizard is concluded for the current step.

previous_step()[source]
validate_step()[source]

A hook called always when changing steps. If it returns False we can not go forward.