TextCtrl question

Hi list,

I have some disabled TextCtrl on a page, but it is hard to read
(I'd like to use it as unreachable display zones), I can change the
background color when disabled but not the foreground's one :frowning:

So how could I avoid these TextCtrl to be granted focus, or is there
a way to change the general disabled text foreground color?

JY

···

--
All international orders must be accompanied by payment in U. S.
funds.

Use wx.StaticText instead?

Michael

···

On 2011-12-05 8:19 AM, Jean-Yves F. Barbier wrote:

Hi list,

I have some disabled TextCtrl on a page, but it is hard to read
(I'd like to use it as unreachable display zones), I can change the
background color when disabled but not the foreground's one :frowning:

So how could I avoid these TextCtrl to be granted focus, or is there
a way to change the general disabled text foreground color?

Yeah, I thought about that, but I would be obliged to draw TextCtrl
shapes alike for each size.

I found a 1/2 solution: self.textCtrlTest.SetEditable( False )

JY

···

On Mon, 05 Dec 2011 08:43:44 -0600 Michael Hipp <michael@redmule.com> wrote:

Use wx.StaticText instead?

--
Vatican upholds ban on contraceptives: "To heir is humane," claims
the Pope.

what about style = wx.TE_READONLY|otherflags in the creation of the text
controls.

Gadget/Steve

···

On 05/12/2011 3:14 PM, Jean-Yves F. Barbier wrote:

On Mon, 05 Dec 2011 08:43:44 -0600 > Michael Hipp <michael@redmule.com> wrote:

Use wx.StaticText instead?

Yeah, I thought about that, but I would be obliged to draw TextCtrl
shapes alike for each size.

I found a 1/2 solution: self.textCtrlTest.SetEditable( False )

JY

I missed this one, and it exists in wxfb :slight_smile:
Thanks Steve

···

On Mon, 5 Dec 2011 15:47:31 +0000 Gadget/Steve <GadgetSteve@live.co.uk> wrote:

what about style = wx.TE_READONLY|otherflags in the creation of the text
controls.

--
Do what comes naturally. Seethe and fume and throw a tantrum.

From a user experience perspective…I find that wxTextCtrl, even with the READONLY flag (or SetEditable() = False) too strongly suggests a “word processing window” which is, by convention, supposed to be editable. Much of that is probably just the blinking cursor and scroll bars (if present). Therefore, for purely app-to-user textual information, staticText is preferable, even if it requires some management of the wrapping/size.

But one advantage of TextCtrl is that if the user wants to copy the words of the message to another window (e.g. they want to share the app’s info to them in a forum post); wxTextCtrl can do it, whereas StaticText can’t. In many cases, though, users won’t need to do this.

There is also wx.lib.fancytext for more easily formatted messages.

Che

···

On Mon, Dec 5, 2011 at 11:32 AM, Jean-Yves F. Barbier 12ukwn@gmail.com wrote:

On Mon, 5 Dec 2011 15:47:31 +0000 > > Gadget/Steve GadgetSteve@live.co.uk wrote:

what about style = wx.TE_READONLY|otherflags in the creation of the text

controls.

I missed this one, and it exists in wxfb :slight_smile:

Thanks Steve

Well, read only is not very good as it takes focus and fancytext
don't meet my needs (the I/F should be visually consistent).
Is there a possibility to superpose a StaticText on an empty
TextCtrl (disabled & colored)?

···

On Mon, 5 Dec 2011 15:47:31 +0000 Gadget/Steve <GadgetSteve@live.co.uk> wrote:

what about style = wx.TE_READONLY|otherflags in the creation of the text
controls.

--
Which is worse: ignorance or apathy? Who knows? Who cares?

what about style = wx.TE_READONLY|otherflags in the creation of the text

controls.

Well, read only is not very good as it takes focus and fancytext

don’t meet my needs (the I/F should be visually consistent).

What’s I/F?

Is there a possibility to superpose a StaticText on an empty

TextCtrl (disabled & colored)?

Why not just put a StaticText its own panel? You can color it and the text whatever you want.

Che

···

On Mon, Dec 5, 2011 at 1:28 PM, Jean-Yves F. Barbier 12ukwn@gmail.com wrote:

On Mon, 5 Dec 2011 15:47:31 +0000 > > Gadget/Steve GadgetSteve@live.co.uk wrote:

What's I/F?

Interface

> Is there a possibility to superpose a StaticText on an empty
> TextCtrl (disabled & colored)?

Why not just put a StaticText its own panel? You can color it and the text
whatever you want.

The PB is not so simple: I want that to look like a regular TextCtrl,
but on one machine I use a theme with rounded buttons/other and on
another they're square.

I think there's no solution but leaving it in read only.

Things would have been very easy if only TextCtrl had accepted to
change it's foreground color while disabled:(

Che

Guevara?

···

On Mon, 5 Dec 2011 13:30:59 -0500 C M <cmpython@gmail.com> wrote:

--
If you want your program to be readable, consider supplying the
argument. -- Larry Wall in the perl man page

What’s I/F?

Interface

Is there a possibility to superpose a StaticText on an empty

TextCtrl (disabled & colored)?

Why not just put a StaticText its own panel? You can color it and the text

whatever you want.

The PB is not so simple:

PB? Maybe you should ULA and then PWBATUYB.

I want that to look like a regular TextCtrl,

but on one machine I use a theme with rounded buttons/other and on

another they’re square.

What do rounded buttons have to do with this? Seems like a non sequitur.

A picture of what you want–on any and all platforms–might make it all clearer.

Che

Guevara?

:smiley:

···

On Mon, Dec 5, 2011 at 1:58 PM, Jean-Yves F. Barbier 12ukwn@gmail.com wrote:

On Mon, 5 Dec 2011 13:30:59 -0500 > > C M cmpython@gmail.com wrote:

What I mean is:
Machine1: Has a theme that renders rounded TextCtrl
Machine2: Has a theme that renders squared TextCtrl
So I can't cheat putting a StaticText on an image that fakes a
TextCtrl, as if I draw it rounded if won't fit w/ Machine2 look, and
vice-versa.

The original goal was to have disabled TextCtrls (to avoid TAB
navigation) w/ different back/foreground colors to indicate
important info - unfortunately if the background can be changed, the
foreground can't.

So this leads to the only possible (easy) way I see: use
active TextCtrls w/ changed back/foreground colors (operative for
foreground if active) and forget about forbidden TAB navigation on
them.

···

On Mon, 5 Dec 2011 14:37:59 -0500 C M <cmpython@gmail.com> wrote:

> I want that to look like a regular TextCtrl,
> but on one machine I use a theme with rounded buttons/other and on
> another they're square.
>

What do rounded buttons have to do with this? Seems like a non sequitur.

A picture of what you want--on any and all platforms--might make it all
clearer.

--
BOFH excuse #385:
Dyslexics retyping hosts file on servers

If you have an event handler for them being selected, (ON_ENTRY???), and
raise a tab event from it anybody tabbing/clicking into the box will
automatically be moved to the next item in the tab order. (Possibly
combined with read only).

Just make sure that you do not have any pages with just these on, (as it
will tab to the next forever).

Gadget/Steve

···

On 06/12/2011 6:52 AM, Jean-Yves F. Barbier wrote:

On Mon, 5 Dec 2011 14:37:59 -0500 > C M <cmpython@gmail.com> wrote:

I want that to look like a regular TextCtrl,
but on one machine I use a theme with rounded buttons/other and on
another they're square.

What do rounded buttons have to do with this? Seems like a non sequitur.

A picture of what you want--on any and all platforms--might make it all
clearer.

What I mean is:
Machine1: Has a theme that renders rounded TextCtrl
Machine2: Has a theme that renders squared TextCtrl
So I can't cheat putting a StaticText on an image that fakes a
TextCtrl, as if I draw it rounded if won't fit w/ Machine2 look, and
vice-versa.

The original goal was to have disabled TextCtrls (to avoid TAB
navigation) w/ different back/foreground colors to indicate
important info - unfortunately if the background can be changed, the
foreground can't.

So this leads to the only possible (easy) way I see: use
active TextCtrls w/ changed back/foreground colors (operative for
foreground if active) and forget about forbidden TAB navigation on
them.

If you have an event handler for them being selected, (ON_ENTRY???), and
raise a tab event from it anybody tabbing/clicking into the box will
automatically be moved to the next item in the tab order. (Possibly
combined with read only).

Hehe, here again I though about that, unfortunately I don't know
how to do the 2nd part (moving the focus to the next one).

Just make sure that you do not have any pages with just these on, (as it
will tab to the next forever).

No risk, there are only a very few of them.

···

On Tue, 6 Dec 2011 10:50:07 +0000 Gadget/Steve <GadgetSteve@live.co.uk> wrote:

--
Cats are intended to teach us that not everything in nature has a
function. -- Garrison Keillor

I eventually found how to do that, but it is not satisfactory: using
EVT_KEY_UP & EVT_ENTER_WINDOW I can still have focus with the mouse,
but the PB is not there (there's for sure another event to counter
mouse focus), it's about keyboard: I've got no way to know from
which side of the widget I come but maintaining a list of all
widgets ordered - this would turn rapidly the whole shebang into a
pure Rube Goldberd machine :wink:

Sooo, I leave them alone, just R/O w/colors changed.

JY

···

On Tue, 6 Dec 2011 10:50:07 +0000 Gadget/Steve <GadgetSteve@live.co.uk> wrote:

If you have an event handler for them being selected, (ON_ENTRY???), and
raise a tab event from it anybody tabbing/clicking into the box will
automatically be moved to the next item in the tab order. (Possibly
combined with read only).

--
Why do we have two eyes? To watch 3-D movies with.

Just use the focus event: EVT_SET_FOCUS. Bind the text control to that and when it gets focus, just call SetFocus() on whatever the next widget in line is. See also http://www.blog.pythonlibrary.org/2009/08/27/wxpython-learning-to-focus/

···

Mike Driscoll

Blog: http://blog.pythonlibrary.org

What I mean is:

Machine1: Has a theme that renders rounded TextCtrl

Machine2: Has a theme that renders squared TextCtrl

So I can’t cheat putting a StaticText on an image that fakes a

TextCtrl, as if I draw it rounded if won’t fit w/ Machine2 look, and

vice-versa.

All that is assuming that you have to use TextCtrls for this “info area”. You don’t. You can and, I think, should use StaticTexts on a panel for these. They will look the same on all platforms, and they will look like app notices and not word processing windows.

See attached code showing a comparison of a TextCtrl (top) to a StaticText on a panel (bottom). I had to include another textCtrl at bottom to take the focus from the top TextCtrl, just to be fair to it.

You can make one of these “signs” as a class and then just pass it the text you want to display and give it the code to automatically come up with an appropriate size for the SetSize() command so that it will always fit well in the panel. If you might have very long messages, you could make it a ScrolledPanel instead, which would allow scrolling of a long message.

Maybe you can get the same effect with a focus-tweaking TextCtrl, but it seems like an interactive widget when you want a non-interactive (“static”) one.

Che

text_ctrl_vs_static_text.py (3 KB)

Using the wx.Window.Navigate method is a little better than SetFocus, Navigate will take care of figuring out which widgets are the next and previous, skip those that can't accept focus, etc. so you don't have to do that to know which widget's SetFocus to call. You can check the current status of the shift keys (included with wx.GetMouseState for example, or use the last key events) to know which direction flags to use.

···

On 12/6/11 7:01 AM, Mike Driscoll wrote:

Just use the focus event: EVT_SET_FOCUS. Bind the text control to that
and when it gets focus, just call SetFocus() on whatever the next widget
in line is. See also
wxPython: Learning to Focus - Mouse Vs Python

--
Robin Dunn
Software Craftsman

No, it'll impair the design and at the exception of 2 of them
they're not following each other.

I do want these informations to have the same look'n'feel than the
other (except for colors) because users are accustomed to this kinda
presentation and it counts much for them.

···

On Tue, 6 Dec 2011 15:35:20 -0500 C M <cmpython@gmail.com> wrote:

All that is assuming that you *have* to use TextCtrls for this "info
area". You don't. You can and, I think, should use StaticTexts on a
panel for these. They will look the same on all platforms, and they will
look like app notices and not word processing windows.

--
Your wig steers the gig.
    -- Lord Buckley

Using the wx.Window.Navigate method is a little better than SetFocus,
Navigate will take care of figuring out which widgets are the next and
previous, skip those that can't accept focus, etc. so you don't have to
do that to know which widget's SetFocus to call.

Thanks this one's interesting.

You can check the
current status of the shift keys (included with wx.GetMouseState for
example, or use the last key events) to know which direction flags to use.

I haven't think about that, thanks again; Che also gave me a hint:
making a class for that (I not accustomed to OOP, so thinking classes
isn't natural to me).

···

On Tue, 06 Dec 2011 13:48:03 -0800 Robin Dunn <robin@alldunn.com> wrote:

--
Eighty percent of married men cheat in America. The rest cheat in
Europe. -- Jackie Mason

Jean-Yves,

All that is assuming that you *have* to use TextCtrls for this "info
area". You don't. You can and, I think, should use StaticTexts on a
panel for these. They will look the same on all platforms, and they will
look like app notices and not word processing windows.

No, it'll impair the design and at the exception of 2 of them
they're not following each other.

I do want these informations to have the same look'n'feel than the
other (except for colors) because users are accustomed to this kinda
presentation and it counts much for them.

You have to know what is needed in your case but at the same time I have to agree with Che, i.e. I am not at all sure that TextCtrl's are the widget to use based on what you described up to now.

I hope this is not one of these UI's where users want to see a screen which has the look'n'feel of an IBM S/34 or similar but it is a Windows UI running on a nice color screen;-) .

Werner

···

On 12/06/2011 11:12 PM, Jean-Yves F. Barbier wrote:

On Tue, 6 Dec 2011 15:35:20 -0500 > C M<cmpython@gmail.com> wrote: