loading image failed

hello

I got an error which is "Image file is not of type 9." when I coded
like this: image = wx.Image("edit.png",
wx.BITMAP_TYPE_ANY).ConvertToBitmap()

there is also same error though I use BITMAP_TYPE_PNG

can someone recognize this problem?

Wonjun, Choi

Screenshot at 2011-12-08 16:43:27.png

I used wx2.8.11.0 version.

You didn't used it properly:

···

On Wed, 7 Dec 2011 23:44:31 -0800 (PST) "Wonjun, Choi" <wonjunchoi001@gmail.com> wrote:

I got an error which is "Image file is not of type 9." when I coded
like this: image = wx.Image("edit.png",
wx.BITMAP_TYPE_ANY).ConvertToBitmap()

--
He who trains his tongue to quote the learned sages, will be known
far and wide as a smart ass.
    -- Howard Kandel

The first thing to do is make sure the image file is good (and that it is a PNG) -- try looking at it in other software.

I'd also check if it's an obscure PNG type -- PNG can be encoded in a number of ways: palletted, RGB, RGBA, I'm not sure what else -- wx may not support every one (though I think it uses libpng, so I'd think it would be pretty complete).

-Chris

···

On 12/7/11 11:46 PM, Wonjun, Choi wrote:

I used wx2.8.11.0 version.

--
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

And the 3rd step would be to make a small runnable sample and attach it and the image file to a message sent to this mail list. MakingSampleApps - wxPyWiki

···

On 12/8/11 9:13 AM, Chris.Barker wrote:

On 12/7/11 11:46 PM, Wonjun, Choi wrote:

I used wx2.8.11.0 version.

The first thing to do is make sure the image file is good (and that it
is a PNG) -- try looking at it in other software.

I'd also check if it's an obscure PNG type -- PNG can be encoded in a
number of ways: palletted, RGB, RGBA, I'm not sure what else -- wx may
not support every one (though I think it uses libpng, so I'd think it
would be pretty complete).

--
Robin Dunn
Software Craftsman

···

class Editor(wx.Frame):
def init(self):
wx.Frame.init(self, None)
self.editor = stc.StyledTextCtrl(self)

    ## register some images for use in the AutoComplete box.

wx.InitAllImageHandlers()

    image = wx.Image("icon/class.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap()
    self.editor.RegisterImage(1, image)
    image = wx.Image("icon/function.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap()
    self.editor.RegisterImage(2, image)

is working fine. but

class ToolbarFrame(wx.Frame):
def init(self, parent, id):

    self.p1 = CT.FileBrowser(self, './work') # wx.GetHomeDir()
    self.p2 = MyNotebook(self)
    self.Bind(wx.EVT_TOOL, lambda event:self.p2.GetCurrentPage().OnAddPython(event), id=ICON_MENU_BUTTON_PYTHON)

class TestPanel(wx.Panel):
def init(self, parent):

def OnAddPython(self, event=None, idx=0):
      ...
      self.editor = STC(self.scrolled_panel)

class STC(st.StyledTextCtrl):
def init(self, *args, **kwargs):

def OnStyle(self, event):
    # Delegate to custom lexer object if one exists
    if self.custlex:
        self.custlex.StyleText(event)
    else:
        event.Skip()

def SetLexer(self, lexerid, lexer=None):
    """Overrides StyledTextCtrl.SetLexer
    Adds optional param to pass in custom container
    lexer object.
    """
    self.custlex = lexer
    super(STC, self).SetLexer(lexerid)

class VowelLexer(object):
def init(self, lang):

def StyleText(self, event):
     ...
     def displaystyle(lang, stcvar, stvar):

           image = wx.Image("./icon/class.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap()
           stcvar.RegisterImage(1, image)

is not working. there is same error.

Wonjun, Choi

I solved my problem.
thank you all

Wonjun, Choi