本文整理汇总了Python中tkinter.Canvas.mainloop方法的典型用法代码示例。如果您正苦于以下问题:Python Canvas.mainloop方法的具体用法?Python Canvas.mainloop怎么用?Python Canvas.mainloop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Canvas
的用法示例。
在下文中一共展示了Canvas.mainloop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loop
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import mainloop [as 别名]
else:
xplus = x+1;
if y == 99:
yplus = 0;
else:
yplus = y+1;
neighbours = board[xplus][yplus] + board[xplus][y] + board[xplus][yminus] + board[x][yplus] + board[x][yminus] + board[xminus][yplus] + board[xminus][y] + board[xminus][yminus];
if neighbours == 3:
nboard[x][y] = 1;
elif neighbours != 2:
nboard[x][y] = 0;
else:
nboard[x][y] = board[x][y]
board, nboard = nboard, board;
def loop(*args):
if state:
makeTurn();
redraw();
canvas.after(10, func=loop);
def switchState(*args):
global state;
state = not state;
if state:
loop();
canvas.bind("<Button-1>",diviveIntervention);
canvas.bind("<Button-3>",switchState);
canvas.mainloop();
示例2: TKinterDisplay
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import mainloop [as 别名]
#.........这里部分代码省略.........
a2 = (id2tuple[2] - id2tuple[0]) / 2
b2 = (id2tuple[3] - id2tuple[1]) / 2
r1 = a1 * b1 / (math.sqrt(((a1 * a1) * (math.pow(math.sin(x1angle), 2))) + ((b1 * b1) * math.pow(math.cos(x1angle), 2))))
r2 = a2 * b2 / (math.sqrt(((a2 * a2) * (math.pow(math.sin(x2angle), 2))) + ((b2 * b2) * math.pow(math.cos(x2angle), 2))))
x1 = x1 + ((r1 / hyp) * (x2 - x1))
y1 = y1 + ((r1 / hyp) * (y2 - y1))
#x2 = x2 + ((r2 / hyp) * (x1 - x2))
#y2 = y2 - ((r2 / hyp) * (y1 - y2))
return self.__drawLine(x1, y1, x2, y2, tags, colour)
@abstractmethod
def renderTextInId(self, tagTocentreOn, tagsToAddTo, content, funcContent):
id1tuple = self.__getCoords(tagTocentreOn)
x1 = id1tuple[0] + ((id1tuple[2] - id1tuple[0]) / 2)
y1 = id1tuple[1] + ((id1tuple[3] - id1tuple[1]) / 2)
txt = self.__renderText(x1, y1, (id1tuple[2] - id1tuple[0]), content, tagsToAddTo)
def handler(event, self=self, content=funcContent):
return self.__eventOnClick(event, content)
self.localCanvas.tag_bind(txt, "<ButtonRelease-1>", handler)
return txt
@abstractmethod
def move(self, tag, xamount, yamount):
self.localCanvas.move(tag, xamount, yamount)
@abstractmethod
def runDisplay(self):
self.localCanvas.mainloop()
def __hideId(self, objectId):
self.localCanvas.itemconfigure(objectId, state="hidden")
pass
def __showId(self, objectId):
self.localCanvas.itemconfigure(objectId, state="normal")
pass
def __sampleDraw(self):
self.localCanvas.create_oval(0, 0, 0, 0, width=0)
def __renderText(self, x, y, width, content, tag):
val = self.localCanvas.create_text(x, y, width=width, text=content, tags=tag, justify="center", font="Helvetica 8 bold", anchor="center")
self.localCanvas.tag_raise(val)
return val
def __drawLine(self, x1, y1, x2, y2, tags=None, colour="black"):
line = self.localCanvas.create_line(x1, y1, x2, y2, tags=tags, width=self.lineThickness, arrow="first", arrowshape=(16,20,6),fill=colour, smooth=True)
self.localCanvas.tag_lower(line)
return # line
def __remove(self, num):
self.localCanvas.delete(num)
def __getCoords(self, ident):
return self.localCanvas.coords(ident)
def __eventOnFrameConfigure(self, event):
'''Reset the scroll region to encompass the inner frame'''
assert self.localCanvas