textCrtrl custom renderer

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

textCrtrl custom renderer

sebastian lópez
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 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: textCrtrl custom renderer

Karsten Hilbert
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 the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: textCrtrl custom renderer

sebastian lópez
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 <[hidden email]>:
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 [hidden email].
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 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: textCrtrl custom renderer

Karsten Hilbert
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 <[hidden email]>:
>
> > 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
> > [hidden email].
> > 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 [hidden email].
> 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 the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: textCrtrl custom renderer

sebastian lópez

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.

 

 

 

2014-10-26 11:27 GMT-05:00 Karsten Hilbert <[hidden email]>:

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 <[hidden email]>:
>
> > 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
> >
[hidden email].
> > For more options, visit
https://groups.google.com/d/optout.
> >
>
>
>
> --
> Atentamente
>
> [image: sebastián]
> Sebastián López
> Ingeniero Químico
> cel
<a href="tel:317-709-0956">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
[hidden email].

> 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
[hidden email].
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 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

defaultTxtTest.py (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: textCrtrl custom renderer

Yoriz
In reply to this post by sebastian lópez


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 

<a href="https://lh4.googleusercontent.com/-31USoxFcVso/VE0YqlUIQhI/AAAAAAAAA3Y/2eBQ5ORyyEY/s1600/render%2Bempty.png" style="margin-left:1em;margin-right:1em" target="_blank" onmousedown="this.href='https://lh4.googleusercontent.com/-31USoxFcVso/VE0YqlUIQhI/AAAAAAAAA3Y/2eBQ5ORyyEY/s1600/render%2Bempty.png';return true;" onclick="this.href='https://lh4.googleusercontent.com/-31USoxFcVso/VE0YqlUIQhI/AAAAAAAAA3Y/2eBQ5ORyyEY/s1600/render%2Bempty.png';return true;">

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 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.

 
 

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: textCrtrl custom renderer

Nathan McCorkle
In reply to this post by sebastian lópez
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 

<a href="https://lh4.googleusercontent.com/-31USoxFcVso/VE0YqlUIQhI/AAAAAAAAA3Y/2eBQ5ORyyEY/s1600/render%2Bempty.png" style="margin-left:1em;margin-right:1em" target="_blank" onmousedown="this.href='https://lh4.googleusercontent.com/-31USoxFcVso/VE0YqlUIQhI/AAAAAAAAA3Y/2eBQ5ORyyEY/s1600/render%2Bempty.png';return true;" onclick="this.href='https://lh4.googleusercontent.com/-31USoxFcVso/VE0YqlUIQhI/AAAAAAAAA3Y/2eBQ5ORyyEY/s1600/render%2Bempty.png';return true;">

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 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: textCrtrl custom renderer

Tim Roberts
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).

I don't think that's the right model.  He's looking for the same functionality as the "placeholder" attribute in a modern HTML <input> 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.
-- 
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.