3 Replies - 846 Views - Last Post: 14 January 2013 - 01:19 PM Rate Topic: -----

#1 Jbf1001  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 31
  • Joined: 24-October 12

wxPython: Text Editor Question About Font Color

Posted 29 December 2012 - 10:38 PM

Hey guys, I am building my own text editor in wxPython for fun and learning purposes. I want to add some highlighting of text similar to Notepad++ or other editors for python syntax. Can you guys point me in the right direction as far as that goes? I want to code it myself but I'm not sure where to start. Thanks!
Is This A Good Question/Topic? 1
  • +

Replies To: wxPython: Text Editor Question About Font Color

#2 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 759
  • View blog
  • Posts: 2,010
  • Joined: 23-December 08

Re: wxPython: Text Editor Question About Font Color

Posted 01 January 2013 - 01:09 PM

Here's some sample code that might provide a good starting point for your text editor

This post has been edited by atraub: 01 January 2013 - 01:10 PM

Was This Post Helpful? 0
  • +
  • -

#3 Jbf1001  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 31
  • Joined: 24-October 12

Re: wxPython: Text Editor Question About Font Color

Posted 14 January 2013 - 12:52 PM

I have already finished that much of the project,what i need is something to help me with highlighting text inside wxPythons TextCtrl
Was This Post Helpful? 0
  • +
  • -

#4 Simown  Icon User is offline

  • Blue Sprat
  • member icon

Reputation: 319
  • View blog
  • Posts: 650
  • Joined: 20-May 10

Re: wxPython: Text Editor Question About Font Color

Posted 14 January 2013 - 01:19 PM

I don't think you can use TextCtrl (unless you want the whole thing to be the same colour) looks like you need StyledTextCtrl, right? You can select certain regions in the text and style them a certain way. That link above gives plenty of information, and also contains the link to documentation and examples.

Edit: And the wxPython official documentation for StyledTextCtrl, I don't think it's linked on that wiki.

For example to select some text use:
SetSelection(start, end)

and then colour and modify it any way you please! Oh and don't forget to:
from wxPython.stc import * 

As it's a submodule of wxPython.

This post has been edited by Simown: 14 January 2013 - 05:09 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1