[wxPython] MDI frame set icon from mimetypesmanager?

I'm noticing that my MDIParent frame doesn't "take" icons returned from the mimetypesmanager class (it works fine with icons loaded from disk). Is there something I'm missing about one of these two classes?

Here's a simplified version of the code I'm using, when run, the icon remains the default "windows" icon, but if I use the "py.ico" line instead, I get (as expected), a python icon. .doc definitely is registered in the system, and shows up in the mimetypesmanager demo (though there it's converting to a bitmap for display)...

2.3.3pre5, on Win2k, Python 2.2, incidentally.

Ideas anyone?
Mike

from wxPython.wx import *
import os

class MDIEditor(wxMDIParentFrame):
     def __init__(
         self, parent=NULL, id=-1,
         title="Editor",
         pos = wxDefaultPosition, size = wxDefaultSize,
         style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
         name = "editorframe",
     ):
         wxMDIParentFrame.__init__( self, parent, id, title, pos, size, style, name )
         type = wxTheMimeTypesManager.GetFileTypeFromExtension('.doc')
         self.icon = type.GetIcon()
## self.icon = wxIcon( "py.ico", wxBITMAP_TYPE_ICO )
         self.SetIcon( self.icon )

if __name__ == '__main__':
     class MyApp(wxApp):
         def OnInit(self):
             frame = MDIEditor()
             frame.Show(true)
             self.SetTopWindow(frame)
             return true
     app = MyApp(0)
     app.MainLoop()

···

--
_______________________________________
   Mike C. Fletcher
   http://members.rogers.com/mcfletch/

Okay, I've tracked this down, basically, the wxIcon returned from the mimetypes manager has it's size set to 0,0 . If you manually set the size to something reasonable ((16,16) or (32,32), for instance), the icon appears in the frame.

Revised test code with the workaround attached. Comment out SetWidth and SetHeight lines to see failure.

Enjoy all,
Mike

8<_________
from wxPython.wx import *
import os

class MDIEditor(wxFrame):
     """Editor frame using the more familiar Multi-document interface
     """
     def __init__(
         self, parent=NULL, id=-1,
         title="Editor",
         pos = wxDefaultPosition, size = wxDefaultSize,
         style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
         name = "editorframe",
     ):
         wxFrame.__init__( self, parent, id, title, pos, size, style, name )
         type = wxTheMimeTypesManager.GetFileTypeFromExtension('.py')
         info = type.GetIconInfo()
         if info:
             print "info", info
             icon, sourceFile, sourceID = info
             print "w,h", (icon.GetWidth(),icon.GetHeight())
             print 'ok?', icon.Ok()
             icon.SetWidth( 32 )
             icon.SetHeight( 32 )
             self.icon = icon
         else:
             print 'couldnot load icon, using default'
             self.icon = wxIcon( "py.ico", wxBITMAP_TYPE_ICO )
         self.child = wxStaticBitmap( self, -1, wxNullBitmap )
         self.child.SetIcon( self.icon )
         self.SetIcon( self.icon )
if __name__ == '__main__':
     class MyApp(wxApp):
         def OnInit(self):
             wxInitAllImageHandlers()
             frame = MDIEditor()
             frame.Show(true)
             self.SetTopWindow(frame)
             return true
     app = MyApp(0)
     app.MainLoop()

Mike C. Fletcher wrote:

···

I'm noticing that my MDIParent frame doesn't "take" icons returned from the mimetypesmanager class (it works fine with icons loaded from disk). Is there something I'm missing about one of these two classes?

Here's a simplified version of the code I'm using, when run, the icon remains the default "windows" icon, but if I use the "py.ico" line instead, I get (as expected), a python icon. .doc definitely is registered in the system, and shows up in the mimetypesmanager demo (though there it's converting to a bitmap for display)...

2.3.3pre5, on Win2k, Python 2.2, incidentally.

Ideas anyone?
Mike

from wxPython.wx import *
import os

class MDIEditor(wxMDIParentFrame):
    def __init__(
        self, parent=NULL, id=-1,
        title="Editor",
        pos = wxDefaultPosition, size = wxDefaultSize,
        style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
        name = "editorframe",
    ):
        wxMDIParentFrame.__init__( self, parent, id, title, pos, size, style, name )
        type = wxTheMimeTypesManager.GetFileTypeFromExtension('.doc')
        self.icon = type.GetIcon()
## self.icon = wxIcon( "py.ico", wxBITMAP_TYPE_ICO )
        self.SetIcon( self.icon )

if __name__ == '__main__':
    class MyApp(wxApp):
        def OnInit(self):
            frame = MDIEditor()
            frame.Show(true)
            self.SetTopWindow(frame)
            return true
    app = MyApp(0)
    app.MainLoop()

--
_______________________________________
   Mike C. Fletcher
   http://members.rogers.com/mcfletch/

Okay, I've tracked this down, basically, the wxIcon returned from the
mimetypes manager has it's size set to 0,0 . If you manually set the
size to something reasonable ((16,16) or (32,32), for instance), the
icon appears in the frame.

Thanks for digging into this and providing the sample. I'll trace through
the C++ and see what's going on.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!