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


Python Frame.update方法代码示例

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


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

示例1: Application

# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import update [as 别名]

#.........这里部分代码省略.........
        self.map.init_canvas(self.map_frame)
        self.map.canvas.pack()  # .grid(row=1,column=1)
        self.map.draw()
        self.map.canvas.bind("<Button-1>", self.paint)
        self.map.canvas.bind("<B1-Motion>", self.paint)

    def init_picker(self):
        """This should really be its own class."""
        self.current_tile = MapRenderer(
            self.config, parent=self.button_frame, tileset=Tileset(id=self.map.map.tileset.id)
        )
        self.current_tile.map.blockdata = [self.paint_tile]
        self.current_tile.map.width = 1
        self.current_tile.map.height = 1
        self.current_tile.init_canvas()
        self.current_tile.draw()
        self.current_tile.canvas.grid(row=0, column=4, padx=4)

        if hasattr(self, "picker"):
            self.picker.kill_canvas()
        self.picker = MapRenderer(self.config, parent=self, tileset=Tileset(id=self.map.map.tileset.id))
        self.picker.map.blockdata = range(len(self.picker.map.tileset.blocks))
        self.picker.map.width = 4
        self.picker.map.height = len(self.picker.map.blockdata) / self.picker.map.width
        self.picker.init_canvas(self.picker_frame)

        if hasattr(self.picker_frame, "vbar"):
            self.picker_frame.vbar.destroy()
        self.picker_frame.vbar = Scrollbar(self.picker_frame, orient=VERTICAL)
        self.picker_frame.vbar.pack(side=RIGHT, fill=Y)
        self.picker_frame.vbar.config(command=self.picker.canvas.yview)

        self.picker.canvas.config(scrollregion=(0, 0, self.picker.canvas_width, self.picker.canvas_height))
        self.map_frame.update()

        # overwriting a property is probably a bad idea
        self.picker.canvas_height = self.map_frame.winfo_height()

        self.picker.canvas.config(yscrollcommand=self.picker_frame.vbar.set)
        self.picker.canvas.pack(side=LEFT, expand=True)

        self.picker.canvas.bind("<4>", lambda event: self.scroll_picker(event))
        self.picker.canvas.bind("<5>", lambda event: self.scroll_picker(event))
        self.picker_frame.vbar.bind("<4>", lambda event: self.scroll_picker(event))
        self.picker_frame.vbar.bind("<5>", lambda event: self.scroll_picker(event))

        self.picker.draw()
        self.picker.canvas.bind("<Button-1>", self.pick_block)

    def scroll_picker(self, event):
        if event.num == 4:
            self.picker.canvas.yview("scroll", -1, "units")
        elif event.num == 5:
            self.picker.canvas.yview("scroll", 1, "units")

    def pick_block(self, event):
        block_x = int(self.picker.canvas.canvasx(event.x)) / (
            self.picker.map.tileset.block_width * self.picker.map.tileset.tile_width
        )
        block_y = int(self.picker.canvas.canvasy(event.y)) / (
            self.picker.map.tileset.block_height * self.picker.map.tileset.tile_height
        )
        i = block_y * self.picker.map.width + block_x
        self.paint_tile = self.picker.map.blockdata[i]

        self.current_tile.map.blockdata = [self.paint_tile]
开发者ID:PikalaxALT,项目名称:pokemon-reverse-engineering-tools,代码行数:70,代码来源:map_editor.py

示例2: show_sell_bills

# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import update [as 别名]

