本文整理汇总了Python中tkinter.Canvas.create_oval方法的典型用法代码示例。如果您正苦于以下问题:Python Canvas.create_oval方法的具体用法?Python Canvas.create_oval怎么用?Python Canvas.create_oval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Canvas
的用法示例。
在下文中一共展示了Canvas.create_oval方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initUI
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import create_oval [as 别名]
def initUI(self):
self.parent.title("Raspberry Pi Sensorik")
self.pack(fill=BOTH, expand=1)
canvas = Canvas(self)
canvas.create_oval(MARGIN, MARGIN, CIRCLE_RADIUS*2, CIRCLE_RADIUS*2, outline="#fb0", fill="#fb0", width=2)
#canvas.create_oval(20, 10, 20+CIRCLE_SIZE, CIRCLE_SIZE, outline="#f50", fill="#f50")
#canvas.create_oval(CIRCLE_SIZE * 3, 10, CIRCLE_SIZE, CIRCLE_SIZE, outline="#05f", fill="#05f")
canvas.pack(fill=BOTH, expand=1)
示例2: draw
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import create_oval [as 别名]
def draw(self, canvas: Canvas):
border = 'black' if self.selected else self.color
x = BORDER + self.i * DD
y = BORDER + self.j * DD
pad = 4
if not self.id:
self.id = canvas.create_oval(x + pad, y + pad, x + DD - pad, y + DD - pad,
fill=self.color, outline=border)
示例3: __init__
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import create_oval [as 别名]
def __init__(self, player_id, canvas:tk.Canvas, color=None):
self.__id = player_id # 말을 소유하고 있는 플레이어의 id
self.__position = 0 # 현재 말의 위치
self.__text = str(player_id)
self.__canvas = canvas
self.__start_x, self.__start_y = 570+(player_id-1)*25, 600
if canvas is not None:
self.__item = canvas.create_oval(0, 0, 20, 20)
if color is not None:
self.__canvas.itemconfig(self.__item, fill=color)
self.__canvas.move(self.__item, self.__start_x, self.__start_y)
示例4: __init__
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import create_oval [as 别名]
def __init__(self, player_id, canvas:tk.Canvas, color=None):
self.__id = player_id # player id of marker
self.__position = 0 # position of marker
self.__canvas = canvas
self.__start_x, self.__start_y = 20+(player_id-1)*30, 50
self.__color = color
if canvas is not None:
self.__item = canvas.create_oval(0, 0, 20, 20)
if color is not None:
self.__canvas.itemconfig(self.__item, fill=color)
self.__canvas.move(self.__item, self.__start_x, self.__start_y)
self.__diff_x = 90
self.__diff_y = 80
示例5: WindowInstance
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import create_oval [as 别名]
class WindowInstance(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.parent.title("Window")
self.pack(fill=BOTH, expand=1)
self.canvas = Canvas(self)
self.doubleBuffer = False
self.fill = "#000"
self.outline = "#000"
def setColor(self, c):
self.fill = c
self.outline = c
def drawRectangle(self, x, y, w, h):
self.canvas.create_rectangle(x, y, x + w, y + h, fill=self.fill, outline=self.outline)
if not self.doubleBuffer:
self.canvas.pack(fill=BOTH, expand=1)
def drawLine(self, x, y, ex, ey):
self.canvas.create_line(x, y, ex, ey, fill=self.fill)
if not self.doubleBuffer:
self.canvas.pack(fill=BOTH, expand=1)
def drawOval(self, x, y, w, h):
self.canvas.create_oval(x, y, x + w, y + h, fill=self.fill, outline=self.outline)
if not self.doubleBuffer:
self.canvas.pack(fill=BOTH, expand=1)
def frame(self):
self.doubleBuffer = True
self.canvas.pack(fill=BOTH, expand=1)
def clear(self):
self.canvas.delete("all")
示例6: CoordinatePlot
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import create_oval [as 别名]
class CoordinatePlot(object):
"""
Shows the distribution of one coordinate of
a list of solutions in the complex plane.
"""
def __init__(self, wdw, dim, sols, idx):
"""
The layout is just a square canvas, of dimension dim.
The canvas represents the complex plane for the plot of
the coordinate defined by index idx of the list sols.
"""
wdw.title('complex coordinate plot')
self.cnv = Canvas(wdw, width=dim, height=dim)
self.cnv.pack()
self.sols = sols
self.idx = idx
self.dim = dim
self.plot()
def plot(self):
"""
Plots a coordinate of the list of solutions.
"""
from phcpy.solutions import coordinates
dim = self.dim
self.cnv.create_line(0, dim/2, dim, dim/2) # x coordinate axis
self.cnv.create_line(dim/2, 0, dim/2, dim) # y coordinate axis
(realmin, realmax, imagmin, imagmax) = windowsize(self.sols, self.idx)
dimreal = max(abs(realmin), abs(realmax))
dimimag = max(abs(imagmin), abs(imagmax))
factor = dim/2 - 10 # the origin is at (dim/2, dim/2)
for sol in self.sols:
(names, values) = coordinates(sol)
val = values[self.idx]
xpt = dim/2 + (val.real/dimreal)*factor
ypt = dim/2 + (val.imag/dimimag)*factor
self.cnv.create_oval(xpt-3, ypt-3, \
xpt+3, ypt+3, fill='red')
示例7: circleWindow
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import create_oval [as 别名]
def circleWindow():
C = Canvas(top,bg='blue', height=250, width=300)
oval = C.create_oval(70, 30, 200, 200, fill="Red")
C.pack()
示例8: __init__
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import create_oval [as 别名]
class Visualize:
def __init__(self, solution):
self.solution = solution
self.time = 0
self.full = solution.full
self.shiftRight = 20
self.shiftDown = 20
self.separation = 90
self.scale = 60
self.textVShift = 10
self.root = Tk()
self.canvas = Canvas(self.root)
self.canvas.pack(fill=BOTH, expand=YES)
self.root.bind("<KeyRelease>", self.key_released)
self.timeLabel = Label(self.root, text='time_lavel')
self.timeLabel.pack(side=RIGHT)
self.setup()
self.draw()
if self.full:
mainloop()
def key_released(self, event):
if event.char == 'j':
if self.time < self.solution.maxt:
self.time = self.time + 1
self.draw()
elif event.char == 'k':
if self.time > 0:
self.time = self.time - 1
self.draw()
elif event.char == 'q':
self.root.quit()
def getBBox(self, v):
return (self.shiftRight + self.separation*v[0],
self.shiftDown + self.separation*v[1],
self.shiftRight + self.separation*v[0] + self.scale,
self.shiftDown + self.separation*v[1] + self.scale)
def getCenter(self, v):
return (self.shiftRight + self.separation*v[0] + self.scale / 2,
self.shiftDown + self.separation*v[1] + self.scale / 2)
def getStatusPos(self, v):
(x,y) = self.getCenter(v)
return (x,y - self.textVShift)
def getDecisionPos(self, v):
(x,y) = self.getCenter(v)
return (x,y + self.textVShift)
def getEdgePos(self, e):
v0 = self.getCenter(e[0])
v1 = self.getCenter(e[1])
if v0[0] == v1[0]:
if v0[1] < v1[1]:
return (v0[0], v0[1] + self.scale / 2), (v1[0], v1[1] - self.scale / 2)
else:
return (v0[0], v0[1] - self.scale / 2), (v1[0], v1[1] + self.scale / 2)
elif v0[1] == v1[1]:
if v0[0] < v1[0]:
return (v0[0] + self.scale / 2, v0[1]), (v1[0] - self.scale / 2, v1[1])
else:
return (v0[0] - self.scale / 2, v0[1]), (v1[0] + self.scale / 2, v1[1])
return v0, v1
def setup(self):
self.nodeStatus = {}
self.nodeDecision = {}
for v in self.solution.nodes:
self.canvas.create_oval(self.getBBox(v))
self.nodeStatus[v] = self.canvas.create_text(self.getStatusPos(v), text="asfs")
self.nodeDecision[v] = self.canvas.create_text(self.getDecisionPos(v), text="fs")
self.edges = {}
for e in self.solution.edges:
self.canvas.create_line(self.getEdgePos(e), fill='gray')
self.edges[e] = self.canvas.create_line(self.getEdgePos(e), arrow='last',
state=HIDDEN)
def draw(self):
# quick reference
nstat = self.solution.nstat
command = self.solution.command
self.timeLabel.config(text = '%r' % self.time)
t = self.time
for v in self.solution.nodes:
self.canvas.itemconfig(self.nodeStatus[v], text=nstat[v,self.time])
self.canvas.itemconfig(self.nodeDecision[v], text=command[v,self.time])
if not self.full:
return
occu = self.solution.occu
for e in self.solution.edges:
state = HIDDEN
#.........这里部分代码省略.........
示例9: Tk
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import create_oval [as 别名]
pos1 += (x, y)
pos2 += (x, y-m)
can.delete(line1[int(y/50)])
can.delete(line2[int(y/50)])
line1[int(y/50)] = [can.create_line(pos1, fill='#000')]
line2[int(y/50)] = [can.create_line(pos2, fill='#f00',
dash=(3, 2))]
can.update()
"""
본문
캔버스를 선언하고 원과 선들을 초기화
"""
master = Tk()
can = Canvas(master, width=500, height=500)
obj = can.create_oval(240, 240, 260, 260, fill='#aafcdf')
can.pack()
# 라인 초기화
line1 = [can.create_line(0, 0, 1, 1)]*11
line2 = [can.create_line(0, 0, 1, 1)]*11
# 애니메이션 구동
can.after(0, web)
onTarget = False
# bind: 미리 정해져 있는 입력에 따라서 함수를 실행
# 사용자의 드래그 동작은 클릭과 클릭한 후 이동으로 구성되어 있다.
can.bind('<Button-1>', onClick)
can.bind('<B1-Motion>', onDrag)
示例10: BoardArea
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import create_oval [as 别名]
#.........这里部分代码省略.........
self._regions = {}
self.__init_regions(self._game)
self._selection = None
def get_selection(self):
'''Getter of _selection.'''
return self._selection
def set_selection(self, sel):
'''Setter of _selection.'''
self._selection = sel
def __init_regions(self, game):
'''Complete the _regions dictionary.'''
canvas_x = 0
canvas_y = 0
for x_index in range(7):
for y_index in range(7):
if (x_index, y_index) in game.get_board():
self._regions[(x_index, y_index)] = \
Rectangle((canvas_x, canvas_y), \
(canvas_x + BOARD_RECTANGLE_SIZE - 1, \
canvas_y + BOARD_RECTANGLE_SIZE - 1))
canvas_x += BOARD_RECTANGLE_SIZE
canvas_x = 0
canvas_y += BOARD_RECTANGLE_SIZE
def left_button_pressed(self, event):
'''The mouse left button was pressed, so if there's no
selection, it's created, and if the selection exists,
attempt to make a movement taking the selection position
and the current position.'''
pos = self.get_position_from_pixels(event.x, event.y)
if pos is not None:
if self.get_selection() is None:
self.set_selection(pos)
self.make_selection(pos)
else:
self._game.move(self.get_selection(), pos)
self.clear_selection(self.get_selection())
self.set_selection(None)
def make_selection(self, pos):
'''A selection was made.'''
self.__selection(pos, BOARD_SEL_COLOR)
def clear_selection(self, pos):
'''No longer selection in the position given.'''
self.__selection(pos, BOARD_BG_COLOR)
def __selection(self, pos, color):
'''Draw the selection rectangle.'''
self._regions[pos].display_on(self._canvas, outline=color)
def update(self, aspect, value):
'''The board organization in the model has changed.'''
if aspect == 'CELL_ON':
self.draw_circle_from_rect(self._regions[value], \
CELL_NOT_EMPTY_COLOR)
elif aspect == 'CELL_OFF':
self.draw_circle_from_rect(self._regions[value], \
CELL_EMPTY_COLOR)
def draw_circle_from_rect(self, rect, color):
'''Draw a cell empty or not empty.'''
origin_x = rect.upper_left()[0] + DIST
origin_y = rect.upper_left()[1] + DIST
corner_x = rect.lower_right()[0] - DIST
corner_y = rect.lower_right()[1] - DIST
self._canvas.create_oval(origin_x, origin_y, \
corner_x, corner_y, fill=color)
def get_position_from_pixels(self, x_coord, y_coord):
'''Get the board position corresponding with the
coordinates given.'''
for cell, rect in self._regions.items():
if rect.contains((x_coord, y_coord)):
return cell
return None
示例11: AppLogic
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import create_oval [as 别名]
class AppLogic(threading.Thread):
def __init__(self, tk_root):
self.root = tk_root
threading.Thread.__init__(self)
self.turn = 0
self.update = False
self.x = -1
self.y = -1
self.start()
def run(self):
self.game_gui = Canvas(self.root, width=600, height=600, background='green')
self.game_gui.bind("<Button-1>", self.click)
self.game_gui.focus_set()
self.game_gui.bind("<Key>", self.key)
self.game_gui.pack()
for i in range(1, 8):
self.game_gui.create_line(0, i*75, 600, i*75)
self.game_gui.create_line(i*75, 0, i*75, 600)
self.pieces = []
for i in range(8):
self.pieces.append([])
for j in range(8):
self.pieces[i].append(self.game_gui.create_oval(i*75+5, j*75+5, (i+1)*75-5, (j+1)*75-5, fill="green", outline="green"))
self.root.protocol("WM_DELETE_WINDOW", self.on_closing)
self.root.resizable(0,0)
self.running = True
config = EvaluateConfig()
tf_util.update_memory(config.gpu_mem_fraction)
AIPlayer.create_if_nonexistant(config)
self.game = Othello()
if(random() > 0.5):
self.human = 1
else:
self.human = -1
ai = create_player(config.model_1, config)
#print("You are playing against", config.model_1)
#print("Playing games with %d simulations per move" % config.game.simulation_num_per_move)
self.side = -1
self.draw_board()
self.value = ai.evaluate(self.game, self.side)
while self.running and not self.game.game_over():
#play move
if self.side != self.human:
self.value = ai.evaluate(self.game, self.side)
self.root.title("Othello (Thinking of Move) Current Value: %0.2f (1 white wins, -1 black wins)" % self.value)
self.root.config(cursor="wait")
t = ai.pick_move(self.game, self.side)
self.game.play_move(t[0], t[1], self.side)
self.draw_board()
self.side *= -1
self.value = ai.evaluate(self.game, self.side)
else:
if len(self.game.possible_moves(self.side)) == 0:
self.side *= -1
continue
if self.side == -1:
color = "black"
else:
color = "white"
self.root.title("Othello (Play as %s) Current Value: %0.2f (1 white wins, -1 black wins)" % (color, self.value))
self.root.config(cursor="")
if self.update:
self.update = False
if (self.x, self.y) in self.game.possible_moves(self.side):
self.game.play_move(self.x, self.y, self.side)
self.draw_board()
self.side *= -1
time.sleep(0.01)
self.root.config(cursor="")
if self.human == self.game.get_winner():
self.root.title("Othello (You Win!)")
elif self.game.get_winner() == 0:
self.root.title("Othello (Its a draw!)")
else:
self.root.title("Othello (You Lose!)")
def key(self, event):
if event.char == "z":
self.human *= -1
def click(self, event):
self.game_gui.focus_set()
if self.human == self.side and not self.update:
if self.x != event.x//75 or self.y != event.y//75:
self.update = True
self.x = event.x//75
self.y = event.y//75
def on_closing(self):
self.running = False
self.root.destroy()
def draw_board(self):
for i in range(8):
for j in range(8):
#.........这里部分代码省略.........
示例12: rmap
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import create_oval [as 别名]
#.........这里部分代码省略.........
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)
def start(self,fun):
self.solve_task = fun
self._tk.mainloop()
##Робот
def pause(self,t=1):
"""Приостановка выполнения программы. Пауза в секундах.
#-------------------
r.pause() # пауза в одну секунду
#-------------------
r.pause(2) # пауза две секунды
#-------------------
示例13: draw
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import create_oval [as 别名]
def draw(self, canvas, fromX, fromY, toX, toY):
return Canvas.create_oval(canvas.getDrawArea(), fromX, fromY, toX, toY, outline=canvas.getShapeColor(),
width=self.PEN_WIDTH)
示例14: __init__
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import create_oval [as 别名]
#.........这里部分代码省略.........
if self.ai_symbol == 'x':
self.ai_action()
def _board(self):
"""Draws tic tac toe board"""
self.canvas.create_rectangle(0, 0, 300, 300, outline="black")
self.canvas.create_rectangle(100, 300, 200, 0, outline="black")
self.canvas.create_rectangle(0, 100, 300, 200, outline="black")
def user_action(self, event):
"""Attempts to take action that matches user click. If the move is valid,
then calls the AI to make the next move. If not, displays the error.
"""
move_x = event.x // 100
move_y = event.y // 100
move_result = self.game.update(self.player_symbol, (move_x, move_y))
if move_result == "Success":
board_x = (200 * move_x + 100) / 2
board_y = (200 * move_y + 100) / 2
if self.player_symbol == 'x':
self.draw_x(board_x, board_y)
else:
self.draw_o(board_x, board_y)
if not self.completed():
# Wait a bit before calling the ai, for visual style
self.frame.after(500, self.ai_action)
else:
self.info_box['text'] = move_result
def ai_action(self):
"""Gets the next move from the AI based on current game state,
and plays.
"""
state = self.game.get_board()
move = self.ai.get_move(state)
move_result = self.game.update(self.ai_symbol, move)
if move_result == "Success":
board_x = (200 * move[0] + 100) / 2
board_y = (200 * move[1] + 100) / 2
if self.ai_symbol == 'x':
self.draw_x(board_x, board_y)
else:
self.draw_o(board_x, board_y)
self.completed()
def completed(self):
"""Checks the game status. If completed, displays the result,
and asks whether the player would like to start another game.
"""
status = self.game.done()
if status == 'e':
return False
message = "Click to start a new game."
if status == 't':
message = "Tie game. " + message
else:
message = "Player " + status.upper() + " has won. " + message
self.info_box.pack_forget()
self.start_button.pack(fill="both", expand=True)
self.start_button["text"] = message
self.start_button["command"] = self.clean_game_board
def draw_x(self, x, y):
self.canvas.create_line(x + 20, y + 20, x - 20, y - 20, width=4,
fill="black")
self.canvas.create_line(x - 20, y + 20, x + 20, y - 20, width=4,
fill="black")
def draw_o(self, x, y):
self.canvas.create_oval(x + 25, y + 25, x - 25, y - 25, width=4,
outline="red")
def set_game_board(self):
"""Hides game start buttons, reveals the game board and info box."""
self.start_button.pack_forget()
self.x_button.pack_forget()
self.o_button.pack_forget()
self.canvas.delete(ALL)
self.canvas.pack(fill="both", expand=True)
self.info_box.pack(fill="both", expand=True)
self.canvas.bind("<ButtonPress-1>", self.user_action)
self._board()
def clean_game_board(self):
"""Hides game board and label, reveals game start buttons."""
self.canvas.pack_forget()
self.info_box.pack_forget()
self.start_button.pack_forget()
self.x_button.pack(fill="both", expand=True)
self.o_button.pack(fill="both", expand=True)
def set_player_x(self):
self.player_symbol = 'x'
self.ai_symbol = 'o'
self.start()
def set_player_o(self):
self.player_symbol = 'o'
self.ai_symbol = 'x'
self.start()
示例15: __init__
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import create_oval [as 别名]
class Plot:
def __init__(self, root, grid, title='', boxsize=[], width=800, height=800):
if boxsize:
self.xmin, self.ymin, self.xmax, self.ymax = boxsize
else:
self.xmin, self.ymin, self.xmax, self.ymax = grid.boxsize()
self.width = width
self.height = height
self.title = title
self.grid = grid
self.frame = Frame(root)
self.frame.pack()
self.canvas = Canvas(bg="white", width=width, height=height)
self.canvas.pack()
def draw(self, rho, the, xyPath=[]):
border_x, border_y = 0.2, 0.2
scale = min((1.-border_x)*self.width/(self.xmax-self.xmin), \
(1.-border_y)*self.height/(self.ymax-self.ymin))
a = max(border_x * self.width/2., (self.width-scale*(self.xmax-self.xmin))/2.)
b = max(border_y * self.height/2.,(self.height-scale*(self.ymax-self.ymin))/2.)
box_pix = (a, self.height-scale*(self.ymax-self.ymin) - b,
scale*(self.xmax-self.xmin) + a, self.height - b)
# draw the box
self.addBox((self.xmin, self.ymin, self.xmax, self.ymax), box_pix)
# color plot
cells = cell.cell(self.grid)
for index in range(len(cells.data)):
ia, ib, ic = cells.data[index]
xa, ya = scale*(self.grid.x(ia)-self.xmin) + a, \
self.height -scale*(self.grid.y(ia)-self.ymin) - b
xb, yb = scale*(self.grid.x(ib)-self.xmin) + a, \
self.height -scale*(self.grid.y(ib)-self.ymin) - b
xc, yc = scale*(self.grid.x(ic)-self.xmin) + a, \
self.height -scale*(self.grid.y(ic)-self.ymin) - b
rhoAbc = (rho[ia] + rho[ib] + rho[ic])/3.0
theAbc = (the[ia] + the[ib] + the[ic])/3.0
color = colormap(rhoAbc, theAbc)
self.canvas.create_polygon(xa, ya, xb, yb, xc, yc, fill=color)
# add path if present
index = 0
for (x, y) in xyPath:
xa, ya = scale*(x - self.xmin) + a, \
self.height -scale*(y - self.ymin) - b
self.canvas.create_oval(xa-5, ya-5,
xa+5, ya+5)
#self.canvas.create_text(xa+2, ya+1, text=str(index))
index += 1
# add title
x, y = self.width/3., self.height/15.0
self.canvas.create_text(x, y, text=str(self.title),
font =("Helvetica", 24),
fill='black')
def addBox(self, xxx_todo_changeme, xxx_todo_changeme1):
"""
Add Box. Min/Max coordinates are in pixels.
"""
(self.xmin,self.ymin,self.xmax,self.ymax) = xxx_todo_changeme
(self.xmin_pix, self.ymin_pix, self.xmax_pix, self.ymax_pix) = xxx_todo_changeme1
self.canvas.create_line(self.xmin_pix, self.ymax_pix, self.xmax_pix, self.ymax_pix)
self.canvas.create_text(self.xmin_pix ,self.ymax_pix+ 8, text=('%4.1f' % self.xmin))
self.canvas.create_text(self.xmin_pix-12,self.ymax_pix , text=('%4.1f' % self.ymin))
self.canvas.create_line(self.xmax_pix, self.ymax_pix, self.xmax_pix, self.ymin_pix)
self.canvas.create_text(self.xmax_pix ,self.ymax_pix+ 8, text=('%4.1f' % self.xmax))
self.canvas.create_line(self.xmax_pix, self.ymin_pix, self.xmin_pix, self.ymin_pix)
self.canvas.create_text(self.xmin_pix-12,self.ymin_pix , text=('%4.1f' % self.ymax))
self.canvas.create_line(self.xmin_pix, self.ymin_pix, self.xmin_pix, self.ymax_pix)