I just finished writing a Tkinter based GUI of the board game Othello for a programming class. Everything seems to be working correctly, but something strange is still happening: any changes that occur on the game board GUI are updated only when I click outside of the window.
This happens not only in my application, but in other Tkinter based GUI applications that my instructor has written--only when running on my machine. I've seen these applications work correctly on other machines, which has led me to believe that there's something specific to my machine that is causing this issue, and for this reason, I haven't included any code in my question.
Does anyone have any insight into this? I'm sorry if I haven't included sufficient details; I'm not exactly sure what to include. I'm using Python 3.3.2 and Tkinter 8.5
edit:
Here's the code for the GUI that my instructor wrote. It's a simple application that creates ovals on a canvas wherever the user clicks. It worked fine on the machines at school, but on my computer, when I click on the canvas, nothing happens until I click outside of the tkinter window. After clicking outside of the window, the spots draw correctly.
Also, I'm running OS X Mavericks (10.9).
import coordinate
import spots_engine
import tkinter
class SpotsApplication:
def __init__(self, state: spots_engine.SpotsState):
self._state = state
self._root_window = tkinter.Tk()
self._canvas = tkinter.Canvas(
master = self._root_window, width = 500, height = 450,
background = '#006000')
self._canvas.grid(
row = 0, column = 0, padx = 10, pady = 10,
sticky = tkinter.N + tkinter.S + tkinter.E + tkinter.W)
self._canvas.bind('<Configure>', self._on_canvas_resized)
self._canvas.bind('<Button-1>', self._on_canvas_clicked)
self._root_window.rowconfigure(0, weight = 1)
self._root_window.columnconfigure(0, weight = 1)
def start(self) -> None:
self._root_window.mainloop()
def _on_canvas_resized(self, event: tkinter.Event) -> None:
self._redraw_all_spots()
def _on_canvas_clicked(self, event: tkinter.Event) -> None:
width = self._canvas.winfo_width()
height = self._canvas.winfo_height()
click_coordinate = coordinate.from_absolute(
(event.x, event.y), (width, height))
self._state.handle_click(click_coordinate)
self._redraw_all_spots()
def _redraw_all_spots(self) -> None:
self._canvas.delete(tkinter.ALL)
canvas_width = self._canvas.winfo_width()
canvas_height = self._canvas.winfo_height()
for spot in self._state.all_spots():
center_x, center_y = spot.center_coordinate().absolute(
(canvas_width, canvas_height))
radius_x = spot.radius_frac() * canvas_width
radius_y = spot.radius_frac() * canvas_height
self._canvas.create_oval(
center_x - radius_x, center_y - radius_y,
center_x + radius_x, center_y + radius_y,
fill = '#ffff00', outline = '#000000')
if __name__ == '__main__':
SpotsApplication(spots_engine.SpotsState()).start()
-> None:,event: tkinter.Event, etc.