redraw via clock for thread safety
This commit is contained in:
1 parent
42ecdb622c
commit
b29b157b7b
2 files changed
+5
-4
No files matched your search
+3
-2
@@ -11,6 +11,7 @@ from queue import Queue
|
||||
|
||||
from kivy.storage.jsonstore import JsonStore
|
||||
from kivy.uix.gridlayout import GridLayout
|
||||
from kivy.clock import Clock
|
||||
|
||||
from board import Board, IllegalMoveException, Move
|
||||
|
||||
@@ -38,8 +39,8 @@ class EngineControls(GridLayout):
|
||||
|
||||
def redraw(self, include_board=False):
|
||||
if include_board:
|
||||
self.parent.board.draw_board()
|
||||
self.parent.board.redraw()
|
||||
Clock.schedule_once(self.parent.board.draw_board, -1) # main thread needs to do this
|
||||
Clock.schedule_once(self.parent.board.redraw, -1)
|
||||
|
||||
def restart(self, board_size=None):
|
||||
self.ready = False
|
||||
|
||||
+2
-2
@@ -80,7 +80,7 @@ class BadukPanWidget(Widget):
|
||||
return [a + t * (b - a) for a, b in zip(self.EVAL_COLORS[i], self.EVAL_COLORS[i + 1])]
|
||||
return self.EVAL_COLORS[-1]
|
||||
|
||||
def draw_board(self):
|
||||
def draw_board(self, *args):
|
||||
self.canvas.before.clear()
|
||||
with self.canvas.before:
|
||||
# board
|
||||
@@ -114,7 +114,7 @@ class BadukPanWidget(Widget):
|
||||
draw_text(pos=(self.gridpos[i], lo / 2), text=Move.GTP_COORD[i], font_size=self.grid_size / 1.5)
|
||||
draw_text(pos=(lo / 2, self.gridpos[i]), text=str(i + 1), font_size=self.grid_size / 1.5)
|
||||
|
||||
def redraw(self):
|
||||
def redraw(self, *args):
|
||||
self.canvas.clear()
|
||||
with self.canvas:
|
||||
# stones
|
||||
|
||||
Reference in new issue
Block a user