garfield.qt Package

garfield.qt.ALIGN_NUMERIC = <PyQt4.QtCore.Alignment object>

Alignment used for numeric values in table widgets. Use this constant as parameter to QtGui.QTableWidgetItem.setTextAlignment().

class garfield.qt.ActionLogHelper(sess, widget, action, get_current_row_item_hook, refresh_hook, action_hooks_loader, context=None)

Bases: object

This class helps setup a table widget with an action. The availability of the action depends on the item that is selected and is determined by querying a list of classes that are registered with the action_hooks_loader. A typical loader is EntryPointLoader.

Activating the action (assuming it was determined to be available) causes the same set of classes to be informed about this event. The registered class instances will typically perform some item specific action. All of this will happen within a transaction on sess. If at least one of the call back functions returns True instead of False, the model will be assumed to be dirty. In that case the transaction is committed and the refresh_hook is called to make sure that the widget (and whatever else depends on the row’s possibly changed state) is updated.

The currently selected row is translated to an item object by calling get_current_row_item_hook without any parameters. This item object is what the registered class instances get passed in.

context is an optional dictionary that will be passed into the constructor of registered classes as keyword arguments.

check_actions_available()

Checks whether the registered hooks are happy with the currently selected item. Called when the item selection changes.

class garfield.qt.CancelTransLogHelper(sess, trans_log_view, trans_log_model, refresh_hook)

Bases: object

current_row_item()
class garfield.qt.DirectionSwitcher(widget, left_pix, right_pix, left_btn, right_btn, direction=2, left_label=None, left_text=u'', right_label=None, right_text=u'')

Bases: object

Manages a set of radio buttons and a label widget and maps them to a logical left and right direction.

LEFT = 1
RIGHT = 2
direction

Direction property’s getter.

reset()

Reset the direction to the chosen default direction.

set_left()
set_right()
switch()

Toggle the direction between LEFT and RIGHT.

class garfield.qt.ExceptionMsgBox(attempted_action=None)

Bases: PyQt4.QtGui.QMessageBox

Displays a critical message box displaying the current exception and trace-back.

set_exception(type_, value, tb)
static show_environment_exception(attempted_action)
static show_given_exception(type_, value, exc_traceback, attempted_action=None)
class garfield.qt.ExtendedItem

Bases: PyQt4.QtGui.QStandardItem

This class extends QStandardItem to distinguish between EditRole and DisplayRole when getting and setting data.

data(role=0)
setData(value, role)
class garfield.qt.HoverTracker(hover_widget)

Bases: PyQt4.QtCore.QObject

Tracks whether the mouse cursor is currently hovering over the widget. Emits the hover(bool, const QWidget&) signal as soon as the state changes. Provides the state as ‘hovering’ property.

eventFilter(event_obj, event)
hover
class garfield.qt.SuppressEnterFilter(widgets)

Bases: PyQt4.QtCore.QObject

Filters events of widgets and suppresses any Return or Enter key events.

eventFilter(_, event)
class garfield.qt.UserHostPasswordPromptDialog(purpose_text=u'', hint_text=u'', username=None, host=None, use_keyring=True, appname=None)

Bases: PyQt4.QtGui.QDialog, garfield.AbstractUserHostPasswordPrompt

show_password_prompt()
garfield.qt.apply_main_widget_defaults(widget)
garfield.qt.get_cash_box_from_cash_box_chooser(sess, cash_box_chooser)
garfield.qt.get_current_drop_down_object(sess, drop_down_list, cls)
garfield.qt.get_current_table_object(sess, table_widget, cls)
garfield.qt.get_location_from_location_chooser(sess, location_chooser)
garfield.qt.get_model_drop_down_selection_data(model, drop_down_list)
garfield.qt.get_model_drop_down_selection_id(model, drop_down_list)
garfield.qt.get_model_table_selection_data(model, table_widget)
garfield.qt.get_model_table_selection_id(model, table_widget)
garfield.qt.get_nonempty_field(edit_widget)

