]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/FontEnumerator.py 
   2  from  wxPython
. wx 
import  *    4  #----------------------------------------------------------------------    6  ## class MyFontEnumerator(wxFontEnumerator):    7  ##     def __init__(self, list):    8  ##         wxFontEnumerator.__init__(self)   11  ##     def OnFacename(self, face):   12  ##         self.list.append(face)   17  class  TestPanel ( wxPanel
):   18      def  __init__ ( self
,  parent
,  log
):   19          wxPanel
.__ init
__ ( self
,  parent
, - 1 )   22  ##         e = MyFontEnumerator(list)   23  ##         e.EnumerateFacenames()   25          e 
=  wxFontEnumerator ()   26          e
. EnumerateFacenames ()   27          list  =  e
. GetFacenames ()   31          wxStaticText ( self
, - 1 ,  "Face names:" , ( 15 ,  50 ), ( 65 ,  18 ))   32          self
. lb1 
=  wxListBox ( self
, - 1 , ( 80 ,  50 ), ( 200 ,  250 ),   34          EVT_LISTBOX ( self
,  self
. lb1
. GetId (),  self
. OnSelect
)   36          self
. txt 
=  wxStaticText ( self
, - 1 ,  "Sample text..." , ( 285 ,  50 ))   38          self
. lb1
. SetSelection ( 0 )   41      def  OnSelect ( self
,  evt
):   42          face 
=  self
. lb1
. GetStringSelection ()   43          font 
=  wxFont ( 28 ,  wxDEFAULT
,  wxNORMAL
,  wxNORMAL
,  false
,  face
)   44          self
. txt
. SetFont ( font
)   45          self
. txt
. SetSize ( self
. txt
. GetBestSize ())   47  ##         st = font.GetNativeFontInfo().ToString()   48  ##         ni2 = wxNativeFontInfo()   50  ##         font2 = wxFontFromNativeInfo(ni2)   52  #----------------------------------------------------------------------   54  def  runTest ( frame
,  nb
,  log
):   55      win 
=  TestPanel ( nb
,  log
)   58  #----------------------------------------------------------------------   68  wxFontEnumerator enumerates either all available fonts on the system or only the ones with given attributes - either only fixed-width (suited for use in programs such as terminal emulators and the like) or the fonts available in the given encoding.   73  if  __name__ 
==  '__main__' :   76      run
. main ([ '' ,  os
. path
. basename ( sys
. argv
[ 0 ])])