Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 特金特绘图问题_Python_User Interface_Python 3.x_Tkinter - Fatal编程技术网

Python 特金特绘图问题

Python 特金特绘图问题,python,user-interface,python-3.x,tkinter,Python,User Interface,Python 3.x,Tkinter,我刚刚为一个编程类编写了一个基于Tkinter的图版游戏Otherlo的GUI。一切似乎都正常工作,但奇怪的事情仍在发生:在游戏板GUI上发生的任何更改只有在我在窗口外单击时才会更新 这不仅发生在我的应用程序中,而且发生在我的导师编写的其他基于Tkinter的GUI应用程序中——只有在我的机器上运行时才会发生。我已经看到这些应用程序在其他机器上正常工作,这让我相信是我的机器特定的东西导致了这个问题,因此,我的问题中没有包含任何代码 有人对此有什么见解吗?我很抱歉,如果我没有包括足够的细节;我不确

我刚刚为一个编程类编写了一个基于Tkinter的图版游戏Otherlo的GUI。一切似乎都正常工作,但奇怪的事情仍在发生:在游戏板GUI上发生的任何更改只有在我在窗口外单击时才会更新

这不仅发生在我的应用程序中,而且发生在我的导师编写的其他基于Tkinter的GUI应用程序中——只有在我的机器上运行时才会发生。我已经看到这些应用程序在其他机器上正常工作,这让我相信是我的机器特定的东西导致了这个问题,因此,我的问题中没有包含任何代码

有人对此有什么见解吗?我很抱歉,如果我没有包括足够的细节;我不确定该包括什么。我正在使用Python 3.3.2和Tkinter 8.5

编辑:

下面是我的指导老师编写的GUI代码。这是一个简单的应用程序,无论用户在何处单击,都可以在画布上创建椭圆。它在学校的机器上运行得很好,但在我的电脑上,当我点击画布时,直到我在tkinter窗口外点击,一切都不会发生。在窗口外单击后,斑点将正确绘制

另外,我正在运行OSX小牛(10.9)

导入坐标
进口柴油机
进口tkinter
类别SPOTA应用程序:
定义初始状态(自身,状态:spots\U engine.SpotsState):
自我状态=状态
self.\u root\u window=tkinter.Tk()
self.\u canvas=tkinter.canvas(
主窗口=自窗口,宽度=500,高度=450,
背景=“#006000”)
self.\u canvas.grid(
行=0,列=0,padx=10,pady=10,
粘性=tkinter.N+tkinter.S+tkinter.E+tkinter.W)
self.\u canvas.bind('',画布上的self.\u调整大小)
self.\u canvas.bind(“”,self.\u在画布上单击)
self.\u root\u window.rowconfigure(0,权重=1)
self.\u root\u window.columnconfigure(0,权重=1)
def启动(自)->无:
self.\u root\u window.mainloop()
画布上的定义大小调整(self,event:tkinter.event)->无:
self.\u重新绘制\u所有点()
在画布上单击定义(self,事件:tkinter.event)->无:
width=self.\u canvas.winfo\u width()
高度=self.\u canvas.winfo\u高度()
单击坐标=坐标。从绝对坐标(
(事件x、事件y)(宽度、高度)
自身状态。句柄单击(单击坐标)
self.\u重新绘制\u所有点()
定义重新绘制所有点(自身)->无:
self.\u canvas.delete(tkinter.ALL)
canvas\u width=self.\u canvas.winfo\u width()
canvas\u height=self.\u canvas.winfo\u height()
对于处于自身状态的点。所有点()
中心x,中心y=spot.center\u坐标().绝对(
(画布宽度、画布高度)
半径x=点半径分形()*画布宽度
半径y=点。半径分形()*画布高度
自我。_canvas.create_oval(
中心x-半径x,中心y-半径y,
中心x+半径x,中心y+半径y,
填充='#ffff00',大纲='#000000')
如果uuuu name uuuuuu='\uuuuuuu main\uuuuuuu':
SpotsApplication(spots_engine.SpotsState()).start()

如果我没有弄错的话,我们这里讨论的问题是一个已知的bug:


编辑:

安装/重新安装
ActiveTcl8.5.15.1.297588
over
ActiveTcl8.6.1.1.297588
正在工作!我的Tkinter GUI再次响应


注意:我使用的是Python 3.3.3。

代码可能会有所帮助,因此只需在最后编辑并添加它即可。此外,请提供您的计算机/系统详细信息(OS)。在回答中添加代码,显示一个最小的应用程序,说明您系统上出现的问题,而不是其他系统上出现的问题(并告诉我们您的系统运行的操作系统平台)。您确定这是您的真实代码吗?有很多语法错误。例如
->None:
事件:tkinter.event
,等等。这些都是类型注释。在Python3中,它们是允许的。谢谢,这很有效。在32位模式下运行python也是一种修复方法。
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()