Returns the contents of a line edit widget in case it is non-empty (contains more than one non-whitespace character) or else returns None. The contents is retrieved using get_stripped_field().

garfield.qt.get_nonempty_plaintext_edit(plaintext_edit_widget)

Returns the contents of a plain text edit widget in case it is non-empty (contains more than one non-whitespace character) or else returns None. The contents is retrieved using get_stripped_plaintext_edit().

garfield.qt.get_selection_data(drop_down_list)
garfield.qt.get_selection_id(drop_down_list)
garfield.qt.get_stripped_field(edit_widget)

Returns the contents of a line edit widget as Unicode and with any surrounding spacing stripped.

garfield.qt.get_stripped_plaintext_edit(plaintext_edit_widget)

Returns the contents of a plaintext edit widget as Unicode and with any surrounding spacing stripped.

garfield.qt.get_table_selection_data(table_widget)
garfield.qt.get_table_selection_id(table_widget)
garfield.qt.get_tax_group_from_tax_group_chooser(sess, drop_down_list)
garfield.qt.load_account_admin_app()
garfield.qt.load_accounting_app()
garfield.qt.load_cash_box_log_app()
garfield.qt.load_qt_system_messages(qapp)

Load system messages for the current locale.

garfield.qt.load_snack_account_app()
garfield.qt.message_box_icon_as_pixmap(widget, style, icon_type)

Returns the built-in icon of type icon_type based on style and the parent widget. The icon is returned as an apropriately sized pixmap.

garfield.qt.monetary_to_html_str(val, places=2)
garfield.qt.prepare_monetary_spinbox(spin_box, places=2, _grouping=True, currency_symbol=u'\u20ac')
garfield.qt.refresh_cash_box_chooser_model(sess, cash_box_chooser, location=None, cash_boxes=None)

Update the cash box drop down list cash_box_chooser with a list of all currently existing cash boxes. If location is not None, a cash box for that location is selected by default. If cash_boxes isn’t None, then it is used as the list of cash boxes.

garfield.qt.refresh_cash_box_log_view(cash_box_log_widget, log_list, with_balance=False, mon=<garfield.progress.NullProgressMonitor object>)
garfield.qt.refresh_location_chooser_model(sess, location_chooser, default_location=None)

Update the locations drop down list location_chooser with all available locations. Select the location matching default_location (unless it is None).

garfield.qt.refresh_tax_group_chooser_model(sess, drop_down_list)
garfield.qt.select_last_table_cell(table_widget)
garfield.qt.setup_table_headers(table, headers)

Sets the headers as horizontal, interactively scalable headers of the table widget table.

garfield.qt.table_add_to_end(table_widget, items)

Set the items (where each item is of type QtGui.QTableWidgetItem) as the contents of the newly added last row on table_widget.

garfield.qt.table_set_columns_on_row(table_widget, row_number, items)

Set the items (where each item is of type QtGui.QTableWidgetItem) as the contents of row_number on table_widget.

garfield.qt.update_model_with_taxes(sess, model, taxes)

Updates model with all taxes in the dictionary taxes. The dictionary taxes is expected to contain tax id keys with their matching tax amount as value. Taxes where the tax amount is zero are skipped. The database session sess is used to look-up details about the taxes.

garfield.qt.update_table_headers(table)

Update the horizontal headers of a table widget.

Resizes the header widths based on the current contents of the underlying model.

garfield.qt.verify_constraints_for_button(constraints_and_widgets, btn, ok_style='', warn_style='background-color: red', warn=True)

Verifies that all constraints are fulfilled and enables the button accordingly. In case of failed constraints, the warn_style is applied to all widgets that are associated with failed constraints. In the special (assumedly initial) case where all constraints are failed, the warn_style is not applied at all.

garfield.qt.account_admin Module

class garfield.qt.account_admin.AccountAdminDialog(parent, sess, **_)

Bases: PyQt4.QtGui.QDialog

