当前位置: 首页>>代码示例>>Python>>正文


Python SummaryLabel.show方法代码示例

本文整理汇总了Python中kiwi.ui.widgets.list.SummaryLabel.show方法的典型用法代码示例。如果您正苦于以下问题:Python SummaryLabel.show方法的具体用法?Python SummaryLabel.show怎么用?Python SummaryLabel.show使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kiwi.ui.widgets.list.SummaryLabel的用法示例。


在下文中一共展示了SummaryLabel.show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _setup_summary_labels

# 需要导入模块: from kiwi.ui.widgets.list import SummaryLabel [as 别名]
# 或者: from kiwi.ui.widgets.list.SummaryLabel import show [as 别名]
 def _setup_summary_labels(self):
     summary_label = SummaryLabel(klist=self.payments_list,
                                  column='paid_value',
                                  label='<b>%s</b>' % api.escape(_(u"Total:")),
                                  value_format='<b>%s</b>')
     summary_label.show()
     self.payments_vbox.pack_start(summary_label, False)
开发者ID:LeonamSilva,项目名称:stoq,代码行数:9,代码来源:renegotiationdetails.py

示例2: _setup_widgets

# 需要导入模块: from kiwi.ui.widgets.list import SummaryLabel [as 别名]
# 或者: from kiwi.ui.widgets.list.SummaryLabel import show [as 别名]
    def _setup_widgets(self):
        self.sales_list.set_columns(self._get_sale_columns())
        self.product_list.set_columns(self._get_product_columns())
        self.services_list.set_columns(self._get_services_columns())
        self.payments_list.set_columns(self._get_payments_columns())
        self.calls_list.set_columns(self._get_calls_columns())
        self.account_list.set_columns(self._get_account_columns())

        self.sales_list.add_list(self.model.get_client_sales())
        self.product_list.add_list(self.model.get_client_products())
        self.services_list.add_list(self.model.get_client_services())
        self.payments_list.add_list(self.model.get_client_payments())
        self.calls_list.add_list(self.model.person.calls)
        self.account_list.add_list(self.model.get_credit_transactions())

        value_format = '<b>%s</b>'
        total_label = "<b>%s</b>" % api.escape(_("Total:"))
        saldo_label = "<b>%s</b>" % api.escape(_("Saldo:"))

        sales_summary_label = SummaryLabel(klist=self.sales_list,
                                           column='total',
                                           label=total_label,
                                           value_format=value_format)
        account_summary_label = SummaryLabel(klist=self.account_list,
                                             column='value',
                                             label=saldo_label,
                                             value_format=value_format)

        sales_summary_label.show()
        account_summary_label.show()
        self.sales_vbox.pack_start(sales_summary_label, False)
        self.account_vbox.pack_start(account_summary_label, False)
开发者ID:marianaanselmo,项目名称:stoq,代码行数:34,代码来源:clientdetails.py

示例3: _setup_widgets

# 需要导入模块: from kiwi.ui.widgets.list import SummaryLabel [as 别名]
# 或者: from kiwi.ui.widgets.list.SummaryLabel import show [as 别名]
    def _setup_widgets(self):
        self.sales_list.set_columns(self._get_sale_columns())
        self.returned_sales_list.set_columns(self._get_returned_sale_columns())
        self.product_list.set_columns(self._get_product_columns())
        self.services_list.set_columns(self._get_services_columns())
        self.work_order_list.set_columns(self._get_work_order_columns())
        self.payments_list.set_columns(self._get_payments_columns())
        self.calls_list.set_columns(self._get_calls_columns())
        self.account_list.set_columns(self._get_account_columns())
        self.sales_list.add_list(self.model.get_client_sales())
        self.returned_sales_list.add_list(self.model.get_client_returned_sales())
        self.product_list.add_list(self.model.get_client_products())
        self.services_list.add_list(self.model.get_client_services())
        self.work_order_list.add_list(self.model.get_client_work_orders())
        self.payments_list.add_list(self.model.get_client_payments())
        self.calls_list.add_list(self.model.person.calls)
        self.account_list.add_list(self.model.get_credit_transactions())
        value_format = '<b>%s</b>'
        total_label = "<b>%s</b>" % api.escape(_("Total:"))
        saldo_label = "<b>%s</b>" % api.escape(_("Balance:"))

        sales_summary_label = SummaryLabel(klist=self.sales_list,
                                           column='total',
                                           label=total_label,
                                           value_format=value_format)
        account_summary_label = SummaryLabel(klist=self.account_list,
                                             column='paid_value',
                                             label=saldo_label,
                                             value_format=value_format,
                                             data_func=lambda p: p.is_outpayment())

        sales_summary_label.show()
        account_summary_label.show()
        self.sales_vbox.pack_start(sales_summary_label, False)
        self.account_vbox.pack_start(account_summary_label, False)
