3

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()
4
  • The code might help, so just edit & add it in the end. Also, your machine/system details (OS). Commented Dec 6, 2013 at 4:47
  • Add code to your answer showing a minimal application that illustrates the problem that occur on your system but not others (and tell us what OS platform your system running). Commented Dec 6, 2013 at 5:06
  • are you sure that's your real code? There are a lot of syntax errors. For example -> None:, event: tkinter.Event, etc. Commented Dec 6, 2013 at 15:16
  • 1
    Those are type annotations. In Python 3 they're permitted. Commented Dec 6, 2013 at 18:36

1 Answer 1

1

If I'm not mistaken, the problem we are talking about here is a known bug:

http://bugs.python.org/issue19373


EDIT:

Installing/reinstalling ActiveTcl8.5.15.1.297588 over ActiveTcl8.6.1.1.297588 is working! My Tkinter GUI is responsive again.

NOTE: I'm using Python 3.3.3.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, that worked. Running python in 32 bit mode also works as a fix.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.