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


Python Canvas.lift方法代码示例

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


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

示例1: rmap

# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import lift [as 别名]

#.........这里部分代码省略.........
        size = self._size
        sleep = self.sleep
        self.sleep = 0

        self._bg = [self._canvas.create_rectangle(1,1,(size*(self._nc+1)), (size*(self._nr+1)), fill="gray")]
        # создать поле
        
        for r in range (1, self._nr+1):
            self._bg.append(self._canvas.create_line(size,r*size,self._nc*size,r*size))
            if r < self._nr: self._canvas.create_text(size/2,r*size+size/2,text=r)
        for c in range (1, self._nc+1):
            self._bg.append(self._canvas.create_line(c*size,size,c*size,self._nr*size))
            if c < self._nc: self._bg.append(self._canvas.create_text(c*size+size/2,size/2,text=c))
        # клетки и номера столбцов и строк

        for r in range (1,self._nr): 
            for c in range(1,self._nc):
                self._r = r
                self._c = c
                if  self._field[r][c].wUp: # стена сверху
                    self.setWall('up')
                if  self._field[r][c].wLeft: # стена слева
                    self.setWall('left')
                if  self._field[r][c].color != '' : # закраска
                    self.paint(self._field[r][c].color)
                if  self._field[r][c].label != '' : # метка0000
                    d = self._d 
                    x1 = self._size*(c)
                    x2 = self._size*(c+1)
                    y1 = self._size*(r)
                    y2 = self._size*(r+1)
                    self._canvas.delete(self._field[r][c].v.label)
                    self._field[r][c].v.label = self._canvas.create_rectangle(x1+d,y1+d,x2-d,y2-d, width = d-1, outline = self._field[r][c].label)
                    self._canvas.lift(self._robot)
                self.settext(self._field[r][c].text) # текст

        for self._c in range (1,self._nc): 
                if  self._field[self._nr][self._c].wUp: # стена сверху
                    self.setWall('down')

        for self._r in range (1,self._nr): 
                if  self._field[self._r][self._nc].wLeft: # стена слева
                    self.setWall('right')

        r = self._endPoint[0]
        c = self._endPoint[1]
        self._canvas.delete(self._park)
        if r > 0 and c > 0:
            self._park = self._canvas.create_oval (c*size+6,r*size+6, c*size+size-6,r*size+size-6, width = 3, outline = 'yellow')
        # конечная точка
        
        self.jumpTo((remr,remc))
        self._task = '\n'+self._task
        self.task.config(text = self._task)
        self.res.config()
        self._update()
        self.sleep = sleep
        #self.pause()

        
    def _update(self):
        "Обновить canvas"
        if not self._NoneUpdate:
            self._canvas.update()
            time.sleep(self.sleep)
        
开发者ID:Katya1518,项目名称:Ogurtsova,代码行数:69,代码来源:robot.py

示例2: World

# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import lift [as 别名]

#.........这里部分代码省略.........

    def crash(self, x1, y1, x2, y2):
        if 0 in (x1, y1, x2, y2):
            return True
        if (x2, y2) in list(self.walls.keys()) and \
                (x1, y1) in self.walls[(x2, y2)]:
            return True
        if (x1, y1) in list(self.walls.keys()) and \
                (x2, y2) in self.walls[(x1, y1)]:
            return True
        return False

    def add_infinite_beepers(self, x, y):
        flag = (x, y) not in list(self.beepers.keys()) or \
            self.beepers[(x, y)] is 0
        self.beepers[(x, y)] = INFINITY
        text = "oo"
        a = self.t + x * self.t
        b = self.n - (self.t + y * self.t)
        t = self.t / 3
        if flag:
            self.ovals[(x, y)] = self.canvas.create_oval(a-t, b-t, a+t,
                                                         b+t, fill="black")
            self.numbers[(x, y)] = self.canvas.create_text(a, b, text=text,
                                                           fill="white",
                                                           font=("Times",
                                                                 max(-self.t/2,
                                                                     -20),
                                                                 ""))
        else:
            self.canvas.itemconfig(self.numbers[(x, y)], text=text)
        if (x, y) in list(self.robots.keys()):
            for robot in self.robots[(x, y)]:
                robot.lift()

    def add_beeper(self, x, y):
        if (x, y) in list(self.beepers.keys()) and \
                self.beepers[(x, y)] is INFINITY:
            return
        flag = (x, y) not in list(self.beepers.keys()) or \
            self.beepers[(x, y)] is 0
        if flag:
            self.beepers[(x, y)] = 1
        else:
            self.beepers[(x, y)] += 1
        text = str(self.beepers[(x, y)])
        a = self.t + x * self.t
        b = self.n - (self.t + y * self.t)
        t = self.t / 3
        if flag:
            self.ovals[(x, y)] = self.canvas.create_oval(a-t, b-t, a+t, b+t,
                                                         fill="black")
            self.numbers[(x, y)] = self.canvas.create_text(a, b, text=text,
                                                           fill="white",
                                                           font=("Times",
                                                                 max(-self.t/2,
                                                                     -20),
                                                                 ""))
        else:
            self.canvas.itemconfig(self.numbers[(x, y)], text=text)
        if (x, y) in list(self.robots.keys()):
            for robot in self.robots[(x, y)]:
                robot.lift()

    def remove_beeper(self, x, y):
        if self.beepers[(x, y)] is INFINITY:
开发者ID:jelkner,项目名称:pykarel,代码行数:70,代码来源:pykarel.py


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