开发者ID:LeonamSilva,项目名称:stoq,代码行数:37,代码来源:clientdetails.py

示例4: _setup_summary_labels

# 需要导入模块: from kiwi.ui.widgets.list import SummaryLabel [as 别名]
# 或者: from kiwi.ui.widgets.list.SummaryLabel import show [as 别名]
 def _setup_summary_labels(self):
     order_summary_label = SummaryLabel(
         klist=self.ordered_items,
         column='total',
         label='<b>%s</b>' % api.escape(_(u"Total")),
         value_format='<b>%s</b>')
     order_summary_label.show()
     self.ordered_vbox.pack_start(order_summary_label, False)
开发者ID:LeonamSilva,项目名称:stoq,代码行数:10,代码来源:purchasedetails.py

示例5: setup_widgets

# 需要导入模块: from kiwi.ui.widgets.list import SummaryLabel [as 别名]
# 或者: from kiwi.ui.widgets.list.SummaryLabel import show [as 别名]
 def setup_widgets(self):
     value_format = '<b>%s</b>'
     total_label = "<b>%s</b>" % api.escape(_("Total:"))
     sales_summary_label = SummaryLabel(klist=self.klist,
                                        column='total',
                                        label=total_label,
                                        value_format=value_format)
     sales_summary_label.show()
     self.pack_start(sales_summary_label, False)
开发者ID:pkaislan,项目名称:stoq,代码行数:11,代码来源:clientdetails.py

示例6: _setup_widgets

# 需要导入模块: from kiwi.ui.widgets.list import SummaryLabel [as 别名]
# 或者: from kiwi.ui.widgets.list.SummaryLabel import show [as 别名]
    def _setup_widgets(self):
        self.product_list.set_columns(self._get_product_columns())
        products = self.store.find(TransferOrderItem, transfer_order=self.model)
        self.product_list.add_list(list(products))

        value_format = '<b>%s</b>'
        total_label = value_format % api.escape(_("Total:"))
        products_summary_label = SummaryLabel(klist=self.product_list,
                                              column='total',
                                              label=total_label,
                                              value_format=value_format)
        products_summary_label.show()
        self.products_vbox.pack_start(products_summary_label, False)
开发者ID:romaia,项目名称:stoq,代码行数:15,代码来源:transferorderdialog.py

示例7: _setup_summary_labels

# 需要导入模块: from kiwi.ui.widgets.list import SummaryLabel [as 别名]
# 或者: from kiwi.ui.widgets.list.SummaryLabel import show [as 别名]
    def _setup_summary_labels(self):
        value_format = "<b>%s</b>"
        total_label = "<b>%s</b>" % api.escape(_("Total:"))
        total_summary_label = SummaryLabel(klist=self.payments_list,
                                           column='value',
                                           label=total_label,
                                           value_format=value_format)
        total_summary_label.show()
        self.payments_vbox.pack_start(total_summary_label, False)

        total_label = "<b>%s</b>" % api.escape(_("Total paid:"))
        total_paid_summary_label = SummaryLabel(klist=self.payments_list,
                                                column='paid_value',
                                                label=total_label,
                                                value_format=value_format)
        total_paid_summary_label.show()
        self.payments_vbox.pack_start(total_paid_summary_label, False)

        total_label = "<b>%s</b>" % api.escape(_("Total:"))
        transaction_summary_label = SummaryLabel(
            klist=self.stock_transactions_list,
            column='total',
            label=total_label,
            value_format=value_format)
        transaction_summary_label.show()
        self.stock_transactions_vbox.pack_start(transaction_summary_label, False)

        total_label = "<b>%s</b>" % api.escape(_("Total:"))
        sale_summary_label = SummaryLabel(klist=self.sales_list,
                                          column='total',
                                          label=total_label,
                                          value_format=value_format)
        sale_summary_label.show()
        self.sales_vbox.pack_start(sale_summary_label, False)
