13db99f1f5
* wx.lib.flagart: contains icons of the flags of many countries. * wx.lib.art.img2pyartprov: makes images embedded in a python file with img2py available via the wx.ArtProvider. * wx.lib.langlistctrl: A wx.ListCtrl for selecting a language, which uses the country flag icons. * An I18N sample for the demo. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43737 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
99 lines
2.7 KiB
Python
99 lines
2.7 KiB
Python
|
|
import wx
|
|
from wx.lib.art import flagart, img2pyartprov
|
|
|
|
FlagArtProvider = None
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
class TestPanel(wx.Panel):
|
|
def __init__(self, parent, log):
|
|
self.log = log
|
|
wx.Panel.__init__(self, parent, -1)
|
|
|
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
|
self.SetSizer(sizer)
|
|
|
|
title = wx.StaticText(self, -1, "Img2PyArtProvider")
|
|
title.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD))
|
|
sizer.Add(title, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
|
|
|
|
line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
|
|
sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
|
|
sizer.Add((20,20))
|
|
|
|
box = wx.BoxSizer(wx.HORIZONTAL)
|
|
ch = wx.ComboBox(self, -1, 'BLANK', choices=flagart.index,
|
|
style=wx.CB_DROPDOWN|wx.CB_READONLY)
|
|
self.Bind(wx.EVT_COMBOBOX, self.OnSelectCountry, ch)
|
|
box.Add(ch, 0, wx.ALIGN_CENTER_VERTICAL)
|
|
box.Add((50,10))
|
|
|
|
bmp = wx.EmptyBitmap(32,22)
|
|
self.bmpFlag = wx.StaticBitmap(self, -1, bmp)
|
|
box.Add(self.bmpFlag, 0, wx.ALIGN_CENTER_VERTICAL)
|
|
|
|
sizer.Add(box, 0, wx.CENTER|wx.ALL, 10)
|
|
|
|
self.country = 'BLANK'
|
|
global FlagArtProvider
|
|
if FlagArtProvider is None:
|
|
FlagArtProvider = img2pyartprov.Img2PyArtProvider(flagart,
|
|
artIdPrefix='wx.ART_')
|
|
wx.ArtProvider.Push(FlagArtProvider)
|
|
|
|
self.getArt()
|
|
|
|
|
|
def OnSelectCountry(self, evt):
|
|
self.log.write("OnSelectCountry\n")
|
|
self.country = evt.GetString()
|
|
self.getArt()
|
|
|
|
|
|
def getArt(self):
|
|
bmp = wx.ArtProvider.GetBitmap('wx.ART_'+self.country, wx.ART_OTHER, (32,22))
|
|
if not bmp.Ok():
|
|
bmp = wx.EmptyBitmap(32,22)
|
|
self.clearBmp(bmp)
|
|
self.bmpFlag.SetBitmap(bmp)
|
|
|
|
|
|
def clearBmp(self, bmp):
|
|
dc = wx.MemoryDC()
|
|
dc.SelectObject(bmp)
|
|
dc.SetBackground(wx.Brush("white"))
|
|
dc.Clear()
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
def runTest(frame, nb, log):
|
|
win = TestPanel(nb, log)
|
|
return win
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
overview = """<html><body>
|
|
<h2><center>Img2PyArtProvider</center></h2>
|
|
|
|
Img2PyArtProvider is an ArtProvider class that publishes images from
|
|
modules generated by img2py.
|
|
|
|
<p>
|
|
This sample shows how to access the flag images in wx.lib.art.flagart
|
|
via the ArtProvider.
|
|
|
|
|
|
</body></html>
|
|
"""
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
import sys,os
|
|
import run
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
|
|