add_misc_change()
cash_check_valid()
cash_post()
cash_reset()
misc_check_valid()
misc_reset()
refresh_cash_box_chooser_model()
refresh_user_chooser_model()
refresh_user_transaction_model()
show()

Show the dialog, but refresh the various models first.

garfield.qt.accounting Module

class garfield.qt.accounting.AccountingDialog(parent, sess, location, environment_sess, **_)

Bases: PyQt4.QtGui.QDialog

on_create_subtotals()
refresh_location_chooser_model()
refresh_subtotal_chooser_model()
refresh_subtotal_views()
showEvent(ev)

Refresh the various models on a non-spontaneous show event.

warn_live_view(warn)

If warn is True, a visual indicator is activated, that warns the user that the data is live data that is not yet stored within a subtotal.

class garfield.qt.accounting.AccountingSubtotalDetailsDialog(parent)

Bases: PyQt4.QtGui.QDialog

class garfield.qt.accounting.CashBoxesAccountingWidget(parent, sess)

Bases: PyQt4.QtGui.QWidget

current_cash_box
new_cash_box()

This proxy eats any arguments this slot might otherwise receive.

new_cash_box_filter()

This proxy eats any arguments this slot might otherwise receive.

refresh_cash_box_chooser_model(mon)
refresh_cash_box_filter_chooser(mon=<garfield.progress.NullProgressMonitor object>)
refresh_cash_box_subtotal_view(mon=<garfield.progress.NullProgressMonitor object>)
refresh_models(subtotal, mon, location, **_)
class garfield.qt.accounting.UserAccountsAccountingWidget(parent, sess)

Bases: PyQt4.QtGui.QWidget

refresh_models(subtotal, mon, **_)
garfield.qt.accounting.deposit_user_trans_balance(sess, subtotal, summary_table, state)
garfield.qt.accounting.misc_user_trans_balance(sess, subtotal, summary_table, state)
garfield.qt.accounting.opening_closing_user_trans_balance(sess, subtotal, summary_table, state)

garfield.qt.cash_box_log Module

class garfield.qt.cash_box_log.CancelCashBoxLogHelper(sess, cash_box_log, refresh_hook, parent, environment_sess)

Bases: object

current_row_item()
class garfield.qt.cash_box_log.CashBoxLogDialog(parent, sess, environment_sess, location, **_)

Bases: PyQt4.QtGui.QDialog

refresh_cash_box_chooser_model()
refresh_cash_box_log_view()
refresh_location_chooser_model()
showEvent(ev)

Refresh the various models on a non-spontaneous show event.

garfield.qt.cash_box_log.row_to_cash_box_log_row(sess, cash_box_log)

garfield.qt.cash_payment Module

Provides dialogs for creating and viewing cash payments/deposits.

class garfield.qt.cash_payment.CashPaymentCreationDialog(parent, sess, location, description=None, description_readonly=False, signee=None, signee_readonly=False, payee=None, payee_readonly=False, amount=None, amount_readonly=False)

Bases: PyQt4.QtGui.QDialog

amount
cash_box
check_valid_payment()
description
payee
signee
class garfield.qt.cash_payment.CashPaymentDetailsDialog(parent, sess, payee, signee, description, amount, cash_box_log_entry, receipt_latex_file, receipt_printer, receipt_printer_options, is_cancellation, is_incoming)

Bases: PyQt4.QtGui.QDialog

print_receipt()
garfield.qt.cash_payment.print_receipt(parent, payee, signee, description, amount, cash_box_log_entry, is_cancellation, is_incoming, receipt_latex_file, receipt_printer, receipt_printer_options)

garfield.qt.completion Module

Provides a completion functionality with a similar purpose as QCompleter, but with improved flexibility regarding completion matching.

class garfield.qt.completion.ArrowWidget(parent)

Bases: PyQt4.QtGui.QWidget

This class displays a downwards pointing indicator arrow and emits a clicked signal when pressed.

It provides set_relative_to() for positioning the arrow at the right border of a parent widget’s rectangle.

arrow_width = 20
clicked