开发者ID:LeonamSilva,项目名称:stoq,代码行数:36,代码来源:costcenterdialog.py

示例8: _setup_widgets

# 需要导入模块: from kiwi.ui.widgets.list import SummaryLabel [as 别名]
# 或者: from kiwi.ui.widgets.list.SummaryLabel import show [as 别名]
    def _setup_widgets(self):
        self.receiving_list.set_columns(self._get_receiving_columns())
        self.sales_list.set_columns(self._get_sale_columns())
        self.transfer_list.set_columns(self._get_transfer_columns())
        self.loan_list.set_columns(self._get_loan_columns())
        self.decrease_list.set_columns(self._get_decrease_columns())

        items = self.store.find(ReceivingItemView, sellable_id=self.model.id)

        self.receiving_list.add_list(list(items))

        items = self.store.find(SaleItemsView, sellable_id=self.model.id)
        self.sales_list.add_list(list(items))

        items = self.store.find(TransferOrderItem, sellable_id=self.model.id)
        self.transfer_list.add_list(list(items))

        items = self.store.find(LoanItemView, sellable_id=self.model.id)
        self.loan_list.add_list(list(items))

        items = self.store.find(StockDecreaseItemsView, sellable=self.model.id)
        self.decrease_list.add_list(list(items))

        value_format = '<b>%s</b>'
        total_label = "<b>%s</b>" % api.escape(_("Total:"))
        receiving_summary_label = SummaryLabel(klist=self.receiving_list,
                                               column='quantity',
                                               label=total_label,
                                               value_format=value_format)
        receiving_summary_label.show()
        self.receiving_vbox.pack_start(receiving_summary_label, False)

        sales_summary_label = SummaryLabel(klist=self.sales_list,
                                           column='quantity',
                                           label=total_label,
                                           value_format=value_format)
        sales_summary_label.show()
        self.sales_vbox.pack_start(sales_summary_label, False)

        transfer_summary_label = SummaryLabel(klist=self.transfer_list,
                                              column='quantity',
                                              label=total_label,
                                              value_format=value_format)
        transfer_summary_label.show()
        self.transfer_vbox.pack_start(transfer_summary_label, False)

        loan_summary_label = SummaryLabel(klist=self.loan_list,
                                          column='quantity',
                                          label=total_label,
                                          value_format=value_format)
        self.loan_vbox.pack_start(loan_summary_label, False)

        decrease_summary_label = SummaryLabel(klist=self.decrease_list,
                                              column='quantity',
                                              label=total_label,
                                              value_format=value_format)
        decrease_summary_label.show()
        self.decrease_vbox.pack_start(decrease_summary_label, False)
开发者ID:romaia,项目名称:stoq,代码行数:60,代码来源:productstockdetails.py

示例9: PurchaseFinishProductListStep

