base Package

base Package

columns Module

Special columns definition for kiwi lists

class stoqlib.gui.base.columns.AccessorColumn(attribute, accessor, *args, **kwargs)[source]

Bases: kiwi.ui.objectlist.Column

get_attribute(instance, name, default=None)[source]

dialogs Module

Basic dialogs definition

class stoqlib.gui.base.dialogs.RunnableView[source]

A mixin class for any View or GladeDelegate that offers run/close

retval = None
close(*args)[source]

Handles action to be performed when window is closed.

destroy()[source]
run()[source]

Handles action to be performed when window is opened. Defaults to _open(), which blocks in a mainloop. Returns the value of the retval attribute.

get_current_toplevel()[source]
set_transient_for(window)[source]
class stoqlib.gui.base.dialogs.BasicDialog(main_label_text=None, title=' ', header_text='', size=None, hide_footer=False, delete_handler=None, help_section=None)[source]

Bases: kiwi.ui.delegates.GladeDelegate, stoqlib.gui.base.dialogs.RunnableView

Abstract class that offers a Dialog with two buttons. It should be subclassed and customized.

domain = 'stoq'
help_section = None
confirm()[source]
cancel()[source]
enable_ok()[source]
disable_ok()[source]
set_ok_label(text, icon=None)[source]
set_cancel_label(text, icon=None)[source]
set_confirm_widget(widget)[source]

Enables widget as a confirm widget, the dialog will be closed as confirmed if the widget is activated. :param widget: a widget

add(widget)[source]
action_area
set_message(message, message_type=None)[source]

Sets a message for this editor :param message: message to add or None to remove previous message :param message_type: type of message to add

on_ok_button__clicked(button)[source]
on_cancel_button__clicked(button)[source]
stoqlib.gui.base.dialogs.get_current_toplevel()[source]
stoqlib.gui.base.dialogs.add_current_toplevel(toplevel)[source]
stoqlib.gui.base.dialogs.get_dialog(parent, dialog, *args, **kwargs)[source]

Returns a dialog.

Parameters:
  • parent – the window which is opening the dialog
  • dialog – the dialog class or instance
  • args – custom positional arguments
  • kwargs – custom keyword arguments
stoqlib.gui.base.dialogs.has_modal_window()[source]

Verifies if any of the currently open windows are modal.

Returns:True if there are any modal windows open, otherwise False
stoqlib.gui.base.dialogs.run_dialog(dialog, parent=None, *args, **kwargs)[source]

Runs a dialog and return the return value of it. If dialog is a class it will be instantiated before running the dialog.

Parameters:
  • dialog – the dialog class
  • parent – parent of the dialog
  • args – custom positional arguments
  • kwargs – custom keyword arguments
stoqlib.gui.base.dialogs.run_dialog_internal(dialog, parent, toplevel)[source]
stoqlib.gui.base.dialogs.push_fullscreen(window)[source]
stoqlib.gui.base.dialogs.pop_fullscreen(window)[source]
class stoqlib.gui.base.dialogs.DialogSystemNotifier[source]
info(short, description)[source]
warning(short, description, *args, **kwargs)[source]
error(short, description)[source]
yesno(text, default=None, *verbs)[source]

gtkadds Module

Some extra methods to deal with gtk/kiwi widgets

stoqlib.gui.base.gtkadds.change_button_appearance(button, icon=None, text=None)[source]
stoqlib.gui.base.gtkadds.set_bold(widget)[source]
stoqlib.gui.base.gtkadds.button_set_image_with_label(button, stock_id, text)[source]

Sets an image above the text :param button: :param stock_id: :param text:

lists Module

List management for common dialogs.

class stoqlib.gui.base.lists.ModelListSlave(parent=None, store=None, orientation=None, reuse_store=False)[source]

Bases: kiwi.ui.listdialog.ListSlave

model_type = None
editor_class = None
columns = None
populate()[source]
add_item()[source]
remove_item(item)[source]
edit_item(item)[source]
run_dialog(dialog_class, *args, **kwargs)[source]

A special variant of run_dialog which deletes objects when a store is reused, it’s safe to use when it’s disabled, so always use this in your run_editor hook

run_editor(store, model)[source]

This can be override by a subclass who wants to send in custom arguments to the editor.

delete_model(model, store)[source]

Deletes the model in a store. This can be overriden by a subclass which is useful when you have foreign keys which depends on this class. :param model: model to delete :param store: the store to delete the model within

class stoqlib.gui.base.lists.ModelListDialog(store=None, reuse_store=False)[source]

Bases: stoqlib.gui.base.dialogs.BasicDialog

A dialog which displays all items in a table and allows you to add and remove items from it

Variables:
  • columns – a list of kiwi.ui.objectlist.Columns
  • size – a two sized tuple; (width, height) or None
  • title – window title
list_slave_class = None
columns = None
size = None
title = None
class stoqlib.gui.base.lists.AdditionListSlave(store, columns=None, editor_class=None, klist_objects=None, visual_mode=False, restore_name=None, tree=False)[source]

Bases: stoqlib.gui.search.searchslave.SearchSlave

A slave that offers a simple list and its management.

This slave also has the option to display a small message right next to the buttons

