Hi, I'm writing a small app in wxpython, on a linux box. I just want to display a graphic and play a short ogg when a gui button is clicked.

Started out as a memory card game, now I just want to display the graphic and play a sound when one of the buttons is pushed. I'm defining the gui buttons as c1, c2, c3 and so on. the graphic and ogg file would be different for each button of course, so I'd like to define them with the rest of the button.

#!/usr/bin/python

# gridsizer.py

import wx

class GridSizer(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(750, 590))
	card1='/full/path/to/png/A.png'
	default='/full/path/to/png/mzzbunns.png'
        menubar = wx.MenuBar()
        file = wx.Menu()
        file.Append(1, '&Quit', 'Exit')
        menubar.Append(file, '&File')
        self.SetMenuBar(menubar)

        self.Bind(wx.EVT_MENU, self.OnClose, id=1)

        sizer = wx.BoxSizer(wx.VERTICAL)

	c1  = wx.BitmapButton(self, -1, wx.Bitmap('/full/path/to/png/A.png'))
	c2  = wx.BitmapButton(self, -1, wx.Bitmap('/full/path/to/png/T.png'))
	c3  = wx.BitmapButton(self, -1, wx.Bitmap('/full/path/to/png/H.png'))
	c4  = wx.BitmapButton(self, -1, wx.Bitmap('/full/path/to/png/E.png'))
	c5  = wx.BitmapButton(self, -1, wx.Bitmap('/full/path/to/png/N.png'))
	c6  = wx.BitmapButton(self, -1, wx.Bitmap('/full/path/to/png/S.png'))
	c7  = wx.BitmapButton(self, -1, wx.Bitmap('/full/path/to/png/O.png'))
	c8  = wx.BitmapButton(self, -1, wx.Bitmap('/full/path/to/png/B.png'))
	c9  = wx.BitmapButton(self, -1, wx.Bitmap('/full/path/to/png/C.png'))
	c10  = wx.BitmapButton(self, -1, wx.Bitmap('/full/path/to/png/D.png'))
	c11  = wx.BitmapButton(self, -1, wx.Bitmap('/full/path/to/png/F.png'))
	c12  = wx.BitmapButton(self, -1, wx.Bitmap('/full/path/to/png/G.png'))
        gs = wx.GridSizer(3, 4, 15, 15)	
	gs.Add(c1)
	gs.Add(c2)
	gs.Add(c3)
	gs.Add(c4)
	gs.Add(c5)
	gs.Add(c6)
	gs.Add(c7)
	gs.Add(c8)
	gs.Add(c9)
	gs.Add(c10)
	gs.Add(c11)
	gs.Add(c12)
        sizer.Add(gs, 1, wx.EXPAND)
        self.SetSizer(sizer)
        self.Centre()
        self.Show(True)

    def OnClose(self, event):
        self.Close()

app = wx.App()
GridSizer(None, -1, 'Mzz Bunns')
app.MainLoop()

I'd like the graphic to be fairly large, to take up the whole main frame for 5 seconds or so, and die when clicked on, or just die after a few seconds.

Thanks much for any help.....

David

Well then i would have a look at wxStaticBitmap, that will handle your images no worries, then you can look at wx.Media.MediaControl for playing your files. Then you just have to bind the buttons in the usual way.

wx.StaticBitmap
http://www.wxpython.org/docs/api/wx.StaticBitmap-class.html

wx.Media.MediaCtrl
http://www.wxpython.org/docs/api/wx.media.MediaCtrl-class.html

I wrote tutorials on how to use both of them, find them at: http://wxpython.webs.com/tutorials.htm Take a look at tutorial 5 and 6

commented: good refs +11
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.