newbie question, about writing a XML viewer with wxPython

Hello guys,

I intend to write, using wxPython, a XML viewer. Since
I am new
to wxPython I am not sure which widget is most suitable for
accomplishing what I am trying to do. I'm hoping to
find someone
kind enough to give me some ideas.

Here are the 'requirements':
- the elements should be displayed one per line in a a
TextCtrl-like
     widget (not in a TreeCtrl) , and will be indented
- the arrowkeys will be used to go from one element to
another ,
    and Enter will collapse/expand the current one
- the current element will be displayed using a
different background
    color for the entire line
- the ability to mark with different fonts/colors
certain elements.
- the elements should be numbered, and the numbers will
displayed
    on the left (similar to the line numbers in PyCrust).

The wxStyledTextCtrl could allow most of these
requirements to
be implemented, but i don't know if it is possible to hide
certain lines when collapsing elements. Well, i know
that it can
hide function/class definitions when wxStyledCtrl is
used for
editing source files, but i got the feeling that it is
complicated
to use this facility of the widget for XML files.
Maybe wxTextCtrl could be used, too.

Another possibility could be writing my own widget, but
i have
no idea how hard it could be.

Eh, what do you think? Are there other ways i should take
into account?

Best wishes,
Adrian Maier

adrian_maier wrote:

Hello guys,

I intend to write, using wxPython, a XML viewer. Since
I am new
to wxPython I am not sure which widget is most suitable for
accomplishing what I am trying to do. I'm hoping to
find someone kind enough to give me some ideas.

Here are the 'requirements':
- the elements should be displayed one per line in a a
TextCtrl-like
    widget (not in a TreeCtrl) , and will be indented - the arrowkeys will be used to go from one element to
another ,
   and Enter will collapse/expand the current one
- the current element will be displayed using a
different background
   color for the entire line
- the ability to mark with different fonts/colors
certain elements. - the elements should be numbered, and the numbers will
displayed
   on the left (similar to the line numbers in PyCrust).

The wxStyledTextCtrl could allow most of these
requirements to
be implemented, but i don't know if it is possible to hide
certain lines when collapsing elements. Well, i know
that it can
hide function/class definitions when wxStyledCtrl is
used for editing source files, but i got the feeling that it is
complicated
to use this facility of the widget for XML files. Maybe wxTextCtrl could be used, too.

Another possibility could be writing my own widget, but
i have no idea how hard it could be.

Eh, what do you think? Are there other ways i should take into account?

Best wishes,
Adrian Maier

Have a look at this article from Uche. Does not cover all your requirements, but might give you some ideas:

http://xml.com/pub/a/2003/04/09/py-xml.html

Good luck
/Rob

adrian_maier wrote:

Here are the 'requirements': - the elements should be displayed one
per line in a a TextCtrl-like widget (not in a TreeCtrl) , and will
be indented - the arrowkeys will be used to go from one element to another , and Enter will collapse/expand the current one - the
current element will be displayed using a different background color
for the entire line - the ability to mark with different fonts/colors
certain elements. - the elements should be numbered, and the numbers
will displayed on the left (similar to the line numbers in PyCrust).

The wxStyledTextCtrl could allow most of these requirements to be
implemented, but i don't know if it is possible to hide certain lines
when collapsing elements.

It is. You can do all the hiding/showing manually or you could also use it's line folding capabilities and then it will put the markers in the margin for expanding/collapsing the elements with the mouse.

Well, i know that it can hide
function/class definitions when wxStyledCtrl is used for editing
source files, but i got the feeling that it is complicated to use
this facility of the widget for XML files.

Once you figure out the basics of wxSTC then I don't think it would be too hard to do.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!