simple text editor w/ D&D of hyperlinks

Andrew Dalke adalke at mindspring.com
Tue Nov 19 00:01:07 EST 2002


I want a text editor where I can drag a hyperlink from Mozilla
onto it and have the editor include that URL along with a
hyperlink.  For example, suppose I have just simple text
(no hyperlinks) like this


  -------------------|---------------------
|  [open]  [save]   |  B i U  [Times] [14]
|-----------------------------------------
|  Here are some of the on-line strips I like
|
|    Nukees -
|    Sluggy Freelance -
|      ...

Now I drag the URL 'http://www.nukees.com/' from the
browser to just to the right of "Nukees -".  I want the
result to look like

  -------------------|---------------------
|  [open]  [save]   |  B i U  [Times] [14]       <--- tool bar
|-----------------------------------------
|  Here are some of the on-line strips I like    ]    can edit
|                                                ]     all of
|    Nukees - _http://www.nukees.com/_           ] <-- this text
|    Sluggy Freelance -                          ]
|      ....                                      ]

where the URL for nukees.com is hot linkable, eg, underlined
and in blue (with a change in color during mouse-over), where
I can drag&drop it onto the browser and have it go to
that page, or I can click on it and have a browser
window open to that page (ie, through 'webbrowser.py'
in the standard library).

I can't figure out how to do this in Qt nor in wxWindows.
The only rich text editors for Qt is "QTextEditor" which
will underline links in HTML but won't tell you what was
pressed.  (There's also a QTextBrowser which lets you follow
links but doesn't let you edit.)  In addition, if I insert
a URL manually, as "<a href= ... >" then insert a character
in the middle, the two sides are marked for hypertext but
the part just added wasn't.  Eg, if I add "spam" to the URL
I get

    _http://www.nu_ spam _kees.com/_

with "spam" in black and the rest in underlined blue.

Beyond this, I would like to support importing links to local
files, resolving some URLs as images (rather than just the name
of the link), flagging those links that have changed, pulling
down a mirror of the pages linked to (for off-line reading),
etc., which means fine grained control of how to handle those
hyperlinks.

Yet QTextEditor doesn't really allow for insertion of things like
images into the document ("A more complete API that supports
setting margins, images, etc., is planned for a later Qt release").

Any suggestions on how to do this?  (Besides writing my own
rich text editor with proper key-binding support for X/Mac/Win!)
I'll even try looking at an alternate GUI library -- I tried
wxPython but my task seemed even less likely to be possible.

					Andrew
					dalke at dalkescientific.com




More information about the Python-list mailing list