【问题标题】:Python error - OverflowError: Python int too large to convert to C longPython 错误 - OverflowError: Python int too large to convert to C long
【发布时间】:2014-01-27 10:04:05
【问题描述】:

我的程序给了我这个错误:

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

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

我该如何解决这个错误? 谢谢解答

【问题讨论】:

  • 停止尝试使用太大的值。
  • DrawCircle 需要一些参数,但您传递的值太大。尝试传递较小的值。
  • 但是“self._x,self._y”的值不是太大,在(0, 600)范围内,因为这是画圆的panel的大小。跨度>

标签: python overflow


【解决方案1】:

您可能错误地使用了太大的值。

编辑:由于我无法评论,self._x、self._y 和 self._r 的大小是多少?

【讨论】:

  • C部分不能改;这是对 Windows API 的调用。
  • @IgnacioVazquez-Abrams 已修复
猜你喜欢
  • 1970-01-01
  • 2022-10-08
  • 1970-01-01
  • 1970-01-01
  • 2010-12-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-26
  • 2019-12-16
相关资源
最近更新 更多