# 需要导入模块: from kiwi.ui.widgets.list import SummaryLabel [as 别名]
# 或者: from kiwi.ui.widgets.list.SummaryLabel import show [as 别名]
class PurchaseFinishProductListStep(WizardEditorStep):
    gladefile = 'PurchaseFinishProductListStep'
    model_type = Settable
    proxy_widgets = ()

    def __init__(self, store, wizard, model):
        WizardEditorStep.__init__(self, store, wizard, model)
        self._setup_widgets()

    def _setup_widgets(self):
        self.product_list.set_columns(self._get_columns())
        items = PurchaseItemView.find_by_purchase(self.store, self.model.purchase)
        self.product_list.add_list(items)

        self._setup_summary()

    def _setup_summary(self):
        self.summary = SummaryLabel(klist=self.product_list,
                                    column='total_received',
                                    value_format='<b>%s</b>')
        self.summary.show()
        self.vbox1.pack_start(self.summary, expand=False)

    def _get_columns(self):
        return [Column('description', title=_('Description'),
                       data_type=str, expand=True, searchable=True),
                Column('quantity', title=_('Ordered'), data_type=int,
                       width=90, format_func=format_quantity, expand=True),
                Column('quantity_received', title=_('Received'), data_type=int,
                       width=110, format_func=format_quantity),
                Column('sellable.unit_description', title=_('Unit'),
                       data_type=str, width=50),
                Column('cost', title=_('Cost'), data_type=currency, width=90),
                Column('total_received', title=_('Total'), data_type=currency,
                       width=100)]

    #
    # WizardStep hooks
    #

    def next_step(self):
        return PurchaseFinishPaymentAdjustStep(self.store, self.wizard,
                                               self.model, self)

    def has_previous_step(self):
        return False
开发者ID:LeonamSilva,项目名称:stoq,代码行数:48,代码来源:purchasefinishwizard.py

示例10: _setup_widgets

# 需要导入模块: from kiwi.ui.widgets.list import SummaryLabel [as 别名]
# 或者: from kiwi.ui.widgets.list.SummaryLabel import show [as 别名]
    def _setup_widgets(self):
        self.product_list.set_columns(self._get_product_columns())
        products = self.store.find(ReceivingOrderItem,
                                   receiving_order_id=self.model.id)
        self.product_list.add_list(list(products))

        value_format = '<b>%s</b>'
        total_label = value_format % api.escape(_("Total:"))
        products_summary_label = SummaryLabel(klist=self.product_list,
                                              column='total',
                                              label=total_label,
                                              value_format=value_format)

        products_summary_label.show()
        self.products_vbox.pack_start(products_summary_label, False)

        label = self.print_labels.get_children()[0]
        label = label.get_children()[0].get_children()[1]
        label.set_label(_(u'Print labels'))
开发者ID:romaia,项目名称:stoq,代码行数:21,代码来源:receivingdialog.py

示例11: _setup_widgets

# 需要导入模块: from kiwi.ui.widgets.list import SummaryLabel [as 别名]
# 或者: from kiwi.ui.widgets.list.SummaryLabel import show [as 别名]
    def _setup_widgets(self):
        self.purchases_list.set_columns(self._get_purchase_columns())
        self.product_list.set_columns(self._get_product_columns())
        self.payments_list.set_columns(self._get_payments_columns())

        purchases = self.model.get_supplier_purchases()
        self.purchases_list.add_list(purchases)

        self._build_data(purchases)
        self.product_list.add_list(self.products)
        self.payments_list.add_list(self.payments)

        value_format = '<b>%s</b>'
        total_label = "<b>%s</b>" % api.escape(_("Total:"))
        purchases_summary_label = SummaryLabel(klist=self.purchases_list,
                                               column='total',
                                               label=total_label,
                                               value_format=value_format)

        purchases_summary_label.show()
        self.purchases_vbox.pack_start(purchases_summary_label, False)
开发者ID:pkaislan,项目名称:stoq,代码行数:23,代码来源:supplierdetails.py

示例12: _setup_widgets

