]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/Img2PyArtProvider.py
3 from wx
.lib
.art
import flagart
, img2pyartprov
7 #----------------------------------------------------------------------
9 class TestPanel(wx
.Panel
):
10 def __init__(self
, parent
, log
):
12 wx
.Panel
.__init
__(self
, parent
, -1)
14 sizer
= wx
.BoxSizer(wx
.VERTICAL
)
17 title
= wx
.StaticText(self
, -1, "Img2PyArtProvider")
18 title
.SetFont(wx
.Font(18, wx
.SWISS
, wx
.NORMAL
, wx
.BOLD
))
19 sizer
.Add(title
, 0, wx
.ALIGN_CENTRE|wx
.ALL
, 5)
21 line
= wx
.StaticLine(self
, -1, size
=(20,-1), style
=wx
.LI_HORIZONTAL
)
22 sizer
.Add(line
, 0, wx
.GROW|wx
.ALIGN_CENTER_VERTICAL|wx
.ALL
, 5)
25 box
= wx
.BoxSizer(wx
.HORIZONTAL
)
26 ch
= wx
.ComboBox(self
, -1, 'BLANK', choices
=flagart
.index
,
27 style
=wx
.CB_DROPDOWN|wx
.CB_READONLY
)
28 self
.Bind(wx
.EVT_COMBOBOX
, self
.OnSelectCountry
, ch
)
29 box
.Add(ch
, 0, wx
.ALIGN_CENTER_VERTICAL
)
32 bmp
= wx
.EmptyBitmap(32,22)
33 self
.bmpFlag
= wx
.StaticBitmap(self
, -1, bmp
)
34 box
.Add(self
.bmpFlag
, 0, wx
.ALIGN_CENTER_VERTICAL
)
36 sizer
.Add(box
, 0, wx
.CENTER|wx
.ALL
, 10)
38 self
.country
= 'BLANK'
39 global FlagArtProvider
40 if FlagArtProvider
is None:
41 FlagArtProvider
= img2pyartprov
.Img2PyArtProvider(flagart
,
42 artIdPrefix
='wx.ART_')
43 wx
.ArtProvider
.Push(FlagArtProvider
)
48 def OnSelectCountry(self
, evt
):
49 self
.log
.write("OnSelectCountry\n")
50 self
.country
= evt
.GetString()
55 bmp
= wx
.ArtProvider
.GetBitmap('wx.ART_'+self
.country
, wx
.ART_OTHER
, (32,22))
57 bmp
= wx
.EmptyBitmap(32,22)
59 self
.bmpFlag
.SetBitmap(bmp
)
62 def clearBmp(self
, bmp
):
65 dc
.SetBackground(wx
.Brush("white"))
68 #----------------------------------------------------------------------
70 def runTest(frame
, nb
, log
):
71 win
= TestPanel(nb
, log
)
74 #----------------------------------------------------------------------
78 overview
= """<html><body>
79 <h2><center>Img2PyArtProvider</center></h2>
81 Img2PyArtProvider is an ArtProvider class that publishes images from
82 modules generated by img2py.
85 This sample shows how to access the flag images in wx.lib.art.flagart
94 if __name__
== '__main__':
97 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])