]>
Commit | Line | Data |
---|---|---|
be05b434 RD |
1 | import wx |
2 | ||
3 | filenames = ["image.bmp", "image.gif", "image.jpg", "image.png" ] | |
4 | ||
5 | class TestFrame(wx.Frame): | |
6 | def __init__(self): | |
7 | wx.Frame.__init__(self, None, title="Loading Images") | |
8 | p = wx.Panel(self) | |
9 | ||
10 | fgs = wx.FlexGridSizer(cols=2, hgap=10, vgap=10) | |
11 | for name in filenames: | |
12 | # load the image from the file | |
13 | img1 = wx.Image(name, wx.BITMAP_TYPE_ANY) | |
14 | ||
15 | # Scale the original to another wx.Image | |
16 | w = img1.GetWidth() | |
17 | h = img1.GetHeight() | |
18 | img2 = img1.Scale(w/2, h/2) | |
19 | ||
20 | # turn them into static bitmap widgets | |
21 | sb1 = wx.StaticBitmap(p, -1, wx.BitmapFromImage(img1)) | |
22 | sb2 = wx.StaticBitmap(p, -1, wx.BitmapFromImage(img2)) | |
23 | ||
24 | # and put them into the sizer | |
25 | fgs.Add(sb1) | |
26 | fgs.Add(sb2) | |
27 | ||
28 | p.SetSizerAndFit(fgs) | |
29 | self.Fit() | |
30 | ||
31 | ||
32 | app = wx.PySimpleApp() | |
33 | frm = TestFrame() | |
34 | frm.Show() | |
35 | app.MainLoop() |