# 需要导入模块: from kiwi.ui.widgets.list import SummaryLabel [as 别名]
# 或者: from kiwi.ui.widgets.list.SummaryLabel import show [as 别名]
    def _setup_widgets(self):
        if self._is_batch:
            self._add_batches_tab()

        self.receiving_list.set_columns(self._get_receiving_columns())
        self.sales_list.set_columns(self._get_sale_columns())
        self.transfer_list.set_columns(self._get_transfer_columns())
        self.loan_list.set_columns(self._get_loan_columns())
        self.decrease_list.set_columns(self._get_decrease_columns())
        self.inventory_list.set_columns(self._get_inventory_columns())
        self.returned_list.set_columns(self._get_returned_columns())

        current_branch = api.get_current_branch(self.store)
        items = self.store.find(ReceivingItemView, sellable_id=self.model.id)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.receiving_list.add_list(list(items))

        items = self.store.find(SaleItemsView, sellable_id=self.model.id)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.sales_list.add_list(list(items))

        items = self.store.find(TransferOrderItem, sellable_id=self.model.id)
        self.transfer_list.add_list(list(items))

        items = self.store.find(LoanItemView, sellable_id=self.model.id)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.loan_list.add_list(list(items))

        items = self.store.find(StockDecreaseItemsView, sellable=self.model.id)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.decrease_list.add_list(list(items))

        items = InventoryItemsView.find_by_product(self.store, self.model.product)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.inventory_list.add_list(items)

        items = self.store.find(ReturnedSaleItemsView, sellable_id=self.model.id)
        if api.sysparam.get_bool('SYNCHRONIZED_MODE'):
            items = items.find(Branch.id == current_branch.id)
        self.returned_list.add_list(items)

        value_format = '<b>%s</b>'
        total_label = "<b>%s</b>" % api.escape(_("Total:"))
        receiving_summary_label = SummaryLabel(klist=self.receiving_list,
                                               column='quantity',
                                               label=total_label,
                                               value_format=value_format)
        receiving_summary_label.show()
        self.receiving_vbox.pack_start(receiving_summary_label, False)

        sales_summary_label = SummaryLabel(klist=self.sales_list,
                                           column='quantity',
                                           label=total_label,
                                           value_format=value_format)
        sales_summary_label.show()
        self.sales_vbox.pack_start(sales_summary_label, False)

        transfer_summary_label = SummaryLabel(klist=self.transfer_list,
                                              column='quantity',
                                              label=total_label,
                                              value_format=value_format)
        transfer_summary_label.show()
        self.transfer_vbox.pack_start(transfer_summary_label, False)

        loan_summary_label = SummaryLabel(klist=self.loan_list,
                                          column='quantity',
                                          label=total_label,
                                          value_format=value_format)
        self.loan_vbox.pack_start(loan_summary_label, False)

        decrease_summary_label = SummaryLabel(klist=self.decrease_list,
                                              column='quantity',
                                              label=total_label,
                                              value_format=value_format)
        decrease_summary_label.show()
        self.decrease_vbox.pack_start(decrease_summary_label, False)
开发者ID:pkaislan,项目名称:stoq,代码行数:83,代码来源:productstockdetails.py

示例13: SellableItemSlave

# 需要导入模块: from kiwi.ui.widgets.list import SummaryLabel [as 别名]
# 或者: from kiwi.ui.widgets.list.SummaryLabel import show [as 别名]

#.........这里部分代码省略.........

    def _setup_widgets(self):
        self._update_product_labels_visibility(False)
        self.quantity.set_sensitive(False)
        self.cost.set_sensitive(False)
        self.add_sellable_button.set_sensitive(False)
        self.unit_label.set_bold(True)

        for widget in [self.quantity, self.cost]:
            widget.set_adjustment(gtk.Adjustment(lower=0, upper=sys.maxint,
                                                 step_incr=1))

        self._reset_sellable()
        self._setup_summary()
        self.cost.set_digits(sysparam(self.store).COST_PRECISION_DIGITS)
        self.quantity.set_digits(3)

        self.barcode.grab_focus()
        self.item_table.set_focus_chain([self.barcode,
                                         self.quantity, self.cost,
                                         self.add_sellable_button,
                                         self.product_button])
        self.register_validate_function(self.validate)

    def _setup_summary(self):
        # FIXME: Move this into AdditionListSlave
        if not self.summary_label_column:
            self.summary = None
            return
        self.summary = SummaryLabel(klist=self.slave.klist,
                                    column=self.summary_label_column,
                                    label=self.summary_label_text,
                                    value_format='<b>%s</b>')
        self.summary.show()
        self.slave.list_vbox.pack_start(self.summary, expand=False)

    def _run_advanced_search(self, search_str=None):
        supplier = None
        has_supplier = hasattr(self.model, 'supplier')
        if has_supplier:
            supplier = self.model.supplier

        table, query = self.get_sellable_view_query()
        ret = run_dialog(AdvancedSellableSearch, self.get_parent(),
                         self.store,
                         table=table,
                         query=query,
                         search_str=search_str,
                         supplier=supplier,
                         hide_toolbar=not self.sellable_editable)
        if not ret:
            return

        # We receive different items depend on if we
        # - selected an item in the search
        # - created a new item and it closed the dialog for us
        if not isinstance(ret, (Product, ProductFullStockItemView,
                                ProductComponentView, SellableFullStockView,
                                ServiceView, ProductWithStockView)):
            raise AssertionError(ret)

        sellable = ret.sellable
        if not self.can_add_sellable(sellable):
            return
        self.barcode.set_text(sellable.barcode)
        self.sellable_selected(sellable)
