The following program gets a TextCtrl's text attributes and sets them
back unchanged. However it reports that the font size is 124, and after
resetting the attributes the text becomes that size. That is, the
window displays a normal-size "foo" and a gigantic "bar". Anyone know
what's going on?

This is WxPython 2.6 on Python 2.5 on Windows XP.

----------------------------------

import sys
import wx

class MyApp (wx.App):

   def __init__ (self):
      wx.App.__init__(self, redirect=0)

   def OnInit (self):
      top = wx.Frame(None, size=(500, 300))
      txt = wx.TextCtrl(top, -1, "foo\n", (-1, -1), (400, 200),
                        wx.TE_RICH|wx.TE_READONLY|wx.TE_MULTILINE)
      top.Show()

      attrs = wx.TextAttr()
      txt.GetStyle(0, attrs)
      font = attrs.GetFont()
      print "font face", font.GetFaceName()  # prints MS Shell Dlg 2
      print "font family", font.GetFamily()  # prints 74
      print "font size", font.GetPointSize() # prints 124!
      txt.SetDefaultStyle(attrs)
      txt.AppendText("bar\n")
      return True

app = MyApp()
app.MainLoop()

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to