using lib.agw.aui and WIT

I am getting this exception just after opening up the WIT.

   File "c:\python27\lib\site-packages\wx-2.9.2-msw\wx\lib\agw\aui\framemanager.py", line 8544, in OnRender
     art.DrawCaption(dc, self._frame, part.pane.caption, part.rect, part.pane)
   File "c:\python27\lib\site-packages\wx-2.9.2-msw\wx\lib\agw\aui\dockart.py", line 570, in DrawCaption
     self.DrawIcon(dc, rect, pane)
   File "c:\python27\lib\site-packages\wx-2.9.2-msw\wx\lib\agw\aui\dockart.py", line 528, in DrawIcon
     dc.DrawBitmap(pane.icon, rect.x+2, rect.y+(rect.height-pane.icon.GetHeight())/2, True)
   File "c:\python27\lib\site-packages\wx-2.9.2-msw\wx\_gdi.py", line 3770, in DrawBitmap
     return _gdi_.DC_DrawBitmap(*args, **kwargs)
TypeError: in method 'DC_DrawBitmap', expected argument 2 of type 'wxBitmap const &'

Python 2.9.2.4 with wx.lib from svn.

Had no problem until today with this, so thought it was me trying out different art providers, but it seems that the following SetIcon call in my code is the cause.

         icon = uiutils.GetBitmap('twcb-64.png', True, True)
         self.view.SetIcon(icon)
         print icon, type(icon)
         print self.view, type(self.view)

The two print lines:
<wx._gdi.Icon; proxy of <Swig Object of type 'wxIcon *' at 0x253b0c4> > <class 'wx._gdi.Icon'>

<twcbsrc.views.cellarbook.AppcbView; proxy of <Swig Object of type 'wxFrame *' at 0x4e09940> > <class 'twcbsrc.views.cellarbook.AppcbView'>

If I comment out the SetIcon call then it is working without problem.

Within self.view I have two AuiNotebook which are setup like this:

         bookStyle = aui.AUI_NB_DEFAULT_STYLE
         bookStyle &= ~(aui.AUI_NB_CLOSE_ON_ACTIVE_TAB)
         self._auiBookTop = aui.AuiNotebook(self.topPane, agwStyle=bookStyle,
                                         name='topAuiBook')
# self._auiBookTop.SetArtProvider(tabArt)

Anyone has an idea on this as I am lost.

Werner

Actually it is the GetBitmap line which causes the problem. I am still confused as it is just getting an image from disk.

