# Path: FabLabKasse/UI/GUIHelper.py
# def resize_table_columns(table, widths):
#     """resize Qt table columns by the weight factors specified in widths,
#     using the whole width (excluding scrollbar width)
#     """
#     w = table.width() - table.verticalScrollBar().width() - 5
#     for i, width in enumerate(widths):
#         table.setColumnWidth(i, int(width * w / sum(widths)))


import sys
import re
import locale
import logging
import datetime
import os
import functools
import scriptHelper
import importlib
        import rpdb2
from decimal import Decimal, DecimalException
from PyQt4 import QtGui, QtCore, Qt
from ConfigParser import Error as ConfigParserError
from libs.flickcharm import FlickCharm
from libs.pxss import pxss
from FabLabKasse.UI.GUIHelper import resize_table_columns
from UI.uic_generated.Kassenterminal import Ui_Kassenterminal
from UI.PaymentMethodDialogCode import PaymentMethodDialog
from UI.KeyboardDialogCode import KeyboardDialog
from cashPayment.client.PaymentDevicesManager import PaymentDevicesManager
from shopping.cart_from_app.cart_gui import MobileAppCartGUI
from shopping.backend.abstract import ProductNotFound, PrinterError
        self.current_category = index.data(QtCore.Qt.UserRole + 1).toInt()[0]  # TODO what does that mean
        self.leaveSearch()
        self.updateProductsAndCategories()

    def on_category_path_button_clicked(self):
        source = self.sender()
        self.current_category = source.category_id
        self.updateProductsAndCategories()

    def _add_to_category_path(self, name, categ_id, bold):
        """add button with text 'name' and callback for opening category categ_id to the category path"""
        # l = Qt.QLabel()
        # l.setText(u"►")
        # self.layout_category_path.addWidget(l)
        button = Qt.QPushButton(u" ► " + name)
        button.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
        if categ_id is not None:
            button.category_id = categ_id
            button.clicked.connect(self.on_category_path_button_clicked)
        self.layout_category_path.addWidget(button)
        if bold:
            # set (last) button to bold
            font = button.font()
            font.setBold(True)
            button.setFont(font)

    def updateProductsAndCategories(self, categories=None, products=None, category_path=None):
        """update models for products, categories, and the category path

        categories: list(Category), products: list(Product), category_path: list(Category) or a string to display one non-clickable button"""

# Path: FabLabKasse/UI/GUIHelper.py
# def resize_table_columns(table, widths):
#     """resize Qt table columns by the weight factors specified in widths,
#     using the whole width (excluding scrollbar width)
#     """
#     w = table.width() - table.verticalScrollBar().width() - 5
#     for i, width in enumerate(widths):
#         table.setColumnWidth(i, int(width * w / sum(widths)))


# Path: FabLabKasse/gui.py
import sys
import re
import locale
import logging
import datetime
import os
import functools
import scriptHelper
import importlib
        import rpdb2
from decimal import Decimal, DecimalException
from PyQt4 import QtGui, QtCore, Qt
from ConfigParser import Error as ConfigParserError
from libs.flickcharm import FlickCharm
from libs.pxss import pxss
from FabLabKasse.UI.GUIHelper import resize_table_columns
from UI.uic_generated.Kassenterminal import Ui_Kassenterminal
from UI.PaymentMethodDialogCode import PaymentMethodDialog
from UI.KeyboardDialogCode import KeyboardDialog
from cashPayment.client.PaymentDevicesManager import PaymentDevicesManager
from shopping.cart_from_app.cart_gui import MobileAppCartGUI
from shopping.backend.abstract import ProductNotFound, PrinterError

        self.current_category = index.data(QtCore.Qt.UserRole + 1).toInt()[0]  # TODO what does that mean
        self.leaveSearch()
        self.updateProductsAndCategories()

    def on_category_path_button_clicked(self):
        source = self.sender()
        self.current_category = source.category_id
        self.updateProductsAndCategories()

    def _add_to_category_path(self, name, categ_id, bold):
        """add button with text 'name' and callback for opening category categ_id to the category path"""
        # l = Qt.QLabel()
        # l.setText(u"►")
        # self.layout_category_path.addWidget(l)
        button = Qt.QPushButton(u" ► " + name)
        button.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
        if categ_id is not None:
            button.category_id = categ_id
            button.clicked.connect(self.on_category_path_button_clicked)
        self.layout_category_path.addWidget(button)
        if bold:
            # set (last) button to bold
            font = button.font()
            font.setBold(True)
            button.setFont(font)

    def updateProductsAndCategories(self, categories=None, products=None, category_path=None):
        """update models for products, categories, and the category path

        categories: list(Category), products: list(Product), category_path: list(Category) or a string to display one non-clickable button"""

        if categories is None: