textCrtrl custom renderer

I would like to create a text control that works in this way:

If the text control is empty then the control shows a default text

In the other hand the control shows the user’s input.

But i don’t know how to set a custom renderer of a textCtrl

You want to read up on "wx.EVT_TEXT".

Karsten

···

On Sun, Oct 26, 2014 at 08:55:43AM -0700, sebastián lópez wrote:

I would like to create a text control that works in this way:

If the text control is empty then the control shows a default text

<https://lh4.googleusercontent.com/-31USoxFcVso/VE0YqlUIQhI/AAAAAAAAA3Y/2eBQ5ORyyEY/s1600/render%2Bempty.png&gt;
In the other hand the control shows the user's input.

But i don't know how to set a custom renderer of a textCtrl

--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

if i used SetValue and GetValue methods i’ll get the default text, so i would like to manipulate the renderer

···

2014-10-26 11:06 GMT-05:00 Karsten Hilbert Karsten.Hilbert@gmx.net:

On Sun, Oct 26, 2014 at 08:55:43AM -0700, sebastián lópez wrote:

I would like to create a text control that works in this way:

If the text control is empty then the control shows a default text

<https://lh4.googleusercontent.com/-31USoxFcVso/VE0YqlUIQhI/AAAAAAAAA3Y/2eBQ5ORyyEY/s1600/render%2Bempty.png>

In the other hand the control shows the user’s input.

But i don’t know how to set a custom renderer of a textCtrl

You want to read up on “wx.EVT_TEXT”.

Karsten

GPG key ID E4071346 @ eu.pool.sks-keyservers.net

E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

You received this message because you are subscribed to a topic in the Google Groups “wxPython-users” group.

To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/9to4Xi4Ld3A/unsubscribe.

To unsubscribe from this group and all its topics, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


Atentamente

sebastián
Sebastián López
Ingeniero Químico
cel 317-709-0956

if i used SetValue and GetValue methods i'll get the default text, so i
would like to manipulate the renderer

Have you read up on wx.EVT_TEXT ?

Karsten

···

On Sun, Oct 26, 2014 at 11:21:34AM -0500, sebastián wrote:

2014-10-26 11:06 GMT-05:00 Karsten Hilbert <Karsten.Hilbert@gmx.net>:

> On Sun, Oct 26, 2014 at 08:55:43AM -0700, sebastián lópez wrote:
>
> > I would like to create a text control that works in this way:
> >
> > If the text control is empty then the control shows a default text
> >
> > <
> https://lh4.googleusercontent.com/-31USoxFcVso/VE0YqlUIQhI/AAAAAAAAA3Y/2eBQ5ORyyEY/s1600/render%2Bempty.png
> >
> > In the other hand the control shows the user's input.
> >
> > But i don't know how to set a custom renderer of a textCtrl
>
> You want to read up on "wx.EVT_TEXT".
>
> Karsten
> --
> GPG key ID E4071346 @ eu.pool.sks-keyservers.net
> E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "wxPython-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/wxpython-users/9to4Xi4Ld3A/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> wxpython-users+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

--
Atentamente

[image: sebastián]
Sebastián López
Ingeniero Químico
cel 317-709-0956

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

Hi

I append my approach by using wx.EVT_KEY_DOWN and wx.EVT_KEY_UP but I also like to know if it’s possible to change the text color in the control to being sometimes black color and sometimes grey color.

defaultTxtTest.py (1.54 KB)

···

2014-10-26 11:27 GMT-05:00 Karsten Hilbert Karsten.Hilbert@gmx.net:

On Sun, Oct 26, 2014 at 11:21:34AM -0500, sebastián wrote:

if i used SetValue and GetValue methods i’ll get the default text, so i
would like to manipulate the renderer

Have you read up on wx.EVT_TEXT ?

Karsten

2014-10-26 11:06 GMT-05:00 Karsten Hilbert Karsten.Hilbert@gmx.net:

On Sun, Oct 26, 2014 at 08:55:43AM -0700, sebastián lópez wrote:

I would like to create a text control that works in this way:

If the text control is empty then the control shows a default text

<
https://lh4.googleusercontent.com/-31USoxFcVso/VE0YqlUIQhI/AAAAAAAAA3Y/2eBQ5ORyyEY/s1600/render%2Bempty.png

In the other hand the control shows the user’s input.

But i don’t know how to set a custom renderer of a textCtrl

You want to read up on “wx.EVT_TEXT”.

Karsten

GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346


You received this message because you are subscribed to a topic in the
Google Groups “wxPython-users” group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/wxpython-users/9to4Xi4Ld3A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Atentamente

[image: sebastián]
Sebastián López
Ingeniero Químico
cel 317-709-0956

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+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346


You received this message because you are subscribed to a topic in the Google Groups “wxPython-users” group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/9to4Xi4Ld3A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Atentamente

sebastián

Sebastián López
Ingeniero Químico
cel 317-709-0956

You could use a wx.SearchCtrl with the SearchButton, CancelButton ect
set to not be shown and use the method SetDescriptiveText for setting your default text.

The search control is a wx.TextCtrl with added functionality.

···

On Sunday, October 26, 2014 3:55:43 PM UTC, sebastián lópez wrote:

I would like to create a text control that works in this way:

If the text control is empty then the control shows a default text

In the other hand the control shows the user’s input.

But i don’t know how to set a custom renderer of a textCtrl

I would use EVT_SET_FOCUS and EVT_KILL_FOCUS.

By default on startup you’d set the color style of the TextCtrl to light-grey and set ChangeValue to the default text. Then in the EVT_SET_FOCUS handler, if the default text is shown ChangeValue(‘’) and set the text style to the normal black color. In the EVT_KILL_FOCUS handler, if the GetValue() is ‘’ (blank), set the light-grey text style and ChangeValue(defaultText).

···

On Sunday, October 26, 2014 8:55:43 AM UTC-7, sebastián lópez wrote:

I would like to create a text control that works in this way:

If the text control is empty then the control shows a default text

In the other hand the control shows the user’s input.

But i don’t know how to set a custom renderer of a textCtrl

I don’t think that’s the right model. He’s looking for the same
functionality as the “placeholder” attribute in a modern HTML
tag. ANY time the box goes empty, it displays the
placeholder property in a grayed color. As soon as one character is
entered, the placeholder goes away and it displays the entered text
in black.
I think you have to use key up and key down. Either that, or
subclass the edit control and draw the placeholder during the paint
event.

···

Nathan McCorkle wrote:

I would use EVT_SET_FOCUS
and EVT_KILL_FOCUS.

        By

default on startup you’d set the color style of the TextCtrl
to light-grey and set ChangeValue to the default text. Then
in the EVT_SET_FOCUS handler, if the default text is shown
ChangeValue(‘’) and set the text style to the normal black
color. In the EVT_KILL_FOCUS handler, if the GetValue() is
‘’ (blank), set the light-grey text style and
ChangeValue(defaultText).

-- Tim Roberts, Providenza & Boekelheide, Inc.

timr@probo.com