Transparent canvas.after

162 views
Skip to first unread message

Anton

unread,
Jul 18, 2019, 3:03:23 AM7/18/19
to Kivy users support
Hello!
I'm junior developer and I have one problem with canvas.
I need reduce canvas.after opacity to zero.
I have program with Screen Manager as root widget.
On problem screen i have BoxLayout, and normal canvas on that Layout already exists.
I need disable all screen(with that i have no problem(widget.disabled = True ;) )) and next show canvas.after with statistics.
When user decide leave statistics, i need reduce transparent of canvas.after to zero.
(Now i have solution I'm clear canvas.after with canvas.after.clear(), but its too slow, when user decide to open stats they are drawing from zero, and if user have too much data drawing takes too much time.)
I'm found instruction opacity for canvas, but its only works with normal canvas, when I try use it for canvas.after, I see that message in console:


File "/home/anton/PycharmProjects/machine/env/lib/python3.6/site-packages/kivy/lang/builder.py", line 57, in custom_callback
     exec(__kvlang__.co_value, idmap)
   File "/home/anton/PycharmProjects/machine/src/screens/control_panel.kv", line 161, in <module>
     on_release: root.stats()
   File "/home/anton/PycharmProjects/machine/src/screens/control_panel.py", line 576, in stats
     self.ids.content.canvas.after.opacity = 0
 AttributeError: 'kivy.graphics.instructions.CanvasBase' object has no attribute 'opacity'

I'm tried do another thing:
Create canvas.after with every color alfa's as NumericProperty(0), and swap values from 0 to 1.
But had another error:

def on_enter(self, *args):
    self.canvas_opacity = NumericProperty(0)




File "/home/anton/PycharmProjects/machine/src/screens/control_panel.kv", line 161, in <module>
     on_release: root.stats()
   File "/home/anton/PycharmProjects/machine/src/screens/control_panel.py", line 502, in stats
     Color(0.318, 0.318, 0.318, self.canvas_opacity)
   File "kivy/graphics/context_instructions.pyx", line 255, in kivy.graphics.context_instructions.Color.__init__
   File "kivy/graphics/context_instructions.pyx", line 275, in kivy.graphics.context_instructions.Color.rgba.__set__
 TypeError: float() argument must be a string or a number, not 'kivy.properties.NumericProperty'


int(self.canvas_opacity) is not working

How I can fix this??

Thank you in advance!
:P

Elliot Garbus

unread,
Jul 18, 2019, 10:44:20 AM7/18/19
to kivy-...@googlegroups.com

Do you want the opacity to flip between 0 and 1 every time on_enter is fired?

 

def on_enter(self, *args):

    #self.canvas_opacity = NumericProperty(0)

    self.canvas_opacity = 1 if self.canvas_opacity == 0 else 0

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/f8535570-3b23-4223-9ba8-e7cce5459b3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 

Anton

unread,
Jul 19, 2019, 2:32:48 AM7/19/19
to Kivy users support
Yes, I want to flip, but I have button for that

четверг, 18 июля 2019 г., 16:44:20 UTC+2 пользователь Elliot Garbus написал:

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

Elliot Garbus

unread,
Jul 19, 2019, 10:45:08 AM7/19/19
to kivy-...@googlegroups.com

Are you still having an issue?

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/c69aae8c-6026-4507-9347-ea161110d8e0%40googlegroups.com.

 

Anton

unread,
Jul 20, 2019, 9:32:22 AM7/20/19
to Kivy users support
yes

пятница, 19 июля 2019 г., 16:45:08 UTC+2 пользователь Elliot Garbus написал:

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

Elliot Garbus

unread,
Jul 20, 2019, 9:33:47 AM7/20/19
to kivy-...@googlegroups.com
Can you describe the problem or even better attach a small test case?


To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/a20cd2b4-fb7c-4c14-ae11-183ba5ad55f5%40googlegroups.com.

Anton

unread,
Jul 23, 2019, 8:17:14 AM7/23/19
to Kivy users support
Here is simple example: https://drive.google.com/open?id=1c0Ai7WSBFAwrgl1MKaBFOT1M5nUE-XlJ

On example i have no data, but when i have data -  drawing canvas is take too much time (0.5 - 1.5 sec)

суббота, 20 июля 2019 г., 15:33:47 UTC+2 пользователь Elliot Garbus написал:

Elliot Garbus

unread,
Jul 23, 2019, 10:46:42 AM7/23/19
to kivy-...@googlegroups.com

Can you take a different approach?

The canvas is not a widget, it is a set of drawing instructions.  The layers, canvas.before, canvas, and .after provide control over drawing order.

 

Can you put the statistics on a different screen and when the user leaves, transition to a blank screen?

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/e22d56b2-89e7-4be3-a5b3-2ecc68409374%40googlegroups.com.

 

Anton

unread,
Jul 24, 2019, 6:17:37 AM7/24/19
to Kivy users support
I have some processes on that screen, I can't leave that screen. (After the all i think it can be on two different screens, but its too much things to rewrite in code.If there is no another solution, I have no choice and will rewrite all)

Thank You for your help!

вторник, 23 июля 2019 г., 16:46:42 UTC+2 пользователь Elliot Garbus написал:
Reply all
Reply to author
Forward
0 new messages