3 import wx
.richtext 
as rt
 
   6 #---------------------------------------------------------------------- 
   8 class RichTextFrame(wx
.Frame
): 
   9     def __init__(self
, *args
, **kw
): 
  10         wx
.Frame
.__init
__(self
, *args
, **kw
) 
  14         self
.CreateStatusBar() 
  15         self
.SetStatusText("Welcome to wx.richtext.RichTextCtrl!") 
  17         self
.rtc 
= rt
.RichTextCtrl(self
, style
=wx
.VSCROLL|wx
.HSCROLL|wx
.NO_BORDER
); 
  18         wx
.CallAfter(self
.rtc
.SetFocus
) 
  21         self
.rtc
.BeginSuppressUndo() 
  23         self
.rtc
.BeginParagraphSpacing(0, 20) 
  25         self
.rtc
.BeginAlignment(rt
.TEXT_ALIGNMENT_CENTRE
) 
  28         self
.rtc
.BeginFontSize(14) 
  29         self
.rtc
.WriteText("Welcome to wxRichTextCtrl, a wxWidgets control for editing and presenting styled text and images") 
  30         self
.rtc
.EndFontSize() 
  33         self
.rtc
.BeginItalic() 
  34         self
.rtc
.WriteText("by Julian Smart") 
  40         self
.rtc
.WriteImage(images
.get_rt_zebraImage()) 
  42         self
.rtc
.EndAlignment() 
  47         self
.rtc
.WriteText("What can you do with this thing? ") 
  48         self
.rtc
.WriteImage(images
.get_rt_smileyImage()) 
  49         self
.rtc
.WriteText(" Well, you can change text ") 
  51         self
.rtc
.BeginTextColour((255, 0, 0)) 
  52         self
.rtc
.WriteText("colour, like this red bit.") 
  53         self
.rtc
.EndTextColour() 
  55         self
.rtc
.BeginTextColour((0, 0, 255)) 
  56         self
.rtc
.WriteText(" And this blue bit.") 
  57         self
.rtc
.EndTextColour() 
  59         self
.rtc
.WriteText(" Naturally you can make things ") 
  61         self
.rtc
.WriteText("bold ") 
  63         self
.rtc
.BeginItalic() 
  64         self
.rtc
.WriteText("or italic ") 
  66         self
.rtc
.BeginUnderline() 
  67         self
.rtc
.WriteText("or underlined.") 
  68         self
.rtc
.EndUnderline() 
  70         self
.rtc
.BeginFontSize(14) 
  71         self
.rtc
.WriteText(" Different font sizes on the same line is allowed, too.") 
  72         self
.rtc
.EndFontSize() 
  74         self
.rtc
.WriteText(" Next we'll show an indented paragraph.") 
  76         self
.rtc
.BeginLeftIndent(60) 
  79         self
.rtc
.WriteText("It was in January, the most down-trodden month of an Edinburgh winter. An attractive woman came into the cafe, which is nothing remarkable.") 
  80         self
.rtc
.EndLeftIndent() 
  84         self
.rtc
.WriteText("Next, we'll show a first-line indent, achieved using BeginLeftIndent(100, -40).") 
  86         self
.rtc
.BeginLeftIndent(100, -40) 
  89         self
.rtc
.WriteText("It was in January, the most down-trodden month of an Edinburgh winteself.rtc. An attractive woman came into the cafe, which is nothing remarkable.") 
  90         self
.rtc
.EndLeftIndent() 
  94         self
.rtc
.WriteText("Numbered bullets are possible, again using subindents:") 
  96         self
.rtc
.BeginNumberedBullet(1, 100, 60) 
  99         self
.rtc
.WriteText("This is my first item. Note that wxRichTextCtrl doesn't automatically do numbering, but this will be added later.") 
 100         self
.rtc
.EndNumberedBullet() 
 102         self
.rtc
.BeginNumberedBullet(2, 100, 60) 
 105         self
.rtc
.WriteText("This is my second item.") 
 106         self
.rtc
.EndNumberedBullet() 
 110         self
.rtc
.WriteText("The following paragraph is right-indented:") 
 112         self
