2014-01-27 55 views
2

我的節目給了我這個錯誤:Python的錯誤 - OverflowError:Python的詮釋太大,轉換爲C長

Traceback (most recent call last): 
    File "C:\Simulation\SymDialog.py", line 153, in OnPaint 
    self.Redraw(False) 
    File "C:\Simulation\SymDialog.py", line 173, in Redraw 
    obj.Draw(self.dc) 
    File "C:\Simulation\SymDialog.py", line 207, in Draw 
    dc.DrawCircle(self._x, self._y, self._r) 
    File "E:\Python\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\_gdi.py", line 3391, in DrawCircle 
    return _gdi_.DC_DrawCircle(*args, **kwargs) 
OverflowError: Python int too large to convert to C long 

從錯誤方法:

的OnPaint

def OnPaint(self, event): 
    self.Redraw(False) 
    wx.GCDC(wx.BufferedPaintDC(self, self._buffer)) 
    event.Skip() 

重繪

def Redraw(self, clear): 
    if clear == True: del self.drawList[:] 
    self.dc = wx.GCDC(wx.BufferedDC(None, self._buffer)) 
    self.dc.SetBackground(wx.Brush(self.GetBackgroundColour())) 
    self.dc.Clear() 
    for obj in self.drawList: 
     obj.Draw(self.dc) 
    del self.dc 

Draw

def Draw(self, dc): 
    self.setDC(dc) 
    dc.DrawCircle(self._x, self._y, self._r) 

我該如何解決這個錯誤? 感謝您的回答

+2

停止嘗試使用太大的值。 –

+0

DrawCircle需要一些參數,但是您傳遞的值太大。嘗試傳遞較小的值。 – sredmond

+0

但「self._x,self._y」的值不是太大,在範圍內(0,600),因爲這是繪製圓的面板的大小。 – Kamilos

回答

0

您可能錯誤地使用了太大的值。

編輯:由於我無法評論,self._x,self._y和self._r的大小是多少?

+2

C部分不能更改;這是對Windows API的調用。 –

+0

@ IgnacioVazquez-Abrams固定 – qwr

相關問題