开发者ID:romaia,项目名称:stoq,代码行数:70,代码来源:abstractwizard.py

示例14: SellableItemSlave

# 需要导入模块: from kiwi.ui.widgets.list import SummaryLabel [as 别名]
# 或者: from kiwi.ui.widgets.list.SummaryLabel import show [as 别名]

#.........这里部分代码省略.........

    def _setup_widgets(self):
        self._update_product_labels_visibility(False)
        self.quantity.set_sensitive(False)
        self.cost.set_sensitive(False)
        self.add_sellable_button.set_sensitive(False)
        self.unit_label.set_bold(True)

        for widget in [self.quantity, self.cost]:
            widget.set_adjustment(gtk.Adjustment(lower=0, upper=sys.maxint,
                                                 step_incr=1))

        self._reset_sellable()
        self._setup_summary()
        self.cost.set_digits(sysparam(self.store).COST_PRECISION_DIGITS)
        self.quantity.set_digits(3)

        self.barcode.grab_focus()
        self.item_table.set_focus_chain([self.barcode,
                                         self.quantity, self.cost,
                                         self.add_sellable_button,
                                         self.product_button])
        self.register_validate_function(self.validate)

    def _setup_summary(self):
        # FIXME: Move this into AdditionListSlave
        if not self.summary_label_column:
            self.summary = None
            return
        self.summary = SummaryLabel(klist=self.slave.klist,
                                    column=self.summary_label_column,
                                    label=self.summary_label_text,
                                    value_format='<b>%s</b>')
        self.summary.show()
        self.slave.list_vbox.pack_start(self.summary, expand=False)

    def _run_advanced_search(self, search_str=None):
        supplier = None
        has_supplier = hasattr(self.model, 'supplier')
        if has_supplier:
            supplier = self.model.supplier

        table, query = self.get_sellable_view_query()
        ret = run_dialog(AdvancedSellableSearch, self.get_parent(),
                         self.store,
                         table=table,
                         query=query,
                         search_str=search_str,
                         supplier=supplier,
                         hide_toolbar=not self.sellable_editable)
        if not ret:
            return

        # We receive different items depend on if we
        # - selected an item in the search
        # - created a new item and it closed the dialog for us
        if not isinstance(ret, (Product, ProductFullStockItemView,
                                ProductComponentView, SellableFullStockView,
                                ServiceView, ProductWithStockView)):
            raise AssertionError(ret)

        sellable = ret.sellable
        if not self.can_add_sellable(sellable):
            return
        self.barcode.set_text(sellable.barcode)
        self.sellable_selected(sellable)
开发者ID:leandrorchaves,项目名称:stoq,代码行数:70,代码来源:abstractwizard.py

示例15: ProductComponentSlave

# 需要导入模块: from kiwi.ui.widgets.list import SummaryLabel [as 别名]
# 或者: from kiwi.ui.widgets.list.SummaryLabel import show [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)

#.........这里部分代码省略.........
开发者ID:LeonamSilva,项目名称:stoq,代码行数:103,代码来源:productslave.py


注:本文中的kiwi.ui.widgets.list.SummaryLabel.show方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。