.rtc
.BeginRightIndent(200) 
 115         self
.rtc
.WriteText("It was in January, the most down-trodden month of an Edinburgh winter. An attractive woman came into the cafe, which is nothing remarkable.") 
 116         self
.rtc
.EndRightIndent() 
 120         self
.rtc
.WriteText("The following paragraph is right-aligned with 1.5 line spacing:") 
 122         self
.rtc
.BeginAlignment(rt
.TEXT_ALIGNMENT_RIGHT
) 
 123         self
.rtc
.BeginLineSpacing(rt
.TEXT_ATTR_LINE_SPACING_HALF
) 
 126         self
.rtc
.WriteText("It was in January, the most down-trodden month of an Edinburgh winter. An attractive woman came into the cafe, which is nothing remarkable.") 
 127         self
.rtc
.EndLineSpacing() 
 128         self
.rtc
.EndAlignment() 
 131         self
.rtc
.WriteText("Other notable features of wxRichTextCtrl include:") 
 133         self
.rtc
.BeginSymbolBullet('*', 100, 60) 
 135         self
.rtc
.WriteText("Compatibility with wxTextCtrl API") 
 136         self
.rtc
.EndSymbolBullet() 
 138         self
.rtc
.BeginSymbolBullet('*', 100, 60) 
 140         self
.rtc
.WriteText("Easy stack-based BeginXXX()...EndXXX() style setting in addition to SetStyle()") 
 141         self
.rtc
.EndSymbolBullet() 
 143         self
.rtc
.BeginSymbolBullet('*', 100, 60) 
 145         self
.rtc
.WriteText("XML loading and saving") 
 146         self
.rtc
.EndSymbolBullet() 
 148         self
.rtc
.BeginSymbolBullet('*', 100, 60) 
 150         self
.rtc
.WriteText("Undo/Redo, with batching option and Undo suppressing") 
 151         self
.rtc
.EndSymbolBullet() 
 153         self
.rtc
.BeginSymbolBullet('*', 100, 60) 
 155         self
.rtc
.WriteText("Clipboard copy and paste") 
 156         self
.rtc
.EndSymbolBullet() 
 158         self
.rtc
.BeginSymbolBullet('*', 100, 60) 
 160         self
.rtc
.WriteText("wxRichTextStyleSheet with named character and paragraph styles, and control for applying named styles") 
 161         self
.rtc
.EndSymbolBullet() 
 163         self
.rtc
.BeginSymbolBullet('*', 100, 60) 
 165         self
.rtc
.WriteText("A design that can easily be extended to other content types, ultimately with text boxes, tables, controls, and so on") 
 166         self
.rtc
.EndSymbolBullet() 
 170         self
.rtc
.WriteText("Note: this sample content was generated programmatically from within the MyFrame constructor in the demo. The images were loaded from inline XPMs. Enjoy wxRichTextCtrl!") 
 172         self
.rtc
.EndParagraphSpacing() 
 174         self
.rtc
.EndSuppressUndo() 
 177     def OnFileOpen(self
, evt
): 
 178         # TODO: Use RichTextBuffer.GetExtWildcard to get the wildcard string 
 179         dlg 
