Discussion:
TextCtrl - formatting coloumn based plain text question
Neamtu Dan
2014-10-17 14:05:21 UTC
Permalink
Hi all,

I am struggling to find a way so that my wxPython based application would
display column based outputs nicely into TextCtrl areas. I would like to
get something like this:

show cable modem 0023.be36.8a98 phy

MAC Address I/F Sid USPwr USMER Timing
DSPwr DSMER Mode DOCSIS
(dBmV)
(SNR) Offset (dBmV) (SNR) Prov

(dB) (dB)
0023.be36.8a98 C7/0/1/U0 761 23.25 38.31 1499
0.00 ----- atdma* 1.1
0023.be36.8a98 C7/0/1/U1 761 23.50 38.36 1508
0.00 ----- atdma* 1.1

Whereas I get this:

#show cable modem 0023.be36.8a98 phy
MAC Address I/F Sid USPwr USMER Timing DSPwr DSMER Mode
DOCSIS
(dBmV) (SNR) Offset (dBmV) (SNR)
Prov
(dB) (dB)
0023.be36.8a98 C7/0/1/U0 761 23.25 38.31 1499 0.00 ----- atdma*
1.1
0023.be36.8a98 C7/0/1/U1 761 23.50 38.36 1508 0.00 ----- atdma*
1.1

Basically, for some reason the spacing between elements of columns is
changed.

Now, I know this is probably an application dependent behavior, I get the
same messed up output when pasting into Word. I do get the proper one when
pasting into notepad like applications, so probably there is a certain
mechanism integrated into those that takes care of formatting. I'm not an
expert on text formatting, neither in wxPython, but it would really be
great if I could manage to achieve this somehow.

Could you point me to any documentation or other ideas that might help?

Thanks,
Dan
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Werner
2014-10-17 15:33:26 UTC
Permalink
Post by Neamtu Dan
Hi all,
I am struggling to find a way so that my wxPython based application
would display column based outputs nicely into TextCtrl areas. I would
show cable modem 0023.be36.8a98 phy
MAC Address I/F Sid USPwr USMER
Timing DSPwr DSMER Mode DOCSIS
(dBmV) (SNR) Offset (dBmV) (SNR) Prov
(dB) (dB)
0023.be36.8a98 C7/0/1/U0 761 23.25 38.31 1499
0.00 ----- atdma* 1.1
0023.be36.8a98 C7/0/1/U1 761 23.50 38.36 1508
0.00 ----- atdma* 1.1
#show cable modem 0023.be36.8a98 phy
MAC Address I/F Sid USPwr USMER Timing DSPwr DSMER
Mode DOCSIS
(dBmV) (SNR) Offset (dBmV)
(SNR) Prov
(dB) (dB)
0023.be36.8a98 C7/0/1/U0 761 23.25 38.31 1499 0.00 -----
atdma* 1.1
0023.be36.8a98 C7/0/1/U1 761 23.50 38.36 1508 0.00 -----
atdma* 1.1
Basically, for some reason the spacing between elements of columns is
changed.
Now, I know this is probably an application dependent behavior, I get
the same messed up output when pasting into Word. I do get the proper
one when pasting into notepad like applications, so probably there is
a certain mechanism integrated into those that takes care of
formatting. I'm not an expert on text formatting, neither in wxPython,
but it would really be great if I could manage to achieve this somehow.
Could you point me to any documentation or other ideas that might help?
You sure you want to use a TextCtrl for that, looks to me to be a better
fit to use one of the ListCtrl things (e.g. wx.ListCtrl,
dataview.ListCtrl, agw.HyperTreeList, agw.UltimateListCtrl), check out
the wxPython demo.

Werner
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Tim Roberts
2014-10-17 16:41:17 UTC
Permalink
This post might be inappropriate. Click to display it.
Chris Barker
2014-10-17 20:53:14 UTC
Permalink
Post by Tim Roberts
Post by Neamtu Dan
I am struggling to find a way so that my wxPython based application
would display column based outputs nicely into TextCtrl areas.
If you really want to do your spacing like this, you
Post by Tim Roberts
either need to draw the text yourself instead of using a control, or you
need to use a fixed-pitch font like Courier or Consolas.
Exactly -- the easy way is a fixed-pitch font, you should be able to get
one on any platform with wx.MODERN for the font Family:

http://docs.wxwidgets.org/3.0/overview_font.html


seems much
Post by Tim Roberts
better suited to a grid control or a list view control. It's very
difficult to manage and maintain spacing in a text control.
or wxHTML, and make an html table, if this is just for display.

-Chris
--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

***@noaa.gov
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Nathan McCorkle
2014-10-17 19:01:57 UTC
Permalink
Post by Neamtu Dan
Hi all,
I am struggling to find a way so that my wxPython based application would
display column based outputs nicely into TextCtrl areas. I would like to
This seems to be more of a Python string-formatting question, more than a
wxPython widget question. Ask google something like: Python print columns.
Something I looked at a while ago was:
http://stackoverflow.com/questions/9989334/create-nice-column-output-in-python

Then as others said, you would want to use a mono-space font. I'm not sure
if you'd need to use a Rich style on the TextCtrl to change the font or
not, but once you get the strings formatted correctly it should behave
pretty much the same as text printed to a console window.
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...