home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 February / maximum-cd-2011-02.iso / DiscContents / digsby_setup85.exe / lib / gui / uberwidgets / formattedinput2 / formatprefsmixin.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-11-24  |  3.6 KB  |  76 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from gui.textutil import default_font
  5. from gui.skin.skinparse import makeFont
  6. from util import try_this
  7. from gui.uberwidgets.formattedinput2.formattedinput import FormattedInput
  8. import wx
  9. from gui.uberwidgets.formattedinput2.fontutil import StyleToDict, TupleToFont
  10. from common import setpref, pref
  11. from traceback import print_exc
  12.  
  13. def StyleFromPref(prefname):
  14.     
  15.     try:
  16.         stylepref = pref(prefname)
  17.         if isinstance(stylepref, basestring):
  18.             style = dict(Font = makeFont(stylepref))
  19.         else:
  20.             style = dict(stylepref)
  21.     except Exception:
  22.         print_exc()
  23.         style = { }
  24.  
  25.     if type(style['Font']) is tuple:
  26.         
  27.         try:
  28.             font = TupleToFont(style['Font'])
  29.         except Exception:
  30.             print_exc()
  31.             font = try_this((lambda : makeFont('Arial 10')), default_font())
  32.         except:
  33.             None<EXCEPTION MATCH>Exception
  34.         
  35.  
  36.     None<EXCEPTION MATCH>Exception
  37.     font = style['Font']
  38.     if not (try_this,)((lambda : wx.Colour(*style['TextColour'])), None):
  39.         pass
  40.     fgc = wx.BLACK
  41.     if not (try_this,)((lambda : wx.Colour(*style['BackgroundColour'])), None):
  42.         pass
  43.     bgc = wx.WHITE
  44.     return wx.TextAttr(fgc, bgc, font)
  45.  
  46.  
  47. class FormatPrefsMixin(object):
  48.     
  49.     def SaveStyle(self, prefname):
  50.         style = StyleToDict(self.tc.GetStyle(0)[1])
  51.         pformat = pformat
  52.         import pprint
  53.         print 'saving style:\n%s' % pformat(style)
  54.         setpref(prefname, style)
  55.  
  56.     
  57.     def WhenDefaultLayoutChange(self, src, pref, old, new):
  58.         self.LoadStyle()
  59.  
  60.     
  61.     def LoadStyle(self, prefname):
  62.         self.tc.SetFormat_Single(StyleFromPref(prefname))
  63.  
  64.  
  65.  
  66. class PrefInput(FormattedInput, FormatPrefsMixin):
  67.     
  68.     def __init__(self, parent, value = '', autosize = True, formatOptions = None, multiFormat = True, showFormattingBar = True, rtl = False, skin = None, entercallback = None, validator = wx.DefaultValidator, formatpref = None):
  69.         FormattedInput.__init__(self, parent, value = value, autosize = autosize, formatOptions = formatOptions, multiFormat = multiFormat, showFormattingBar = showFormattingBar, rtl = rtl, skin = skin, validator = validator)
  70.         self.formatpref = formatpref
  71.         if formatpref is not None:
  72.             self.LoadStyle(formatpref)
  73.         
  74.  
  75.  
  76.