472,784 Members | 1,311 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,784 software developers and data experts.

GUI toolkit selection for a text editor widget

Hello,

Sorry to be bringing up what seems to be a somewhat beaten up topic...

This is what I wanted to do:

Create a _simple_ text editor widget which supports VI(M) style
keybindings but works with arbitrary fonts/unicode characters. Vi(m)
unfortunately, does not support Devanagari (or proportional fonts) and
it looks like it will take quite some time for these things to work. As
and when Vim supports Devanagari on Windows, I will give up this effort.

My current aims are:
1. Simple Vi(m) style keybindings.
2. Syntax highlighting for arbitrary files based on Vim-style syntax
highlighting definitions. Vim defines syntax highlighting for files
based on a very flexible regexp style approach. Thus you can define
syntax hightlighting for new file types just by writing some regexps.
3. Should be able to load/edit files written in unicode.
4. Macro capability.
5. I want to implement this purely in python.
6. Should work on windows.
7. I do not really care much about speed/looks etc as long as the thing is
functional.

The choice of the GUI toolkit is therefore almost exclusively depends on
how these conditions can be met. This is my take so far:

1. PyQT: Unfortunately, the qtext module which extends the scintilla module
to QT is available only under a commercial license for windows. The
QMultiLineEdit widget does not support any text styling at all. Hence
PyQT seems to be ruled out straight away.

2. wxPython: The wxStyledTextCtrl widget showed great promise. It has
almost everything one would wish for. Except for a _major_ bug while
editing unicode. The text caret which shows where the text insertion
will happen is offset from the actual insertion point in complex
scripts like devangari or arabic. This looks like its a problem with
calculating text extents. Robin Dunn has acknowledged this bug, but
unfortunately, unless there is a workaround, I cannot do anything with
wxStyledTextCtrl at all.

wxPython also has wxTextCtrl which has far lesser features than
wxStyledTextCtrl, but at least does not have the bug with the text
caret. Unfortunately, it looks like it does not provide some necessary
functions. For one, if I desire to do syntax highlighting based on it, I
would need to find out the current range of text displayed in the
window. But I couldn't find any way of finding out which lines are
actually displayed. The various wxScrollBar functions (which wxTextCtrl
inherits) do not give useful information.

3. Tkinter: I looked briefly at Tkinter and the Text widget looked very
impressive indeed! It looks like the way it highlights text is even
more powerful than Vim in that each character (or range) has multiple
"tags" associated with it and the most recent tag takes precedence.
This looks like something which might be very handy. It even supports
inserting bitmaps etc. All in all, very neat looking.

But there seems to be some limitations:
1. How do I recognize control key inputs? I tried
self.bind('<Key>', function)
but how to find out if CTRL-a has been pressed in the function. When
I ran a simple app, event.char reports 'a' when I press CTRL-A. So
does event.keysym and event.keycode... wxPython has something called
event.ControlDown() for keyEvents...

2. There seems to be a problem with displaying unicode which Text
suffers from too :( The problem is not as severe as the one
wxStyledTextCtrl suffers from and it looks like it can be "lived
with". When moving over certain "composing character" strings in
unicode, the caret seems to move _between_ the characters. Ideally,
each sequence of composing characters would be considered a single
"glyph"... I will elaborate if someone needs clarification.

3. Although the Text widget itself is powerful, from what I gather in
this newsgroup and on the web, Tkinter does not provide things like
a tree control widget which might be essential later on. This looks
like something which can be worked around, because idle, the editor
provided with Python 2.3 seems to have all these things constructed
using the basic primitives...

Infact, I am wondering whether I should just modify Idle to accept Vi
style key-bindinds...

I would greatly appreciate any comments.

Thank you,
Regards,
Srinath

Jul 18 '05 #1
2 3681
In article <Pi*************************************@albinoni. EECS.Berkeley.EDU>,
Srinath Avadhanula <sr*************@yahoo.com> wrote:
Jul 18 '05 #2
On Fri, 07 Nov 2003 19:43:44 -0800, Srinath Avadhanula wrote:
Hello,

Sorry to be bringing up what seems to be a somewhat beaten up topic...

This is what I wanted to do:

Create a _simple_ text editor widget which supports VI(M) style
keybindings but works with arbitrary fonts/unicode characters. Vi(m)
unfortunately, does not support Devanagari (or proportional fonts) and
it looks like it will take quite some time for these things to work. As
and when Vim supports Devanagari on Windows, I will give up this effort.

My current aims are:
1. Simple Vi(m) style keybindings.
2. Syntax highlighting for arbitrary files based on Vim-style syntax
highlighting definitions. Vim defines syntax highlighting for files
based on a very flexible regexp style approach. Thus you can define
syntax hightlighting for new file types just by writing some regexps.
3. Should be able to load/edit files written in unicode.
4. Macro capability.
5. I want to implement this purely in python.
6. Should work on windows.
7. I do not really care much about speed/looks etc as long as the thing is
functional.


Don't forget pygtk, bindings for GTK+. GTK+ has a very powerful
GtkTextView widget. There is also a GtkSourceView widget that has recently
been wrapped for python use. GTK+ supports custom keybindings throughout.
GTK+ works well on Windows. GTK+ on Windows XP uses the XP themeing
system, so GTK+ apps look native on Windows XP. The Windows classic
theme, although not perfect, works very similarly to native Windows
widgets.

If you use pygtk but would rather use the Scintilla widget you may be
interested in this: http://sra.itc.it/people/cavada/PyScintilla2.html
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jane Austine | last post by:
As you add more items, say text lines, in Text widget, it gets too slow and almost impractical to use on. Take idle for example. If the text gets bigger(e.g. print...
53
by: Paul Rubin | last post by:
I've been approached about writing a Windows app which will need a really professional looking GUI. Forget TKinter, this has to actually look good (real artists will be available to get the visual...
24
by: invitro81 | last post by:
Hello I've recently learnt python and I do love it! I congratulate all those geeks who produce this nice language; well, because I could be called a nearby newbee I've decided to improve my...
3
by: Ant | last post by:
Hi all, I have been trying to select text in a Text widget programmatically. I have been trying the following minimal example: #================================= from Tkinter import * def...
161
by: Dan Lenski | last post by:
Hi all, I'm a recent, belated convert from Perl. I work in a physics lab and have been using Python to automate a lot of measurement equipment lately. It works fabulously for this purpose. ...
2
by: dennis.sprengers | last post by:
Ik ben bezig met een eigen UBB editor. Als iemand aan het typen is, zorgt CTRL-B voor een \-tag en nogmaals CTRL-B voor een \ tag. Als je eerst een selectie maakt en dan CTRL-B drukt, wordt de...
6
by: Gigs_ | last post by:
I'm writing text editor. How to enable/disable (cut, copy etc.) when text is selected/not selected
1
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. ...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.