コード例 #1
0
ファイル: sell.py プロジェクト: sychov/conditer
    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)
コード例 #2
0
ファイル: sell.py プロジェクト: sychov/conditer
    def show_sell_cathegory():
        """Заполняет нижний фрейм списком категорий товаров (кнопками с
        картинками). """

        master = show_sell.master

        big_buttons = []
        for cathegory in queries.cathegories():
            big_buttons.append(Button(master,
                        text=cathegory.name,
                        image=data.IMAGES[cathegory.picture],
                        compound="top", style='Default.TButton',
                        command=lambda cath=cathegory:
                                       press_cathegory(cath)))

            if not queries.actual_items_in_cathegory(cathegory):
                                    big_buttons[-1].configure(state=DISABLED)

        # Вынос картинок на глобальную переменную (в объекте data) не дурость,
        # а, к сожалению, проблема взаимоотношения Ткинтера с интерпретатором.
        # Иначе картинки банально исчезают под уборщиком мусора.

        if not big_buttons:
            return

        big_buttons[0].grid(column=0, row=0,
                        padx=SELL_BUTTON_PADX, pady=SELL_BUTTON_PADY)

        master.update()
        x1 = master.winfo_width()
        x2 = big_buttons[0].winfo_width()
        master.update()
        SELL_BUTTON_COUNT = x1//(x2+SELL_BUTTON_PADX*2)
        if SELL_BUTTON_COUNT:
            for q in range (1, len(big_buttons)):
                big_buttons[q].grid(column=q%SELL_BUTTON_COUNT,
                                    row=q//SELL_BUTTON_COUNT,
                                    padx=SELL_BUTTON_PADX,
                                    pady=SELL_BUTTON_PADY)
コード例 #3
0
ファイル: lost.py プロジェクト: sychov/conditer
    def show_lost_eat(master, cath):
        """Заполняет нижний фрейм списком еды (кнопками с надписями)"""

        small_butons = []
        small_butons.append(Button(master, text='...',
                            width=SELL_WORD_WIDTH, style='Eat.TButton',
                            command = lambda:press_eat(master, 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]
            quantity = queries.items_in_storage(item)
            if cath:        #Для ингредиентов еще выводим единицы измерения
                spaces = (SELL_WORD_WIDTH - len(item.name) -
                                                        len(quantity)) * ' '
                text = item.name + spaces + quantity
            else:
                spaces = (SELL_WORD_WIDTH - len(item.name) - 4 -
                                                        len(quantity)) * ' '
                text = item.name + spaces + quantity + ' ' + item.measure


            small_butons.append(Button(master, text=text, width=SELL_WORD_WIDTH,
                    style=('Eat.TButton'), command = lambda eat=item:
                                                  press_eat(master, 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)
コード例 #4
0
ファイル: lost.py プロジェクト: sychov/conditer
    def show_lost_cathegory(master):
        """Заполняет нижний фрейм списком категорий товаров (кнопками с
        картинками). """

        big_buttons = []
        for cathegory in queries.cathegories():
            if cathegory.name <> u'Акции':
                big_buttons.append(Button(master,
                            text=cathegory.name,
                            image=data.IMAGES[cathegory.picture],
                            compound="top", style='Default.TButton',
                            command=lambda cath=cathegory:
                                           press_cathegory(master, cath)))

                if not queries.actual_items_in_cathegory(cathegory):
                                       big_buttons[-1].configure(state=DISABLED)

        # + одну кнопку для "голых" индредиентов
        big_buttons.append(Button(master,
                        text=u'Ингредиенты',
                        image=data.IMAGES[u'Ингредиенты'],
                        compound="top", style='Default.TButton',
                        command=lambda cath=None:
                                       press_cathegory(master, cath)))

        big_buttons[0].grid(column=0, row=0,
                        padx=SELL_BUTTON_PADX, pady=SELL_BUTTON_PADY)

        master.update()
        x1 = master.winfo_width()
        x2 = big_buttons[0].winfo_width()
        SELL_BUTTON_COUNT = x1//(x2+SELL_BUTTON_PADX*2)
        if SELL_BUTTON_COUNT:
            for q in range (1, len(big_buttons)):
                big_buttons[q].grid(column=q%SELL_BUTTON_COUNT,
                                    row=q//SELL_BUTTON_COUNT,
                                    padx=SELL_BUTTON_PADX,
                                    pady=SELL_BUTTON_PADY)