本文整理汇总了Python中stoqlib.database.queryexecuter.QueryExecuter.set_order_by方法的典型用法代码示例。如果您正苦于以下问题:Python QueryExecuter.set_order_by方法的具体用法?Python QueryExecuter.set_order_by怎么用?Python QueryExecuter.set_order_by使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.database.queryexecuter.QueryExecuter
的用法示例。
在下文中一共展示了QueryExecuter.set_order_by方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: QueryEntryGadget
# 需要导入模块: from stoqlib.database.queryexecuter import QueryExecuter [as 别名]
# 或者: from stoqlib.database.queryexecuter.QueryExecuter import set_order_by [as 别名]
class QueryEntryGadget(object):
"""This gadget modifies a ProxyEntry to behave like a ProxyComboEntry.
When instanciated, the gadget will remove the entry from the editor, add
a Gtk.HBox on its place, and re-attach the entry to the newly created
hbox. This hbox will also have a button to add/edit a new object.
There are a few advantages in using this instead of a combo:
- There is no need to prefill the combo with all the options, which can
be very slow depending on the number of objects.
- This allows the user to use a better search mechanism, allowing him to
filter using multiple keywords and even candidade keys (like a client
document)
"""
MIN_KEY_LENGTH = 1
LOADING_ITEMS_TEXT = _("Loading items...")
NEW_ITEM_TEXT = _("Create a new item with that name")
NEW_ITEM_TOOLTIP = _("Create a new item")
EDIT_ITEM_TOOLTIP = _("Edit the selected item")
INFO_ITEM_TOOLTIP = _("See info about the selected item")
NO_ITEMS_FOUND_TEXT = _("No items found")
advanced_search = True
selection_only = False
item_editor = None
item_info_dialog = ClientEditor
search_class = None
search_spec = None
search_columns = None
order_by = None
def __init__(self, entry, store, initial_value=None,
parent=None, run_editor=None,
edit_button=None, info_button=None,
search_clause=None):
"""
:param entry: The entry that we should modify
:param store: The store that will be used for database queries
:param initial_value: Initial value for the entry
:param parent: The parent that should be respected when running other
dialogs
"""
super(QueryEntryGadget, self).__init__()
self._parent = parent
self._on_run_editor = run_editor
self._can_edit = False
self._search_clause = search_clause
self.entry = entry
self.entry.set_mode(ENTRY_MODE_DATA)
self.edit_button = edit_button
self.info_button = info_button
self.store = store
# The filter that will be used. This is not really in the interface.
# We will just use it to perform the search.
self._filter = StringSearchFilter('')
self._executer = QueryExecuter(self.store)
self._executer.set_search_spec(self.search_spec)
self._executer.set_filter_columns(self._filter, self.search_columns)
self._executer.set_order_by(self.order_by)
self._last_operation = None
self._source_id = None
self._setup()
self.set_value(initial_value, force=True)
#
# Public API
#
def set_value(self, obj, force=False):
if not force and obj == self._current_obj:
return
obj = self.store.fetch(obj)
if obj is not None:
if hasattr(obj, 'description'):
value = obj.description
else:
value = obj.get_description()
self.entry.prefill([(value, obj)])
self.update_edit_button(Gtk.STOCK_EDIT, self.EDIT_ITEM_TOOLTIP)
else:
value = ''
self.entry.prefill([])
self.update_edit_button(Gtk.STOCK_NEW, self.NEW_ITEM_TOOLTIP)
self._current_obj = obj
self.entry.update(obj)
self.entry.set_text(value)
self._update_widgets()
def set_editable(self, can_edit):
self.entry.set_property('editable', can_edit)
self._update_widgets()
#.........这里部分代码省略.........