def GetBitmap(imgstr, imgfld=False, icon=False):
     if imgfld:
         bDir = os.path.join(wx.GetApp().baseDir, "images")
     else:
         bDir = os.path.join(wx.GetApp().baseDir, "icons")
     imgFile = os.path.join(bDir, imgstr)
     if os.path.isfile(imgFile):
         if icon:
             bmpTmp = wx.Image(imgFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
             bmp = wx.NullIcon
             bmp.CopyFromBitmap(bmpTmp)
         else:
             bmp = wx.Image(imgFile,
                 wx.BITMAP_TYPE_ANY).Rescale(16, 16).ConvertToBitmap()
     else:
         logging.error("image not found: %s" % imgFile)

     return bmp

I am still confused:-(

Werner

···

On 11/05/2011 04:19 PM, werner wrote:

I am getting this exception just after opening up the WIT.

  File "c:\python27\lib\site-packages\wx-2.9.2-msw\wx\lib\agw\aui\framemanager.py", line 8544, in OnRender
    art.DrawCaption(dc, self._frame, part.pane.caption, part.rect, part.pane)
  File "c:\python27\lib\site-packages\wx-2.9.2-msw\wx\lib\agw\aui\dockart.py", line 570, in DrawCaption
    self.DrawIcon(dc, rect, pane)
  File "c:\python27\lib\site-packages\wx-2.9.2-msw\wx\lib\agw\aui\dockart.py", line 528, in DrawIcon
    dc.DrawBitmap(pane.icon, rect.x+2, rect.y+(rect.height-pane.icon.GetHeight())/2, True)
  File "c:\python27\lib\site-packages\wx-2.9.2-msw\wx\_gdi.py", line 3770, in DrawBitmap
    return _gdi_.DC_DrawBitmap(*args, **kwargs)
TypeError: in method 'DC_DrawBitmap', expected argument 2 of type 'wxBitmap const &'

Python 2.9.2.4 with wx.lib from svn.

Had no problem until today with this, so thought it was me trying out different art providers, but it seems that the following SetIcon call in my code is the cause.

        icon = uiutils.GetBitmap('twcb-64.png', True, True)
        self.view.SetIcon(icon)
        print icon, type(icon)
        print self.view, type(self.view)

The two print lines:
<wx._gdi.Icon; proxy of <Swig Object of type 'wxIcon *' at 0x253b0c4> > <class 'wx._gdi.Icon'>

<twcbsrc.views.cellarbook.AppcbView; proxy of <Swig Object of type 'wxFrame *' at 0x4e09940> > <class 'twcbsrc.views.cellarbook.AppcbView'>

If I comment out the SetIcon call then it is working without problem.

You are creating a wx.Icon instead of a wx.Bitmap because of using the wx.NullIcon.

···

On 11/5/11 8:27 AM, werner wrote:

Actually it is the GetBitmap line which causes the problem. I am still
confused as it is just getting an image from disk.

def GetBitmap(imgstr, imgfld=False, icon=False):
if imgfld:
bDir = os.path.join(wx.GetApp().baseDir, "images")
else:
bDir = os.path.join(wx.GetApp().baseDir, "icons")
imgFile = os.path.join(bDir, imgstr)
if os.path.isfile(imgFile):
if icon:
bmpTmp = wx.Image(imgFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
bmp = wx.NullIcon
bmp.CopyFromBitmap(bmpTmp)
else:
bmp = wx.Image(imgFile,
wx.BITMAP_TYPE_ANY).Rescale(16, 16).ConvertToBitmap()
else:
logging.error("image not found: %s" % imgFile)

return bmp

I am still confused:-(

--
Robin Dunn
Software Craftsman

Actually it is the GetBitmap line which causes the problem. I am still
confused as it is just getting an image from disk.

def GetBitmap(imgstr, imgfld=False, icon=False):
if imgfld:
bDir = os.path.join(wx.GetApp().baseDir, "images")
else:
bDir = os.path.join(wx.GetApp().baseDir, "icons")
imgFile = os.path.join(bDir, imgstr)
if os.path.isfile(imgFile):
if icon:
bmpTmp = wx.Image(imgFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
bmp = wx.NullIcon
bmp.CopyFromBitmap(bmpTmp)
else:
bmp = wx.Image(imgFile,
wx.BITMAP_TYPE_ANY).Rescale(16, 16).ConvertToBitmap()
else:
logging.error("image not found: %s" % imgFile)

return bmp

I am still confused:-(

You are creating a wx.Icon instead of a wx.Bitmap because of using the wx.NullIcon.

If icon is True then I think I use an wx.Icon which is what I need for SetIcon, no?

I know my naming of stuff could be better - but .......:-[ . Will have another look at all this sometimes tomorrow.

Werner

···

On 11/05/2011 07:41 PM, Robin Dunn wrote:

On 11/5/11 8:27 AM, werner wrote:

My old code somehow stepped on something which I can't explain.

Anyhow after reworking my code (borrowed some from MakeIcon in the demo) the problem went away.

Basically instead of starting with NullIcon I use wx.IconFromBitmap when needing an icon.

Werner

···

On 11/05/2011 07:41 PM, Robin Dunn wrote:

On 11/5/11 8:27 AM, werner wrote:

Actually it is the GetBitmap line which causes the problem. I am still
confused as it is just getting an image from disk.

def GetBitmap(imgstr, imgfld=False, icon=False):
if imgfld:
bDir = os.path.join(wx.GetApp().baseDir, "images")
else:
bDir = os.path.join(wx.GetApp().baseDir, "icons")
imgFile = os.path.join(bDir, imgstr)
if os.path.isfile(imgFile):
if icon:
bmpTmp = wx.Image(imgFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
bmp = wx.NullIcon
bmp.CopyFromBitmap(bmpTmp)
else:
bmp = wx.Image(imgFile,
wx.BITMAP_TYPE_ANY).Rescale(16, 16).ConvertToBitmap()
else:
logging.error("image not found: %s" % imgFile)

return bmp

I am still confused:-(

You are creating a wx.Icon instead of a wx.Bitmap because of using the wx.NullIcon.