Esempio n. 1
0
    def show_sell_eat(cath):
        """Заполняет нижний фрейм списком еды (кнопками с надписями)"""

        master = show_sell.master

        small_butons = []
        small_butons.append(Button(master, text='...',
                            width=SELL_WORD_WIDTH, style='Eat.TButton',
                            command = lambda:press_eat(cath, eat='')))

        # ---Первую кнопку кладем отдельно для определения количества по ширине-
        small_butons[0].grid(column=0, row=0,padx=SELL_WORD_PADX,
                                                    pady=SELL_WORD_PADY)
        master.update()
        x1 = master.winfo_width()
        x2 = small_butons[0].winfo_width()
        SELL_WORD_COUNT = x1/(x2+SELL_WORD_PADX*2)
        # ----------------------------------------------------------------------

        goods = queries.actual_items_in_cathegory(cath)
        for count in range(len(goods)):
            item = goods[count]
            spaces = SELL_WORD_WIDTH - len(item.name) - \
                                len('%.2f' %  queries.item_price(item))
            text = item.name + ' ' * spaces + '%.2f' % queries.item_price(item)
            style = ('Eat.TButton','Eat2.TButton')[queries.price_is_sales(item)]
            small_butons.append(Button(master, text=text, width=SELL_WORD_WIDTH,
                                       style=style,
                                       command = lambda eat=item, cath=cath:
                                                press_eat(cath, eat)))

        for q in range (1, len(small_butons)):
            small_butons[q].grid(column=q%SELL_WORD_COUNT,
                row=q//SELL_WORD_COUNT,padx=SELL_WORD_PADX, pady=SELL_WORD_PADY)
Esempio n. 2
0
        def make_list_string (self, eat, quantity):
            """Вспомогательная функция создания строки для счета"""

            if queries.price_is_sales(eat):
                str_1 = u'*'
            else:
                str_1 = u' '
            string = str_1 + u'%-' + unicode(BILL_WIDTH - 36) + \
                                        u's %2d   %6.2f грн.   %6.2f грн.'
            string = string % (eat.name, quantity, queries.item_price(eat),
                               quantity * queries.item_price(eat))
            return string
Esempio n. 3
0
        def itogo(self):
            """Обсчитывает итоговую сумму счета, применяет скидку и выводит
            в соответствующую метку под счетом."""

            summ = 0
            for item, quantity in zip(self.bill, self.quantity):
                if queries.price_is_sales(item):
                    summ += quantity * queries.item_price(item)
                else:
                    summ += quantity * queries.item_price(item) * (100 -
                                                            self.discount) / 100

            summ = round(summ, 2)
            self.label1.configure(text='Итого:%8s грн.' % ('%5.2f' % summ))
            return summ