= wx
.FileDialog(self
, "Choose a filename", 
 180                             wildcard
="All files (*.*)|*.*", 
 182         if dlg
.ShowModal() == wx
.ID_OK
: 
 185                 # TODO: use the filter index to determine what file type to use 
 186                 self
.rtc
.LoadFile(path
, rt
.RICHTEXT_TYPE_TEXT
) 
 190     def OnFileSave(self
, evt
): 
 191         if not self
.rtc
.GetFilename(): 
 192             self
.OnFileSaveAs(evt
) 
 196     def OnFileSaveAs(self
, evt
): 
 197         # TODO: Use RichTextBuffer.GetExtWildcard to get the wildcard string 
 198         dlg 
= wx
.FileDialog(self
, "Choose a filename", 
 199                             wildcard
="All files (*.*)|*.*", 
 201         if dlg
.ShowModal() == wx
.ID_OK
: 
 204                 self
.rtc
.SaveFile(path
) 
 207     def OnFileViewHTML(self
, evt
): pass 
 210     def OnFileExit(self
, evt
): 
 214     def OnBold(self
, evt
): 
 215         self
.rtc
.ApplyBoldToSelection() 
 217     def OnItalic(self
, evt
):  
 218         self
.rtc
.ApplyItalicToSelection() 
 220     def OnUnderline(self
, evt
): 
 221         self
.rtc
.ApplyUnderlineToSelection() 
 223     def OnAlignLeft(self
, evt
): 
 224         self
.rtc
.ApplyAlignmentToSelection(rt
.TEXT_ALIGNMENT_LEFT
) 
 226     def OnAlignRight(self
, evt
): 
 227         self
.rtc
.ApplyAlignmentToSelection(rt
.TEXT_ALIGNMENT_RIGHT
) 
 229     def OnAlignCenter(self
, evt
): 
 230         self
.rtc
.ApplyAlignmentToSelection(rt
.TEXT_ALIGNMENT_CENTRE
) 
 232     def OnIndentMore(self
, evt
): 
 233         attr 
= rt
.RichTextAttr() 
 234         attr
.SetFlags(rt
.TEXT_ATTR_LEFT_INDENT
) 
 235         ip 
= self
.rtc
.GetInsertionPoint() 
 236         if self
.rtc
.GetStyle(ip
, attr
): 
 237             r 
= rt
.RichTextRange(ip
, ip
) 
 238             if self
.rtc
.HasSelection(): 
 239                 r 
= self
.rtc
.GetSelectionRange() 
 241             attr
.SetLeftIndent(attr
.GetLeftIndent() + 100) 
 242             attr
.SetFlags(rt
.TEXT_ATTR_LEFT_INDENT
) 
 243             self
.rtc
.SetStyle(r
, attr
) 
 246     def OnIndentLess(self
, evt
): 
 247         attr 
= rt
.RichTextAttr() 
 248         attr
.SetFlags(rt
.TEXT_ATTR_LEFT_INDENT
) 
 249         ip 
= self
.rtc
.GetInsertionPoint() 
 250         if self
.rtc
.GetStyle(ip
, attr
): 
 251             r 
= rt
.RichTextRange(ip
, ip
) 
 252             if self
.rtc
.HasSelection(): 
 253                 r 
= self
.rtc
.GetSelectionRange() 
 255         if attr
.GetLeftIndent() >= 100: 
 256             attr
.SetLeftIndent(attr
.GetLeftIndent() - 100) 
 257             attr
.SetFlags(rt
.TEXT_ATTR_LEFT_INDENT
) 
 258             self
.rtc
.SetStyle(r
, attr
) 
 261     def OnParagraphSpacingMore(self
, evt
): 
 262         attr 
= rt
.RichTextAttr() 
 263         attr
.SetFlags(rt
.TEXT_ATTR_PARA_SPACING_AFTER
) 
 264         ip 
= self
.rtc
.GetInsertionPoint() 
 265         if self
.rtc
.GetStyle(ip
, attr
): 
 266             r 
= rt
.RichTextRange(ip
, ip
) 
 267             if self
.rtc
.HasSelection(): 
 268                 r 
= self
.rtc
.GetSelectionRange() 
 270             attr
.SetParagraphSpacingAfter(attr
.GetParagraphSpacingAfter() + 20); 
 271             attr
.SetFlags(rt
.TEXT_ATTR_PARA_SPACING_AFTER
) 
 272             self
.rtc
.SetStyle(r
, attr
) 
 275     def OnParagraphSpacingLess(self
, evt
): 
 276         attr 
= rt
.RichTextAttr() 
 277         attr
.SetFlags(rt
.TEXT_ATTR_PARA_SPACING_AFTER
) 
 278         ip 
= self
.rtc
.GetInsertionPoint() 
 279         if self
.rtc
.GetStyle(ip
, attr
): 
 280             r 
= rt
.RichTextRange(ip
, ip
) 
 281             if self
.rtc
.HasSelection(): 
 282                 r 
= self
.rtc
.GetSelectionRange() 
 284             if attr
.GetParagraphSpacingAfter() >= 20: 
 285                 attr
.SetParagraphSpacingAfter(attr
.GetParagraphSpacingAfter() - 20); 
 286                 attr
.SetFlags(rt
.TEXT_ATTR_PARA_SPACING_AFTER
) 
 287                 self
.rtc
.SetStyle(r
, attr
) 
 290     def OnLineSpacingSingle(self
, evt
):  
 291         attr 
= rt
.RichTextAttr() 
 292         attr
.SetFlags(rt
.TEXT_ATTR_LINE_SPACING
) 
 293         ip 
= self
.rtc
.GetInsertionPoint() 
 294         if self
.rtc
.GetStyle(ip
, attr
): 
 295             r 
= rt
.RichTextRange(ip
, ip
) 
 296             if self
.rtc
.HasSelection(): 
 297                 r 
= self
.rtc
.GetSelectionRange() 
 299             attr
.SetFlags(rt
.TEXT_ATTR_LINE_SPACING
) 
 300             attr
.SetLineSpacing(10) 
 301             self
.rtc
.SetStyle(r
, attr
) 
 304     def OnLineSpacingHalf(self
, evt
): 
 305         attr 
= rt
.RichTextAttr() 
 306         attr
.SetFlags(rt
.TEXT_ATTR_LINE_SPACING
) 
 307         ip 
= self
.rtc
.GetInsertionPoint() 
 308         if self
.rtc
.GetStyle(ip
, attr
): 
 309             r 
= rt
.RichTextRange(ip
, ip
) 
 310             if self
.rtc
.HasSelection(): 
 311                 r 
= self
.rtc
.GetSelectionRange() 
 313             attr
.SetFlags(rt
.TEXT_ATTR_LINE_SPACING
) 
 314             attr
.SetLineSpacing(15) 
 315             self
.rtc
.SetStyle(r
, attr
) 
 318     def OnLineSpacingDouble(self
, evt
): 
 319         attr 
= rt
.RichTextAttr() 
 320         attr
.SetFlags(rt
.TEXT_ATTR_LINE_SPACING
) 
 321         ip 
= self
.rtc
.GetInsertionPoint() 
 322         if self
.rtc
.GetStyle(ip
, attr
): 
 323             r 
= rt
.RichTextRange(ip
, ip
) 
 324             if self
.rtc
.HasSelection(): 
 325                 r 
= self
.rtc
.GetSelectionRange() 
 327             attr
.SetFlags(rt
.TEXT_ATTR_LINE_SPACING
) 
 328             attr
.SetLineSpacing(20) 
 329             self
.rtc
.SetStyle(r
, attr
) 
 332     def OnFont(self
, evt
): 
 333         if not self
.rtc
.HasSelection(): 
 336         r 
= self
.rtc
.GetSelectionRange() 
 337         fontData 
= wx
.FontData() 
 338         fontData
.EnableEffects(False) 
 339         attr 
= rt
.RichTextAttr() 
 340         attr
.SetFlags(rt
.TEXT_ATTR_FONT
) 
 341         if self
.rtc
.GetStyle(self
.rtc
.GetInsertionPoint(), attr
): 
 342             fontData
.SetInitialFont(attr
.CreateFont()) 
 344         dlg 
= wx
.FontDialog(self
, fontData
) 
 345         if dlg
.ShowModal() == wx
.ID_OK
: 
 346             fontData 
= dlg
.GetFontData() 
 347             font 
= fontData
.GetChosenFont() 
 349                 attr
.SetFlags(rt
.TEXT_ATTR_FONT
) 
 351                 self
.rtc
.SetStyle(r
, attr
) 
 355     def OnColour(self
, evt
): 
 356         colourData 
= wx
.ColourData() 
 357         attr 
= rt
.RichTextAttr() 
 358         attr
.SetFlags(rt
.TEXT_ATTR_TEXT_COLOUR
) 
 359         if self
.rtc
.GetStyle(self
.rtc
.GetInsertionPoint(), attr
): 
 360             colourData
.SetColour(attr
.GetTextColour()) 
 362         dlg 
= wx
.ColourDialog(self
, colourData
) 
 363         if dlg
.ShowModal() == wx
.ID_OK
: 
 364             colourData 
= dlg
.GetColourData() 
 365             colour 
= colourData
.GetColour() 
 367                 if not self
.rtc
.HasSelection(): 
 368                     self
.rtc
.BeginTextColour(colour
) 
 370                     r 
= self
.rtc
.GetSelectionRange() 
 371                     attr
.SetFlags(rt
.TEXT_ATTR_TEXT_COLOUR
) 
 372                     attr
.SetTextColour(colour
) 
 373                     self
.rtc
.SetStyle(r
, attr
) 
 378     def OnUpdateBold(self
, evt
): 
 379         evt
.Check(self
.rtc
.IsSelectionBold()) 
 381     def OnUpdateItalic(self
, evt
):  
 382         evt
.Check(self
.rtc
.IsSelectionItalics()) 
 384     def OnUpdateUnderline(self
, evt
):  
 385         evt
.Check(self
.rtc
.IsSelectionUnderlined()) 
 387     def OnUpdateAlignLeft(self
, evt
): 
 388         evt
.Check(self
.rtc
.IsSelectionAligned(rt
.TEXT_ALIGNMENT_LEFT
)) 
 390     def OnUpdateAlignCenter(self
, evt
): 
 391         evt
.Check(self
.rtc
.IsSelectionAligned(rt
.TEXT_ALIGNMENT_CENTRE
)) 
 393     def OnUpdateAlignRight(self
, evt
): 
 394         evt
.Check(self
.rtc
.IsSelectionAligned(rt
.TEXT_ALIGNMENT_RIGHT
)) 
 397     def ForwardEvent(self
, evt
): 
 398         # The RichTextCtrl can handle menu and update events for undo, 
 399         # redo, cut, copy, paste, delete, and select all, so just 
 400         # forward the event to it. 
 401         self
.rtc
.ProcessEvent(evt
) 
 404     def MakeMenuBar(self
): 
 405         def doBind(item
, handler
, updateUI
=None): 
 406             self
.Bind(wx
.EVT_MENU
, handler
, item
) 
 407             if updateUI 
is not None: 
 408                 self
.Bind(wx
.EVT_UPDATE_UI
, updateUI
, item
) 
 411         doBind( fileMenu
.Append(-1, "&Open\tCtrl+O", "Open a file"), 
 413         doBind( fileMenu
.Append(-1, "&Save\tCtrl+S", "Save a file"), 
 415         doBind( fileMenu
.Append(-1, "&Save As...\tF12", "Save to a new file"), 
 417         fileMenu
.AppendSeparator() 
 418         doBind( fileMenu
.Append(-1, "&View as HTML", "View HTML"), 
 420         fileMenu
.AppendSeparator() 
 421         doBind( fileMenu
.Append(-1, "E&xit\tCtrl+Q", "Quit this program"), 
 425         doBind( editMenu
.Append(wx
.ID_UNDO
, "&Undo\tCtrl+Z"), 
 426                 self
.ForwardEvent
, self
.ForwardEvent
) 
 427         doBind( editMenu
.Append(wx
.ID_REDO
, "&Redo\tCtrl+Y"), 
 428                 self
.ForwardEvent
, self
.ForwardEvent 
) 
 429         editMenu
.AppendSeparator() 
 430         doBind( editMenu
.Append(wx
.ID_CUT
, "Cu&t\tCtrl+X"), 
 431                 self
.ForwardEvent
, self
.ForwardEvent 
) 
 432         doBind( editMenu
.Append(wx
.ID_COPY
, "&Copy\tCtrl+C"), 
 433                 self
.ForwardEvent
, self
.ForwardEvent
) 
 434         doBind( editMenu
.Append(wx
.ID_PASTE
, "&Paste\tCtrl+V"), 
 435                 self
.ForwardEvent
, self
.ForwardEvent
) 
 436         doBind( editMenu
.Append(wx
.ID_CLEAR
, "&Delete\tDel"), 
 437                 self
.ForwardEvent
, self
.ForwardEvent
) 
 438         editMenu
.AppendSeparator() 
 439         doBind( editMenu
.Append(wx
.ID_SELECTALL
, "Select A&ll\tCtrl+A"), 
 440                 self
.ForwardEvent
, self
.ForwardEvent 
) 
 442         #doBind( editMenu.AppendSeparator(),  ) 
 443         #doBind( editMenu.Append(-1, "&Find...\tCtrl+F"),  ) 
 444         #doBind( editMenu.Append(-1, "&Replace...\tCtrl+R"),  ) 
 446         formatMenu 
= wx
.Menu() 
 447         doBind( formatMenu
.AppendCheckItem(-1, "&Bold\tCtrl+B"), 
 448                 self
.OnBold
, self
.OnUpdateBold
) 
 449         doBind( formatMenu
.AppendCheckItem(-1, "&Italic\tCtrl+I"), 
 450                 self
.OnItalic
, self
.OnUpdateItalic
) 
 451         doBind( formatMenu
.AppendCheckItem(-1, "&Underline\tCtrl+U"), 
 452                 self
.OnUnderline
, self
.OnUpdateUnderline
) 
 453         formatMenu
.AppendSeparator() 
 454         doBind( formatMenu
.AppendCheckItem(-1, "L&eft Align"), 
 455                 self
.OnAlignLeft
, self
.OnUpdateAlignLeft
) 
 456         doBind( formatMenu
.AppendCheckItem(-1, "&Centre"), 
 457                 self
.OnAlignCenter
, self
.OnUpdateAlignCenter
) 
 458         doBind( formatMenu
.AppendCheckItem(-1, "&Right Align"), 
 459                 self
.OnAlignRight
, self
.OnUpdateAlignRight
) 
 460         formatMenu
.AppendSeparator() 
 461         doBind( formatMenu
.Append(-1, "Indent &More"), self
.OnIndentMore
) 
 462         doBind( formatMenu
.Append(-1, "Indent &Less"), self
.OnIndentLess
) 
 463         formatMenu
.AppendSeparator() 
 464         doBind( formatMenu
.Append(-1, "Increase Paragraph &Spacing"), self
.OnParagraphSpacingMore
) 
 465         doBind( formatMenu
.Append(-1, "Decrease &Paragraph Spacing"), self
.OnParagraphSpacingLess
) 
 466         formatMenu
.AppendSeparator() 
 467         doBind( formatMenu
.Append(-1, "Normal Line Spacing"), self
.OnLineSpacingSingle
) 
 468         doBind( formatMenu
.Append(-1, "1.5 Line Spacing"), self
.OnLineSpacingHalf
) 
 469         doBind( formatMenu
.Append(-1, "Double Line Spacing"), self
.OnLineSpacingDouble
) 
 470         formatMenu
.AppendSeparator() 
 471         doBind( formatMenu
.Append(-1, "&Font..."), self
.OnFont
) 
 474         mb
.Append(fileMenu
, "&File") 
 475         mb
.Append(editMenu
, "&Edit") 
 476         mb
.Append(formatMenu
, "F&ormat") 
 480     def MakeToolBar(self
): 
 481         def doBind(item
, handler
, updateUI
=None): 
 482             self
.Bind(wx
.EVT_TOOL
, handler
, item
) 
 483             if updateUI 
is not None: 
 484                 self
.Bind(wx
.EVT_UPDATE_UI
, updateUI
, item
) 
 486         tbar 
= self
.CreateToolBar() 
 487         doBind( tbar
.AddTool(-1, images
.get_rt_openBitmap(), 
 488                             shortHelpString
="Open"), self
.OnFileOpen
) 
 489         doBind( tbar
.AddTool(-1, images
.get_rt_saveBitmap(), 
 490                             shortHelpString
="Save"), self
.OnFileSave
) 
 492         doBind( tbar
.AddTool(wx
.ID_CUT
, images
.get_rt_cutBitmap(), 
 493                             shortHelpString
="Cut"), self
.ForwardEvent
, self
.ForwardEvent
) 
 494         doBind( tbar
.AddTool(wx
.ID_COPY
, images
.get_rt_copyBitmap(), 
 495                             shortHelpString
="Copy"), self
.ForwardEvent
, self
.ForwardEvent
) 
 496         doBind( tbar
.AddTool(wx
.ID_PASTE
, images
.get_rt_pasteBitmap(), 
 497                             shortHelpString
="Paste"), self
.ForwardEvent
, self
.ForwardEvent
) 
 499         doBind( tbar
.AddTool(wx
.ID_UNDO
, images
.get_rt_undoBitmap(), 
 500                             shortHelpString
="Undo"), self
.ForwardEvent
, self
.ForwardEvent
) 
 501         doBind( tbar
.AddTool(wx
.ID_REDO
, images
.get_rt_redoBitmap(), 
 502                             shortHelpString
="Redo"), self
.ForwardEvent
, self
.ForwardEvent
) 
 504         doBind( tbar
.AddTool(-1, images
.get_rt_boldBitmap(), isToggle
=True, 
 505                             shortHelpString
="Bold"), self
.OnBold
, self
.OnUpdateBold
) 
 506         doBind( tbar
.AddTool(-1, images
.get_rt_italicBitmap(), isToggle
=True, 
 507                             shortHelpString
="Italic"), self
.OnItalic
, self
.OnUpdateItalic
) 
 508         doBind( tbar
.AddTool(-1, images
.get_rt_underlineBitmap(), isToggle
=True, 
 509                             shortHelpString
="Underline"), self
.OnUnderline
, self
.OnUpdateUnderline
) 
 511         doBind( tbar
.AddTool(-1, images
.get_rt_alignleftBitmap(), isToggle
=True, 
 512                             shortHelpString
="Align Left"), self
.OnAlignLeft
, self
.OnUpdateAlignLeft
) 
 513         doBind( tbar
.AddTool(-1, images
.get_rt_centreBitmap(), isToggle
=True, 
 514                             shortHelpString
="Center"), self
.OnAlignCenter
, self
.OnUpdateAlignCenter
) 
 515         doBind( tbar
.AddTool(-1, images
.get_rt_alignrightBitmap(), isToggle
=True, 
 516                             shortHelpString
="Align Right"), self
.OnAlignRight
, self
.OnUpdateAlignRight
) 
 518         doBind( tbar
.AddTool(-1, images
.get_rt_indentlessBitmap(), 
 519                             shortHelpString
="Indent Less"), self
.OnIndentLess
) 
 520         doBind( tbar
.AddTool(-1, images
.get_rt_indentmoreBitmap(), 
 521                             shortHelpString
="Indent More"), self
.OnIndentMore
) 
 523         doBind( tbar
.AddTool(-1, images
.get_rt_fontBitmap(), 
 524                             shortHelpString
="Font"), self
.OnFont
) 
 525         doBind( tbar
.AddTool(-1, images
.get_rt_colourBitmap(), 
 526                             shortHelpString
="Font Colour"), self
.OnColour
) 
 532 #---------------------------------------------------------------------- 
 534 class TestPanel(wx
.Panel
): 
 535     def __init__(self
, parent
, log
): 
 537         wx
.Panel
.__init
__(self
, parent
, -1) 
 539         b 
= wx
.Button(self
, -1, "Show the RichTextCtrl sample", (50,50)) 
 540         self
.Bind(wx
.EVT_BUTTON
, self
.OnButton
, b
) 
 543     def OnButton(self
, evt
): 
 544         win 
= RichTextFrame(self
, -1, "wx.richtext.RichTextCtrl", 
 546                             style 
= wx
.DEFAULT_FRAME_STYLE
) 
 549         # give easy access to PyShell if it's running 
 553 #---------------------------------------------------------------------- 
 555 def runTest(frame
, nb
, log
): 
 556     win 
= TestPanel(nb
, log
) 
 559 #---------------------------------------------------------------------- 
 563 overview 
= """<html><body> 
 564 <h2><center>wx.richtext.RichTextCtrl</center></h2> 
 571 if __name__ 
== '__main__': 
 574     run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])