Ok, I've been going through these tutorials for both PyGame and wxPython, but I've hit a big speed bump. In each tutorial, I've gotten to the point where I need to "import" or "load" images for various purposes (animation, icons, etc.). Each time I follow the tutorial, I can't quite get it right... please don't tell me "Hey, you can't use the pictures in the tutorial example because those are not the directories, paths, or pics that are on your computer". I know that already. Help me to figure out (please provide code and examples in your posts) how to use images on my computer. I will provide the code in the tutorials, links to the tutorials, and the error I get from my code. This might require you to answer with some depth and instruction, but it would be a big help to me and my progress in learning python!
P.S.
- When I show my code, it is not the only thing I tried. Don't just tell me I'm wrong, provide a clear answer.
- It is basically the same problem in wxPython and PyGame... it's all about making images work in these apps
I've been studying and working very hard in python, and this has really stopped me dead in my tracks. Please provide whatever help you can.
What the tutorial says to do:
What I tried (but not the only thing I tried):
P.S.
- When I show my code, it is not the only thing I tried. Don't just tell me I'm wrong, provide a clear answer.
- It is basically the same problem in wxPython and PyGame... it's all about making images work in these apps
I've been studying and working very hard in python, and this has really stopped me dead in my tracks. Please provide whatever help you can.
What the tutorial says to do:
Code:
#!/usr/bin/python # menuexample.py import wx class MenuExample(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(250, 150)) menubar = wx.MenuBar() file = wx.Menu() quit = wx.MenuItem(file, 1, '&Quit\tCtrl+Q') quit.SetBitmap(wx.Bitmap('icons/exit.png')) file.AppendItem(quit) self.Bind(wx.EVT_MENU, self.OnQuit, id=1) menubar.Append(file, '&File') self.SetMenuBar(menubar) self.Centre() self.Show(True) def OnQuit(self, event): self.Close() app = wx.App() MenuExample(None, -1, '') app.MainLoop()
Code:
#!/usr/bin/python # menuexample.py import wx class MenuExample(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(250, 150)) menubar = wx.MenuBar() file = wx.Menu() quit = wx.MenuItem(file, 1, '&Quit\tCtrl+Q') quit.SetBitmap(wx.Bitmap('C:\Python24\tony.bmp')) file.AppendItem(quit) self.Bind(wx.EVT_MENU, self.OnQuit, id=1) menubar.Append(file, '&File') self.SetMenuBar(menubar) self.Centre() self.Show(True) def OnQuit(self, event): self.Close() app = wx.App() MenuExample(None, -1, '') app.MainLoop()
Comment