Hello People!

I'm trying to design a text editor using wxpython. I wish to add some basic formatting functionality (like BOLD, ITALICS, UNDERLINE) to it.

Is there any way to achieve this in wx.TextCtrl ? Or do I have to use stc.StyledTextCtrl (which I don't really wish right now)?

Thank You.

Here would be a typical example ...

# experiments with wx.StaticText(), set a font for the text
 
import wx
 
class MyFrame(wx.Frame):
    def __init__(self, parent, id, title, data):
        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, size=(500, 380))
        panel = wx.Panel(self, -1)
        # font type: wx.DEFAULT, wx.DECORATIVE, wx.ROMAN, wx.SCRIPT, wx.SWISS, wx.MODERN
        # slant: wx.NORMAL, wx.SLANT or wx.ITALIC
        # weight: wx.NORMAL, wx.LIGHT or wx.BOLD
        #font1 = wx.Font(10, wx.SWISS, wx.ITALIC, wx.NORMAL)
        # use additional fonts this way ...
        font1 = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL, False, u'Comic Sans MS')
        text1 = wx.StaticText(panel, -1, data, pos=(20,15))
        text1.SetFont(font1)
        # center frame on screen
        self.Center()
        # show the frame
        self.Show(True)
 
 
data = """\
Al Gore:  The Wild Years
America's Most Popular Lawyers
Career Opportunities for History Majors
Different Ways to Spell "Bob"
Dr. Kevorkian's Collection of Motivational Speeches
Ethiopian Tips on World Dominance
Everything Men Know About Women
Everything Women Know About Men
One Hundred and One Spotted Owl Recipes by the EPA
Staple Your Way to Success
The Amish Phone Book
The Engineer's Guide to Fashion
Ralph Nader's list of pleasures"""
 
application = wx.PySimpleApp()
# create instance of class MyFrame
window = MyFrame(None, -1, "The World's Shortest Books", data)
# start the event loop
application.MainLoop()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.