domain = 'stoq'
toplevel_name = 'AdditionListSlave'
gladefile = 'AdditionListSlave'
widgets = ('add_button', 'delete_button', 'klist', 'list_vbox', 'edit_button')
get_items()[source]
get_columns()[source]
run_editor(model)[source]

This can be overriden to provide a custom run_dialog line, or a conversion function for the model

delete_model(model)[source]

Deletes a model, can be overridden in subclass :param model: model to delete

add_extra_button(label=None, stock=None)[source]

Add an extra button on the this slave

The extra button will be appended at the end of the button box, the one containing the add/edit/delete buttons

Parameters:
  • label – label of the button, can be None if stock is passed
  • stock – stock label of the button, can be None if label is passed
  • returns – the button added
Return type:

gtk.Button

set_message(message, details_callback=None)[source]

Display a simple message on a label, next to the add, edit, delete buttons :param message: a message with properly escaped markup

clear_message()[source]
get_selection()[source]
hide_add_button()[source]
hide_edit_button()[source]
hide_del_button()[source]
set_editor(editor_class)[source]
on_klist__row_activated(*args)[source]
on_klist__selection_changed(*args)[source]
on_add_button__clicked(button)[source]
on_edit_button__clicked(button)[source]
on_delete_button__clicked(button)[source]
class stoqlib.gui.base.lists.SimpleListDialog(columns, objects, hide_cancel_btn=True, title='', multiple=True, header_text='')[source]

Bases: stoqlib.gui.base.dialogs.BasicDialog

size = (500, 400)
setup_slave(columns, objects, selection_mode)[source]
get_selection()[source]
confirm()[source]

messagebar Module

class stoqlib.gui.base.messagebar.MessageBar(message, message_type=None)[source]

Bases: gtk.InfoBar

set_message(message, message_type=None)[source]

Sets or update a new message in the message bar. Can also be used to change the message type

Parameters:
  • message – the message to be displayed
  • message_type – defines the color and urgency of a message. One of gtk.MESSAGE_* .

slaves Module

Basic slave definitions

class stoqlib.gui.base.slaves.NoteSlave(store, model, visual_mode=False)[source]

Bases: stoqlib.gui.editors.baseeditor.BaseEditorSlave

Slave store general notes. The model must have an attribute ‘notes’ to work.

gladefile = 'NoteSlave'
proxy_widgets = ('notes',)
setup_proxies()[source]

wizards Module

Base classes for wizards

class stoqlib.gui.base.wizards.WizardStep(previous=None, header=None)[source]

This class must be inherited by the steps

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.

has_next_step()[source]
has_previous_step()[source]
previous_step()[source]
validate_step()[source]

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

class stoqlib.gui.base.wizards.PluggableWizard(title, first_step, size=None, edit_mode=False)[source]

Bases: kiwi.ui.delegates.GladeDelegate

Wizard controller and view class

domain = 'stoq'
gladefile = 'PluggableWizard'
on_next_button__clicked(button)[source]
on_ok_button__clicked(button)[source]
on_previous_button__clicked(button)[source]
on_cancel_button__clicked(button)[source]
update_view()[source]
enable_next()[source]

Enables the next button in the wizard.

disable_next()[source]

Disables the next button in the wizard.

enable_back()[source]

Enables the back button in the wizard.

disable_back()[source]

Disables the back button in the wizard.

enable_finish()[source]

Enables the finish button in the wizard.

disable_finish()[source]

Disables the finish button in the wizard.

enable_cancel()[source]

Enables the cancel button in the wizard.

disable_cancel()[source]

Disables the cancel button in the wizard.

set_message(message)[source]

Set message for nofitication. :param message:

cancel(*args)[source]
finish()[source]
go_to_next()[source]
get_current_step()[source]
go_to_step(step)[source]
class stoqlib.gui.base.wizards.BaseWizardStep(store, wizard, previous=None)[source]

Bases: stoqlib.gui.base.wizards.WizardStep, kiwi.ui.delegates.GladeSlaveDelegate

A wizard step base class definition

domain = 'stoq'
gladefile = None
class stoqlib.gui.base.wizards.WizardEditorStep(store, wizard, model=None, previous=None)[source]

Bases: stoqlib.gui.editors.baseeditor.BaseEditorSlave, stoqlib.gui.base.wizards.WizardStep

A wizard step base class definition used when we have a model to be edited or created

class stoqlib.gui.base.wizards.BaseWizard(store, first_step, model=None, title=None, size=None, edit_mode=False)[source]

Bases: stoqlib.gui.base.wizards.PluggableWizard, stoqlib.gui.base.dialogs.RunnableView

A wizard base class definition

help_section = None
need_cancel_confirmation = False

if we need to ask the user if he really wants to cancel the dialog if there are any changes done that would be lost otherwise

size = ()
title = None
set_help_section(section)[source]
cancel()[source]
quit_if_last(*args)[source]

A delete handler method for wizards

refresh_next(validation_value)[source]
close()[source]
has_changes()[source]

Check if there are changes on this wizard

By default we will check if there’re any pending changes on store and that information will be used by need_cancel_confirmation

on_toplevel__delete_event(widget, *args, **kwargs)[source]
on_toplevel__response(dialog, response, *args, **kwargs)[source]