#.........这里部分代码省略.........
                index = window_names.index(w_name) - 1
                note.select(window_names[index])

        button_left = Button(sellTopFrame, image=data.IMG_INTERFACE[3],
                                command=b_left)
        button_left.pack(side=LEFT, padx=5, pady=5)

        #------------------------------------------------------------
        def b_right():
            """Срабатывает при нажатии кнопки "вправо", сдвигается вправо на
            один таб в блокноте со счетами"""

            w_name = note.select()
            window_names = note.tabs()
            if window_names:
                index = window_names.index(w_name) + 1
                if index == len(window_names):
                    index = 0
                note.select(window_names[index])

        button_right = Button(sellTopFrame, image=data.IMG_INTERFACE[4],
                                command=b_right)
        button_right.pack(side=LEFT, padx=5, pady=5)

        #------------------------------------------------------------
        def b_del():
            """Срабатывает при нажатии кнопки "удалить счет", удаляет таб в
            блокноте со счетами"""

            w_name = note.select()
            window_names = note.tabs()
            if not window_names:
                button_del_bill.configure(state=DISABLED)
            else:
                index = window_names.index(w_name)
                if not bills[index].bill:
                    note.forget(note.select())
                    del(bills[index])
                    if not note.tabs():
                        button_del_bill.configure(state=DISABLED)
                else:
                    if tkMessageBox.askokcancel('Внимание!',
                                   'Вы уверены, что хотите удалить этот счет?'):
                        note.forget(note.select())
                        del(bills[index])
                        if not note.tabs():
                            button_del_bill.configure(state=DISABLED)

        button_del_bill = Button(sellTopFrame,text=u'Удалить\nсчет',
                        style='Little.TButton', command=b_del)
        button_del_bill.pack(side=LEFT, padx=10, pady=10, fill=X)


        #----- ОСТАВШИЕСЯ ЭЛЕМЕНТЫ - БЛОКНОТ, СЧЕТЧИК ПРОДАЖ, КАЛЬКУЛЯТОР ------

        label = Label(sellTopFrame, text='', bg='white',
                                            font=('Lucida Console', FONT_SIZE))
        label.pack(side=RIGHT, padx=10, pady=5)

        def label_renew():
            """Обновляет счетчик продаж в верхнем правом углу экрана"""
            sold = '%6.2f' % round(queries.sell_in_day(),2) + ' грн.'
            label.configure(text='СЕГОДНЯ ПРОДАНО\n на ' + sold)

        label_renew()
        show_sell_bills.label_renew = label_renew

        #-----------
        button_calc = Button(sellTopFrame, image=data.IMG_INTERFACE[8],
                        command=calculator_press)
        button_calc.pack(side=RIGHT, padx=5, pady=5)

        button_paid = Button(sellTopFrame, image=data.IMG_INTERFACE[10], width=8,
                                     compound=LEFT, text=u'Блокнот\nрасходов',
                                     command=lambda: calc_pad(data))
        button_paid.pack(side=RIGHT, padx=5, pady=5)

        #-----------
        note = Notebook(master, style='Custom.TNotebook')
        bills = []
        note.pack(side=TOP, padx=BILL_PAD_X, pady=BILL_PAD_Y)

        #----------- Один пустой столик ставим по умолчанию ----------
        bill = Bill(note)
        bills.append(bill)
        tab = bill.frame
        note.add(tab, text = u' Стол 1 ')
        #-------------------------------------------------------------

        #--------Автоподъем высоты ------------
        sellTopFrame.update()
        y1 = sellTopFrame.winfo_height()
        y2 = note.winfo_height()
        master.configure(height = y1 + y2 + 40)
        master.pack_propagate(False)
        #---------------------------------------

        calculator_press.window_calc = False

        return bills, note
开发者ID:sychov,项目名称:conditer,代码行数:104,代码来源:sell.py

示例3: Application

# 需要导入模块: from ttk import Frame [as 别名]
# 或者: from ttk.Frame import update [as 别名]

