本文整理匯總了Python中kiwi.ui.widgets.list.SummaryLabel.set_value方法的典型用法代碼示例。如果您正苦於以下問題:Python SummaryLabel.set_value方法的具體用法?Python SummaryLabel.set_value怎麽用?Python SummaryLabel.set_value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類kiwi.ui.widgets.list.SummaryLabel
的用法示例。
在下文中一共展示了SummaryLabel.set_value方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ProductComponentSlave
# 需要導入模塊: from kiwi.ui.widgets.list import SummaryLabel [as 別名]
# 或者: from kiwi.ui.widgets.list.SummaryLabel import set_value [as 別名]
class ProductComponentSlave(BaseEditorSlave):
gladefile = 'ProductComponentSlave'
model_type = TemporaryProductComponent
proxy_widgets = ['production_time']
def __init__(self, store, product=None, visual_mode=False):
self._product = product
self._remove_component_list = []
BaseEditorSlave.__init__(self, store, model=None, visual_mode=visual_mode)
self._setup_widgets()
def _get_columns(self):
return [Column('code', title=_(u'Code'), data_type=int,
expander=True, sorted=True),
Column('quantity', title=_(u'Quantity'),
data_type=Decimal),
Column('unit', title=_(u'Unit'), data_type=str),
Column('description', title=_(u'Description'),
data_type=str, expand=True),
Column('category', title=_(u'Category'), data_type=str),
# Translators: Ref. is for Reference (as in design reference)
Column('design_reference', title=_(u'Ref.'), data_type=str),
Column('production_cost', title=_(u'Production Cost'),
format_func=get_formatted_cost, data_type=currency),
Column('total_production_cost', title=_(u'Total'),
format_func=get_formatted_cost, data_type=currency),
]
def _setup_widgets(self):
component_list = list(self._get_products())
if component_list:
self.component_combo.prefill(component_list)
else:
self.sort_components_check.set_sensitive(False)
self.component_tree.set_columns(self._get_columns())
self._populate_component_tree()
self.component_label = SummaryLabel(
klist=self.component_tree,
column='total_production_cost',
label='<b>%s</b>' % api.escape(_(u'Total:')),
value_format='<b>%s</b>')
self.component_label.show()
self.component_tree_vbox.pack_start(self.component_label, False)
self.info_label.set_bold(True)
self._update_widgets()
if self.visual_mode:
self.component_combo.set_sensitive(False)
self.add_button.set_sensitive(False)
self.sort_components_check.set_sensitive(False)
def _get_products(self, sort_by_name=True):
# FIXME: This is a kind of workaround until we have the
# SQLCompletion funcionality, then we will not need to sort the
# data.
if sort_by_name:
attr = ProductFullStockView.description
else:
attr = ProductFullStockView.category_description
products = []
for product_view in self.store.find(ProductFullStockView).order_by(attr):
if product_view.product is self._product:
continue
description = product_view.get_product_and_category_description()
products.append((description, product_view.product))
return products
def _update_widgets(self):
has_selected = self.component_combo.read() is not None
self.add_button.set_sensitive(has_selected)
has_selected = self.component_tree.get_selected() is not None
self.edit_button.set_sensitive(has_selected)
self.remove_button.set_sensitive(has_selected)
# FIXME: This is wrong. Summary label already calculates the total. We
# are duplicating this.
value = self.get_component_cost()
self.component_label.set_value(get_formatted_cost(value))
if not self._validate_components():
self.component_combo.set_sensitive(False)
self.add_button.set_sensitive(False)
self.edit_button.set_sensitive(False)
self.remove_button.set_sensitive(False)
self.info_label.set_text(_(u"This product is being produced. "
"Can't change components."))
def _populate_component_tree(self):
self._add_to_component_tree()
def _get_components(self, product):
for component in self.store.find(ProductComponent, product=product):
yield TemporaryProductComponent(product=component.product,
component=component.component,
quantity=component.quantity,
design_reference=component.design_reference)
#.........這裏部分代碼省略.........