Fail on trying to load .png: PyAssertionError

Hey folks - trying to run a piece of code (listed at bottom): modified from the “getting started” tutorial;

When running gives the following error:

File “C:\Users\crobertson\Desktop\Development\Programming Assets\Python\TEMP files\gui_test 2.py”, line 55, in UI_init
“exit.png”,wx.BITMAP_TYPE_PNG
File “C:\Python27\lib\site-packages\wx-3.0-msw\wx_core.py”, line 2882, in init
core.Image_swiginit(self,core.new_Image(*args, **kwargs))
PyAssertionError: C++ assertion “strcmp(setlocale(LC_ALL, NULL), “C”) == 0” failed at …\src\common\intl.cpp(1449) in wxLocale::GetInfo(): You probably called setlocale() directly instead of using wxLocale and now there is a mismatch between C/C++ and Windows locale.
Things are going to break, please only change locale by creating wxLocale objects to avoid this!

``

This is the code it runs from

class display(wx.Frame):
#create a child class called “display” which is inherited from the “wx.Frame()” object
def init(self, *args, **kwargs):
#this addes the original init class to this class
#(in effect we are appending our modifications to it)
super(display,self).init(*args, **kwargs)
self.UI_init()

    def UI_init(self):
           
           menubar=wx.MenuBar()
           filemenu=wx.Menu()

           quit_app=wx.MenuItem(filemenu, APP_EXIT, "&Quit\tCtrl+Q")
           quit_app.SetBitmap(
                   wx.Image(
                           "exit.png",wx.BITMAP_TYPE_PNG
                           ).ConvertToBitmap()
                   )
           
           filemenu.AppendItem(quit_app)

           self.Bind(wx.EVT_MENU,self.OnQuit,id=APP_EXIT)

           

           menubar.Append(filemenu, "&File")
           
           self.SetMenuBar(menubar)

           self.SetSize((400,500))
           self.SetTitle("Icons and Shortcuts TUTORIAL!")
           self.Centre()
           self.Show(True)
           
    def OnQuit(self, e):
            self.Close()

def main():
ex = wx.App()
display(None)
ex.MainLoop()

if name == ‘main’:
main()

``

is that wxPython 3.0.0 or 3.0.2?
I think I have seen treads about this on the wx-dev list but can’t
find the answer at the moment.
Werner

···

On 3/30/2015 16:39, Callum Robertson
wrote:

    Hey folks - trying to run a piece of code (listed

at bottom): modified from the “getting started” tutorial;

When running gives the following error:

File “C:\Users\crobertson\Desktop\Development\Programming
Assets\Python\TEMP files\gui_test 2.py”, line
55, in
UI_init

                  "exit.png",wx.BITMAP_TYPE_PNG

                File "C:\Python27\lib\site-packages\wx-3.0-msw\wx\_core.py", line

2882, in
init

                  _core_.Image_swiginit(self,_core_.new_Image(*args, **kwargs))

            PyAssertionError: C++
              assertion                   "strcmp(setlocale(LC_ALL,

NULL), “C”) == 0"
failed at …..\src\common\intl.cpp(1449) in
wxLocale::GetInfo(): You
probably called setlocale()
directly instead of using
wxLocale and now
there is a
mismatch between C/C++ and Windows
locale.

            Things are

going to break,
please only change locale by
creating wxLocale objects to avoid this!

``

Out of curiosity, do you have an “exit.png” in the same folder as your code?

···

On Monday, March 30, 2015 at 12:03:15 PM UTC-4, Callum Robertson wrote:

Hey folks - trying to run a piece of code (listed at bottom): modified from the “getting started” tutorial;

           quit_app=wx.MenuItem(filemenu, APP_EXIT, "&Quit\tCtrl+Q")
           quit_app.SetBitmap(
                   wx.Image(
                           "exit.png",wx.BITMAP_TYPE_PNG
                           ).ConvertToBitmap()
                   )

``

Hi! Sorry, never got notified of the reply!

I do in deed: I’ve also tried explicitly passing the path to the image.

···

On Wednesday, 1 April 2015 13:29:48 UTC+1, Mike Stover wrote:

Out of curiosity, do you have an “exit.png” in the same folder as your code?

On Monday, March 30, 2015 at 12:03:15 PM UTC-4, Callum Robertson wrote:

Hey folks - trying to run a piece of code (listed at bottom): modified from the “getting started” tutorial;

           quit_app=wx.MenuItem(filemenu, APP_EXIT, "&Quit\tCtrl+Q")
           quit_app.SetBitmap(
                   wx.Image(
                           "exit.png",wx.BITMAP_TYPE_PNG
                           ).ConvertToBitmap()
                   )

``

Oops, sorry, was never notified of the reply!

I am running Python 2.7.9 and WXPython 3.0 according to the wxversion module.

I’m behind a firewall at work, so if I need to update anything it may take a few days to get the installer!

···

On Monday, 30 March 2015 17:25:06 UTC+1, werner wrote:

  On 3/30/2015 16:39, Callum Robertson > wrote:
    Hey folks - trying to run a piece of code (listed

at bottom): modified from the “getting started” tutorial;

When running gives the following error:

File “C:\Users\crobertson\Desktop\ Development\Programming
Assets\Python\TEMP files\gui_test 2.py”, line
55, in
UI_init

                  "exit.png",wx.BITMAP_TYPE_PNG

                File "C:\Python27\lib\site-packages\wx-3.0-msw\wx\_core.py", line

2882, in
init

                  _core_.Image_swiginit(self,_core_.new_Image(*args, **kwargs))

            PyAssertionError: C++
              assertion                   "strcmp(setlocale(LC_ALL,

NULL), “C”) == 0"
failed at …..\src\common\intl.cpp(1449) in
wxLocale::GetInfo(): You
probably called setlocale()
directly instead of using
wxLocale and now
there is a
mismatch between C/C++ and Windows
locale.

            Things are

going to break,
please only change locale by
creating wxLocale objects to avoid this!

``

is that wxPython 3.0.0 or 3.0.2?

I think I have seen treads about this on the wx-dev list but can't

find the answer at the moment.

Werner