#.........这里部分代码省略.........
        if hasattr(self, 'map'):
            self.map.kill_canvas()
        self.map = Map(self.map_frame, self.map_name, config=self.config)
        self.init_map_connections()

    def draw_map(self):
        self.map.init_canvas(self.map_frame)
        self.map.canvas.pack() #.grid(row=1,column=1)
        self.map.draw()
        self.map.canvas.bind('<Button-1>', self.paint)
        self.map.canvas.bind('<B1-Motion>', self.paint)

    def init_picker(self):
        self.current_tile = Map(self.button_frame, tileset_id=self.map.tileset_id, config=self.config)
        self.current_tile.blockdata = [self.paint_tile]
        self.current_tile.width = 1
        self.current_tile.height = 1
        self.current_tile.init_canvas()
        self.current_tile.draw()
        self.current_tile.canvas.grid(row=0, column=4, padx=4)

        if hasattr(self, 'picker'):
            self.picker.kill_canvas()
        self.picker = Map(self, tileset_id=self.map.tileset_id, config=self.config)
        self.picker.blockdata = range(len(self.picker.tileset.blocks))
        self.picker.width = 4
        self.picker.height = len(self.picker.blockdata) / self.picker.width
        self.picker.init_canvas(self.picker_frame)

        if hasattr(self.picker_frame, 'vbar'):
            self.picker_frame.vbar.destroy()
        self.picker_frame.vbar = Scrollbar(self.picker_frame, orient=VERTICAL)
        self.picker_frame.vbar.pack(side=RIGHT, fill=Y)
        self.picker_frame.vbar.config(command=self.picker.canvas.yview)

        self.picker.canvas.config(scrollregion=(0,0,self.picker.canvas_width, self.picker.canvas_height))
        self.map_frame.update()
        self.picker.canvas.config(height=self.map_frame.winfo_height())
        self.picker.canvas.config(yscrollcommand=self.picker_frame.vbar.set)
        self.picker.canvas.pack(side=LEFT, expand=True)

        self.picker.canvas.bind('<4>', lambda event : self.scroll_picker(event))
        self.picker.canvas.bind('<5>', lambda event : self.scroll_picker(event))
        self.picker_frame.vbar.bind('<4>', lambda event : self.scroll_picker(event))
        self.picker_frame.vbar.bind('<5>', lambda event : self.scroll_picker(event))

        self.picker.draw()
        self.picker.canvas.bind('<Button-1>', self.pick_block)

    def scroll_picker(self, event):
        if event.num == 4:
            self.picker.canvas.yview('scroll', -1, 'units')
        elif event.num == 5:
            self.picker.canvas.yview('scroll', 1, 'units')


    def pick_block(self, event):
        block_x = int(self.picker.canvas.canvasx(event.x)) / (self.picker.tileset.block_width * self.picker.tileset.tile_width)
        block_y = int(self.picker.canvas.canvasy(event.y)) / (self.picker.tileset.block_height * self.picker.tileset.tile_height)
        i = block_y * self.picker.width + block_x
        self.paint_tile = self.picker.blockdata[i]

        self.current_tile.blockdata = [self.paint_tile]
        self.current_tile.draw()

    def paint(self, event):
        block_x = event.x / (self.map.tileset.block_width * self.map.tileset.tile_width)
        block_y = event.y / (self.map.tileset.block_height * self.map.tileset.tile_height)
        i = block_y * self.map.width + block_x
        if 0 <= i < len(self.map.blockdata):
            self.map.blockdata[i] = self.paint_tile
            self.map.draw_block(block_x, block_y)

    def init_map_connections(self):
        if not self.display_connections:
            return
        for direction in self.map.connections.keys():
            if direction in self.connections.keys():
                if hasattr(self.connections[direction], 'canvas'):
                    self.connections[direction].kill_canvas()
            if self.map.connections[direction] == {}:
                self.connections[direction] = {}
                continue
            self.connections[direction] = Map(self, self.map.connections[direction]['map_name'], config=self.config)

            if direction in ['north', 'south']:
                x1 = 0
                y1 = 0
                x2 = x1 + eval(self.map.connections[direction]['strip_length'], self.config.constants)
                y2 = y1 + 3
            else: # east, west
                x1 = 0
                y1 = 0
                x2 = x1 + 3
                y2 = y1 + eval(self.map.connections[direction]['strip_length'], self.config.constants)

            self.connections[direction].crop(x1, y1, x2, y2)
            self.connections[direction].init_canvas(self.map_frame)
            self.connections[direction].canvas.pack(side={'west':LEFT,'east':RIGHT}[direction])
            self.connections[direction].draw()
开发者ID:TheScarletSword,项目名称:pokereddeluxe,代码行数:104,代码来源:map_editor.py


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