Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #96616 > unrolled thread
| Started by | Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> |
|---|---|
| First post | 2015-09-15 03:31 +0100 |
| Last post | 2015-09-17 02:17 +0100 |
| Articles | 5 — 3 participants |
Back to article view | Back to comp.lang.python
kivy editable multicolumn list Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2015-09-15 03:31 +0100
RE: kivy editable multicolumn list David Aldrich <David.Aldrich@EMEA.NEC.COM> - 2015-09-15 07:44 +0000
Re: kivy editable multicolumn list Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2015-09-17 02:02 +0100
Re: kivy editable multicolumn list Laura Creighton <lac@openend.se> - 2015-09-15 12:42 +0200
Re: kivy editable multicolumn list Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2015-09-17 02:17 +0100
| From | Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> |
|---|---|
| Date | 2015-09-15 03:31 +0100 |
| Subject | kivy editable multicolumn list |
| Message-ID | <mt7vuk$fq$1@speranza.aioe.org> |
Hi all. Not sure if this is the place to ask about kivy ... I apologize if not. I am playing with the example here https://gist.github.com/geojeff/4442405 Now I would like to change the background color the editable field. So I added def __init__(self,**kwargs): super(EditableLabel,self).__init__(**kwargs) with self.canvas.before: Color(0,1,0) Rectangle(pos=self.pos,size=self.size) print(self.pos,self.size) to class EditableLabel. But when entering __init__ self.pos and self.size do not have the correct pos/size for the EditableLabel. How can I fix this? Please no kv solutions. I need dynamic change it in a real example. Thanks for any help.
[toc] | [next] | [standalone]
| From | David Aldrich <David.Aldrich@EMEA.NEC.COM> |
|---|---|
| Date | 2015-09-15 07:44 +0000 |
| Message-ID | <mailman.586.1442303071.8327.python-list@python.org> |
| In reply to | #96616 |
> Not sure if this is the place to ask about kivy ... Try the kivy users list here: https://groups.google.com/forum/#!forum/kivy-users Best regards David
[toc] | [prev] | [next] | [standalone]
| From | Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> |
|---|---|
| Date | 2015-09-17 02:02 +0100 |
| Message-ID | <mtd3f4$c0t$1@speranza.aioe.org> |
| In reply to | #96620 |
Às 08:44 de 15-09-2015, David Aldrich escreveu: >> Not sure if this is the place to ask about kivy ... > > Try the kivy users list here: > > https://groups.google.com/forum/#!forum/kivy-users Thanks for the link.
[toc] | [prev] | [next] | [standalone]
| From | Laura Creighton <lac@openend.se> |
|---|---|
| Date | 2015-09-15 12:42 +0200 |
| Message-ID | <mailman.589.1442313796.8327.python-list@python.org> |
| In reply to | #96616 |
In a message of Tue, 15 Sep 2015 03:31:49 +0100, Paulo da Silva writes:
>Hi all.
>Not sure if this is the place to ask about kivy ...
>I apologize if not.
>
>I am playing with the example here
>https://gist.github.com/geojeff/4442405
>
>Now I would like to change the background color the editable field.
>
>So I added
> def __init__(self,**kwargs):
> super(EditableLabel,self).__init__(**kwargs)
> with self.canvas.before:
> Color(0,1,0)
> Rectangle(pos=self.pos,size=self.size)
> print(self.pos,self.size)
>
>to class EditableLabel.
>
>But when entering __init__ self.pos and self.size do not have the
>correct pos/size for the EditableLabel.
>
>How can I fix this? Please no kv solutions. I need dynamic change it in
>a real example.
I am not sure what you want for your integers_dict. It isn't the
something that Rob Collins fixtures package provides. :)
https://pypi.python.org/pypi/fixtures
I just hardcoded it like this:
integers_dict = {str(i): {'text': str(i), 'is_selected': False}
for i in range(100)}
which I pasted out of http://kivy.org/docs/api-kivy.uix.listview.html
'Using an Item View Template'. This may have no relation to what you
really want.
you also need a line
from kivy.graphics import Color, Rectangle
Then you change your class definition to be:
class EditableLabel(ListItemLabel):
def __init__(self,**kwargs):
super(EditableLabel, self).__init__(**kwargs)
self.bind(pos=self.redraw)
self.bind(size=self.redraw)
def redraw(self, *args):
self.canvas.clear()
with self.canvas:
Color(.5,.5,.5)
Rectangle(pos=self.pos,size=self.size)
I don't know why changing self.canvas.before: to self.canvas: in the redraw
method was needed here. I expected self.canvas.before to be what was
needed, but doesn't seem that way.
If you don't clear the canvas first, in the redraw the results look very
silly to me. However, since you are just playing around to learn things,
then that behaviour may be what you are looking for, so comment it out
and see if you like that better.
HTH,
Laura
[toc] | [prev] | [next] | [standalone]
| From | Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> |
|---|---|
| Date | 2015-09-17 02:17 +0100 |
| Message-ID | <mtd4al$e4v$1@speranza.aioe.org> |
| In reply to | #96626 |
Às 11:42 de 15-09-2015, Laura Creighton escreveu:
> In a message of Tue, 15 Sep 2015 03:31:49 +0100, Paulo da Silva writes:
...
>> Now I would like to change the background color the editable field.
>>
...
>
> I just hardcoded it like this:
>
> integers_dict = {str(i): {'text': str(i), 'is_selected': False}
> for i in range(100)}
>
> which I pasted out of http://kivy.org/docs/api-kivy.uix.listview.html
> 'Using an Item View Template'. This may have no relation to what you
> really want.
The example is closely based on an example that comes with kivy and is
supposed to run in the same directory. The fixtures there contain the
same as you hardcoded.
>
> you also need a line
> from kivy.graphics import Color, Rectangle
It's there. I just forgot to mention it.
>
> Then you change your class definition to be:
>
> class EditableLabel(ListItemLabel):
> def __init__(self,**kwargs):
> super(EditableLabel, self).__init__(**kwargs)
> self.bind(pos=self.redraw)
> self.bind(size=self.redraw)
>
> def redraw(self, *args):
> self.canvas.clear()
> with self.canvas:
> Color(.5,.5,.5)
> Rectangle(pos=self.pos,size=self.size)
>
This works but not as I expected. So it fixes the bug but the result I
got is not the pretended one.
I was trying to change the background color of the editable field.
That's the reason for the colored rectangle. But the rectangle overlaps
the text! So the entered text is hidden.
> I don't know why changing self.canvas.before: to self.canvas: in the redraw
> method was needed here. I expected self.canvas.before to be what was
> needed, but doesn't seem that way.
>
> If you don't clear the canvas first, in the redraw the results look very
> silly to me.
In both situations redraw is entered with wrong self.pos and self.size
values. So there are extra rectangles drawn at wrong places and sizes.
I can't understand why.
Changing self.canvas.before to self.canvas and inserting
self.canvas.clear() fixes the problem.
But as I said the drawn rectangle hides the label text.
Thank you Laura.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web