panel_widget.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:Enibar 作者: ENIB 项目源码 文件源码
def add_product(self, cname, pname, price_name, price):
        """ Add product to list

        :param str cname: Category name
        :param str pname: Product name
        :param str price_name: Price name
        :param float price: Price value
        """
        name = "{} ({}) - {}".format(pname, price_name, cname)
        for product in self.products:
            if product['name'] == name:
                product['price'] += price
                product['price'] = product['price']
                product['count'] += 1
                product['widget'].setText(0, str(product['count']))
                product['widget'].setText(2, str(round(product['price'], 2)))
                break
        else:
            product = {
                'name': name,
                'price': price,
                'count': 1,
                'category': cname,
                'product': pname,
                'price_name': price_name,
                'deletable': False if pname == settings.ECOCUP_NAME else True,
            }
            widget = QtWidgets.QTreeWidgetItem(['1', name, str(price)])
            self.addTopLevelItem(widget)
            product['widget'] = widget
            self.products.append(product)
        self.update_total()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号