This signal is emitted when the arrow is clicked. (On mouse down.)

mousePressEvent(_mouse_event)
mouseReleaseEvent(_mouse_event)
paintEvent(_paint_event)
set_relative_to(rect)

Adjusts the widgets geometry so that the widget is positioned at the right border of the rectangle.

class garfield.qt.completion.FlexibleCompleter(line_edit, completer_clb=None, max_visible_items=7)

Bases: PyQt4.QtCore.QObject

The FlexibleCompleter is heavily based on Qt4’s QCompleter. It connects and partially overlays the edit field line_edit, which should be a QtGui.QLineEdit.

As soon as text is entered into the text edit widget, the completer callback completer_clb is called to look for items that match the entered text. The callback is called with the search string as its only parameter.

The callback is responsible for searching for matches and feeding the result into the completer’s completion_model. The model is then displayed in a list widget for the user to choose from. At most max_visible_items will be displayed at the same time.

In case the completer callback finds a perfect match, it may want to also set the completion_index to the apropriate item in the completion model. Otherwise, the completion_index will be set as soon as the user activates an entry in the chooser widget.

The implementation carefully avoids adding any strong Python references to the passed-in objects, thus avoiding tricky circular dependencies.

changed_selection

This signal is emitted as soon as the completion index is changed. The new completion_index is passed as the (only) parameter.

Note that the signal is also emitted in case the selection was cleared. In that case the passed completion index is QtCore.QModelIndex() - which is an invalid index. Use QtCore.QModelIndex.isInvalid() to check.

completion_index

The index to the currently selected item in the completion model. Is invalid in case no item is currently selected.

completion_model

The current completion model. Contains all elements that match the text entered into the text edit widget.

Is expected to be set and updated by the completer callback. (The FlexibleCompleter will only read the model and use it display completions to the user.)

See:QtGui.QStandardItemModel
eventFilter(event_obj, event)

Called for all events sent to the list view and line edit widgets.

As soon as the list view is visible, Qt targets all line edit events at the list view instead. (This is due to line edit being a focus proxy for the list view.) This function forwards some of those events back to the line edit widget, so that input is still possible.

show_completions()

Shows the list of possible completions (i.e. completion_model). Only has an effect if the edit widget currently has focus and the model is non-empty.

showing_completions

This signal is emitted as soon as the chooser widget is displayed.

text_changed(text)

Slot that is triggered as soon as the text field’s contents changes. May be explicitly called in case the text field’s contents was changed programmatically.

class garfield.qt.completion.OverlayedArrowLayout(parent)

Bases: PyQt4.QtGui.QLayout

This custom overlay class is responsible for positioning a single arrow widget. By using a layout, the arrow widget can be injected into a normal widget while still properly receiving geometry information.

addItem(item)
count()
itemAt(idx)
setGeometry(rect)
takeAt(idx)

garfield.qt.designerplugin Module

class garfield.qt.designerplugin.AbstractDesignerPlugin(parent=None)

Bases: PyQt4.QtDesigner.QPyDesignerCustomWidgetPlugin

domXml()
group()
icon()
initialize(_formEditor)
isContainer()
isInitialized()
whatsThis()

garfield.qt.dialog Module

This package provides flexible dialogs.

class garfield.qt.dialog.ExtendedMessageDialog(parent, message_title=None, message_text=None, extended_text=None, extended_widget=None, icon_type=12)

Bases: PyQt4.QtGui.QDialog

This is a message dialog that provides a place for an additional widget extended_widget with the description extended_text.

extended_text

This property provides the dialog’s description label for the additional widget.

extended_widget

This property provides access to the additional widget.

message_text

This property provides the dialog’s main message.

message_title

This property provides the dialog’s title.

garfield.qt.pdb Module

This module provides a convenience function for calling into pdb from a Qt application.

The typical usage is:

import garfield.qt.pdb; garfield.qt.pdb.set_trace
garfield.qt.pdb.set_trace()

garfield.qt.printer Module

This package provides dialogs for printing files.

