mirror of https://github.com/kivy/kivy.git
Page:
Control alpha of all the children
Pages
A draggable scrollbar using a slider
AdBuddiz Android advertisements integration for Kivy apps
Advanced Graphics: In Progress
An example of background Twisted server running on Android
Android Background Services
Android SDK NDK Information
Android SDK NDK Informations
Android native embedded browser
Android style menu app skeleton
Background Service using P4A android.service
Batch installer for windows(KivyInstaller)
Breaking changes in Kivy
Building Portable Package
Button(s) in settings panel
Buttons in Settings panel
Community Guidelines
Connecting Kivy with Anaconda (OSX)
Contextual Menus
Contextual menus
Control alpha of all the children
Create source distribution release on PyPI
Creating a Release APK
Data driven variables with kivy properties
Debugging widget sizes
Deep Linking with iOS and Android
Delayed Work using Clock
Drag and Drop Widgets
Dragable Widget
Draggable Scalable Button
Editable ComboBox
Editable Label
Embedding a Carousel inside a TabbedPanel
GestureBox
Home
Implementing Android Adaptive Icons
KEP001: Instantiate things other than widgets from kv
Kivy 2.0 api breaks
Kivy Blogs and Blog Posts
Kivy Python 2 Support Timeline
Kivy Technical FAQ
Kv language preprocessing
Linking ScreenManager to a different Widget
List of Kivy Projects
Markup Summary
Menu on long touch
Migration guide from legacy garden packages
Moving kivy.garden.xxx to kivy_garden.xxx and kivy.deps.xxx to kivy_deps.xxx
On touch current widget
On touch on current widget
Packaging Kivy apps written in Python 3, targeting Windows using Nuitka
Pyjnius Vibrator Example
Release Checklist
Release notes for 1.10.0
Release notes for 1.11.0
Sample Gestures
Scaler for Retina screen
Scollable Options in Settings panel
Scrollable Label
Setting Up Kivy with various popular IDE's
Setting up Pycharm on OSX (older versions)
Setting up garden with Mac Ports
Setting up kivy with various popular IDE
Simple slider with value in label
Snippet template
Snippets awaiting moderation
Snippets
Starting Kivy App and Service on bootup on Android
Styling a Spinner and SpinnerOption in KV
Talks and tutorials
Theming Kivy
Tiled Maps & Tile Based Movement
Tiling the background of a widget with an image, pixel perfect
Ubuntu Touch
Updating widget content from a items list
User Snippets
Using Asynchronous programming inside a Kivy application
Using Buildozer on windows 10 using WSL
Viewport with fixed resolution autofit to window
Windows RT
Working with Python threads inside a Kivy application
rand0m app
wiki_proposed
2
Control alpha of all the children
Aron Barreira Bordin edited this page 2015-07-10 20:00:26 -03:00
Table of Contents
Summary
- author: Mathieu Virbel
- kivy: >= 1.0.7
The idea of this snippet is to control the alpha of all children. You cannot set a color or global alpha. So the idea is to draw all the children in a Framebuffer, and draw this framebuffer with a custom color.
Note: One can use opacity
property of a Widget since 1.4.1
We are making this widget in top of FloatLayout.
Usage
#!python
from fbofloatlayout import FboFloatLayout
layout = FboFloatLayout()
# add here your own widget like:
# layout.add_widget(Button(text='hello world'))
# hide every widgets
layout.alpha = 0
# show all widgets with alpha = 50%
layout.alpha = 0.5
# you can even animate it
from kivy.animation import Animation
Animation(alpha=1.0).start(layout)
Files
fbofloatlayout.py
#!python
__all__ = ('FboFloatLayout', )
# needed to create Fbo, must be resolved in future kivy version
from kivy.core.window import Window
from kivy.graphics import Color, Rectangle, Canvas
from kivy.graphics.fbo import Fbo
from kivy.uix.floatlayout import FloatLayout
from kivy.properties import ObjectProperty, NumericProperty
class FboFloatLayout(FloatLayout):
texture = ObjectProperty(None, allownone=True)
alpha = NumericProperty(1)
def __init__(self, **kwargs):
self.canvas = Canvas()
with self.canvas:
self.fbo = Fbo(size=self.size)
self.fbo_color = Color(1, 1, 1, 1)
self.fbo_rect = Rectangle()
# wait that all the instructions are in the canvas to set texture
self.texture = self.fbo.texture
super(FboFloatLayout, self).__init__(**kwargs)
def add_widget(self, *largs):
# trick to attach graphics instructino to fbo instead of canvas
canvas = self.canvas
self.canvas = self.fbo
ret = super(FboFloatLayout, self).add_widget(*largs)
self.canvas = canvas
return ret
def remove_widget(self, *largs):
canvas = self.canvas
self.canvas = self.fbo
super(FboFloatLayout, self).remove_widget(*largs)
self.canvas = canvas
def on_size(self, instance, value):
self.fbo.size = value
self.texture = self.fbo.texture
self.fbo_rect.size = value
def on_pos(self, instance, value):
self.fbo_rect.pos = value
def on_texture(self, instance, value):
self.fbo_rect.texture = value
def on_alpha(self, instance, value):
self.fbo_color.rgba = (1, 1, 1, value)
##Comments Add your comments here