canot define variable

hi i ve got this errors
Traceback (most recent call last):
  File "C:\Users\oscar\Documents\NetBeansProjects\latest\src\main.py",
line 251, in OnNewDocument
    newo = drawkernel.skth.DrawArea(self.Notebook, -1)
  File "C:\Users\oscar\Documents\NetBeansProjects\latest\src\drawkernel
\skth.py", line 13, in __init__
    self._initBuffer()
  File "C:\Users\oscar\Documents\NetBeansProjects\latest\src\drawkernel
\skth.py", line 126, in _initBuffer
    self.drawContents(dc)
  File "C:\Users\oscar\Documents\NetBeansProjects\latest\src\drawkernel
\skth.py", line 104, in drawContents
    gdc = self.wrapDC(dc)
AttributeError: 'DrawArea' object has no attribute 'wrapDC'

but if i got defined the wrapDC just like this

        self.wrapDC = lambda dc: dc

and then is called here...

def drawContents(self, dc):
        self.PrepareDC(dc)

        gdc = self.wrapDC(dc)#right here

        ordered_selection = []
        for obj in self.contents[::-1]:
            if obj in self.selection:
                obj.draw(gdc, True)
                ordered_selection.append(obj)
            else:
                obj.draw(gdc, False)

        if self.curTool is not None:
            self.curTool.draw(gdc)

        for obj in ordered_selection:
            obj.drawHandles(gdc)

what i can do for dot that?

hi i ve got this errors
Traceback (most recent call last):
   File "C:\Users\oscar\Documents\NetBeansProjects\latest\src\main.py",
line 251, in OnNewDocument
     newo = drawkernel.skth.DrawArea(self.Notebook, -1)
   File "C:\Users\oscar\Documents\NetBeansProjects\latest\src\drawkernel
\skth.py", line 13, in __init__
     self._initBuffer()
   File "C:\Users\oscar\Documents\NetBeansProjects\latest\src\drawkernel
\skth.py", line 126, in _initBuffer
     self.drawContents(dc)
   File "C:\Users\oscar\Documents\NetBeansProjects\latest\src\drawkernel
\skth.py", line 104, in drawContents
     gdc = self.wrapDC(dc)
AttributeError: 'DrawArea' object has no attribute 'wrapDC'

but if i got defined the wrapDC just like this

         self.wrapDC = lambda dc: dc

Are you sure that this ^^ ...

and then is called here...

def drawContents(self, dc):
         self.PrepareDC(dc)

         gdc = self.wrapDC(dc)#right here

... happens before this ^^ ?

···

On 3/7/10 3:03 PM, iozk_Live wrote:

--
Robin Dunn
Software Craftsman

no that ^^ but i can solve put it after the 'draw' def __init__() code
class.

but i dont know what is this if variable or array. i don't think that
is one array
self.tools = {
            'select' : (self.selectIcon,
drawKernel.drawobjects.SelectDrawingTool()),
            'line' : (self.lineIcon,
drawKernel.drawobjects.LineDrawingTool()),
            'polygon' : (self.polygonIcon,
drawKernel.drawobjects.PolygonDrawingTool()),
            'scribble': (self.scribbleIcon,
drawKernel.drawobjects.ScribbleDrawingTool()),
            'rect' : (self.rectIcon,
drawKernel.drawobjects.RectDrawingTool()),
            'ellipse' : (self.ellipseIcon,
drawKernel.drawobjects.EllipseDrawingTool()),
            'text' : (self.textIcon,
drawKernel.drawobjects.TextDrawingTool())
        }

but here is defined like array

def setCurrentTool(self, toolName):
        toolIcon, tool = self.tools[toolName]#here
        if self.curToolIcon is not None:
            self.curToolIcon.SetValue(False)

        toolIcon.SetValue(True)
        self.curToolName = toolName
        self.curToolIcon = toolIcon
        self.curTool = tool
        drawKernel.skth.DrawArea.SetCursor(tool.getDefaultCursor())

and give me this error

Traceback (most recent call last):
  File "C:\Users\oscar\Documents\NetBeansProjects\latest\src\main.py",
line 370, in <module>
    Frame(None, -1, "Toon Dev Studio").Show()
  File "C:\Users\oscar\Documents\NetBeansProjects\latest\src\main.py",
line 74, in __init__
    self.setCurrentTool("select")
  File "C:\Users\oscar\Documents\NetBeansProjects\latest\src\main.py",
line 357, in setCurrentTool
    toolIcon, tool = self.tools[toolName]
AttributeError: 'Frame' object has no attribute 'tools'

···

iozk_Live wrote:

no that ^^ but i can solve put it after the 'draw' def __init__() code
class.

but i dont know what is this if variable or array. i don't think that
is one array
self.tools = {
            'select' : (self.selectIcon,
drawKernel.drawobjects.SelectDrawingTool()),
            'line' : (self.lineIcon,
drawKernel.drawobjects.LineDrawingTool()),
            'polygon' : (self.polygonIcon,
drawKernel.drawobjects.PolygonDrawingTool()),
            'scribble': (self.scribbleIcon,
drawKernel.drawobjects.ScribbleDrawingTool()),
            'rect' : (self.rectIcon,
drawKernel.drawobjects.RectDrawingTool()),
            'ellipse' : (self.ellipseIcon,
drawKernel.drawobjects.EllipseDrawingTool()),
            'text' : (self.textIcon,
drawKernel.drawobjects.TextDrawingTool())
        }

this is a dictionary -- indexed by a string: the name of the tool.

but here is defined like array

def setCurrentTool(self, toolName):
        toolIcon, tool = self.tools[toolName]#here

that's how you access a dict...

and give me this error
    toolIcon, tool = self.tools[toolName]
AttributeError: 'Frame' object has no attribute 'tools'

so that means that "self.tools" was not defined for the Frame -- what was it defined in?

http://wiki.wxpython.org/MakingSampleApps

this is pretty basic python stuff -- you really do need to "get" how OO works in Python in order to use wxPython. "self" is the convention for the name of the current instance of an object -- since it is a convention, just seeing the line:

self.something = ...

doesn't tell us a thing about what class that is defined in.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov