X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/30fc5e8fee1557e4049d35d416d76a2bebdd8780..f5766910b6731eb03e82371416e9778203396ce7:/wxPython/demo/RichTextCtrl.py?ds=sidebyside diff --git a/wxPython/demo/RichTextCtrl.py b/wxPython/demo/RichTextCtrl.py index c19c0c7207..b4824e7073 100644 --- a/wxPython/demo/RichTextCtrl.py +++ b/wxPython/demo/RichTextCtrl.py @@ -197,12 +197,13 @@ class RichTextFrame(wx.Frame): # TODO: Use RichTextBuffer.GetExtWildcard to get the wildcard string dlg = wx.FileDialog(self, "Choose a filename", wildcard="All files (*.*)|*.*", - style=wx.OPEN) + style=wx.SAVE) if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() if path: self.rtc.SaveFile(path) - + dlg.Destroy() + def OnFileViewHTML(self, evt): pass @@ -335,6 +336,7 @@ class RichTextFrame(wx.Frame): r = self.rtc.GetSelectionRange() fontData = wx.FontData() + fontData.EnableEffects(False) attr = rt.RichTextAttr() attr.SetFlags(rt.TEXT_ATTR_FONT) if self.rtc.GetStyle(self.rtc.GetInsertionPoint(), attr): @@ -351,6 +353,29 @@ class RichTextFrame(wx.Frame): dlg.Destroy() + def OnColour(self, evt): + colourData = wx.ColourData() + attr = rt.RichTextAttr() + attr.SetFlags(rt.TEXT_ATTR_TEXT_COLOUR) + if self.rtc.GetStyle(self.rtc.GetInsertionPoint(), attr): + colourData.SetColour(attr.GetTextColour()) + + dlg = wx.ColourDialog(self, colourData) + if dlg.ShowModal() == wx.ID_OK: + colourData = dlg.GetColourData() + colour = colourData.GetColour() + if colour: + if not self.rtc.HasSelection(): + self.rtc.BeginTextColour(colour) + else: + r = self.rtc.GetSelectionRange() + attr.SetFlags(rt.TEXT_ATTR_TEXT_COLOUR) + attr.SetTextColour(colour) + self.rtc.SetStyle(r, attr) + dlg.Destroy() + + + def OnUpdateBold(self, evt): evt.Check(self.rtc.IsSelectionBold()) @@ -498,6 +523,8 @@ class RichTextFrame(wx.Frame): tbar.AddSeparator() doBind( tbar.AddTool(-1, images.get_rt_fontBitmap(), shortHelpString="Font"), self.OnFont) + doBind( tbar.AddTool(-1, images.get_rt_colourBitmap(), + shortHelpString="Font Colour"), self.OnColour) tbar.Realize()