class garfield.qt.printer.PrintCopiesDialog(parent, message_title, message_text, num_copies=1, preview_files=None)

Bases: garfield.qt.dialog.ExtendedMessageDialog

Provides a dialog that asks the user whether to print a document and how many copies to make.

num_copies
show_files()
update_print_btn()

garfield.qt.progress Module

This package provides a progress dialog.

class garfield.qt.progress.ProgressDialog(parent)

Bases: PyQt4.QtGui.QDialog

Provides a modal progress dialog that implements IProgressMonitor. Can be used as a context manager according to PEP 343 to make sure that the progress dialog is closed in the event of exceptions.

get_progress_monitor()

garfield.qt.resources Module

garfield.qt.resources.get_resource_path(fn)
garfield.qt.resources.qrc_resolve_path(qrc_fn, res_path, qrc_path=None)

Use a Qt resource file to resolve a resource path to the underlying file- system path.

@param qrc_fn is the Qt resource file path relative to which, the resource
path will be resolved.

@param res_path is the “virtual” resource path that will be translated. @param qrc_path optionally specifies the absolute path that will be used @return: the file system path or None in case of an error.

garfield.qt.resources.ui_hardcode_resources(ui_fn, fp_out, qrc_path=None)

Updates all references to Qt resources in a Qt UI file to point to the paths of the resources within the file-system instead. Unless the resource file specifies absolute paths, the resulting paths will be relative to qrc_path.

garfield.qt.resources.uic_load_ui(fn, parent)

Loads a UI file.

garfield.qt.snack_account Module

class garfield.qt.snack_account.SnackAccountDialog(parent, sess, user, location, **_)

Bases: PyQt4.QtGui.QDialog

cash_post()

Perform a cash transfer. Assumes that all fields are properly set.

cash_reset()

Reset all fields relevant to the cash transfer back to the default values.

refresh_cash_box_chooser_model()

Update the cash box drop down field with a list of all currently existing cash boxes. Pre-selects the last cash box that matches the current location.

Stores the index of the selected cash box for easy later resetting.

refresh_other_chooser_model()

Update the drop-down field of available people to transfer money to. Lists all valid accounts except the current account.

refresh_transaction_model()
show()

Show the dialog, but refresh the various models first.

transfer_post()

Perform a person to person cash transfer. Assumes all fields relevant to the transfer have valid values.

transfer_reset()

Reset all fields relevant to the person to person cash transfer back to the default values.

garfield.qt.starter_app Module

class garfield.qt.starter_app.AppChooserDialog(db, sess, **params)

Bases: PyQt4.QtGui.QDialog

show_app(app_name)
class garfield.qt.starter_app.DatabasePasswordPrompt(**kwargs)

Bases: garfield.qt.UserHostPasswordPromptDialog

password_callback()
password_incorrect_callback()
class garfield.qt.starter_app.ErrorDialog(text)

Bases: PyQt4.QtGui.QMessageBox

static show_text(text)
garfield.qt.starter_app.build_standalone_app(requested_app_name, sess, user, **params)
garfield.qt.starter_app.gather_qt_apps()
garfield.qt.starter_app.main()
garfield.qt.starter_app.show_startup_notifications(session, user)
garfield.qt.starter_app.wintitle_add_garfield_ver(sess, win)

Appends Garfield version information to the title of the window win. Also appends an instance name in case this isn’t a production instance.

garfield.qt.user_transactions Module

class garfield.qt.user_transactions.UserTransactionsModel

Bases: PyQt4.QtCore.QAbstractTableModel

columnCount(_parent=<PyQt4.QtCore.QModelIndex object>)
data(index, role=0)
headerData(section, orientation, role=0)
last_balance
rowCount(_parent=<PyQt4.QtCore.QModelIndex object>)
transactions
class garfield.qt.user_transactions.UserTransactionsViewHelper(table_model, table_view, balance_label=None)

Bases: PyQt4.QtCore.QObject

refresh_model_and_view(transactions)
view_updated