Created
July 6, 2016 19:43
-
-
Save Alan-FGR/b3051e13d64d0faea7257540493f8c2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.app import App | |
from kivy.app import Builder | |
from kivy.uix.stacklayout import StackLayout | |
from kivy.uix.button import Button | |
Builder.load_string(""" | |
#:set RED (1, 0, 0, 1) | |
#:set GREEN (0, 1, 0, 1) | |
#:set BLUE (0, 0, 1, 1) | |
#:set YELLOW (1, 1, 0, 1) | |
<-Button>: | |
size_hint_y: None | |
height: 40 | |
opacity: 0.8 if self.disabled else 1 | |
color: RED if self.disabled else GREEN # doesn't work | |
# can't even use white and tint | |
# it on line 28 as a workaround :( | |
canvas.before: | |
Color: | |
rgb: YELLOW if self.disabled else BLUE | |
Rectangle: | |
size: self.size | |
pos: self.pos | |
canvas: | |
Color: | |
rgb: 1,1,1,1 | |
Rectangle: | |
texture: self.texture | |
size: self.texture_size | |
pos: self.center_x - self.texture_size[0]*0.5, self.y+10 | |
""") | |
class Test(App): | |
def build(self): | |
root_layout = StackLayout() | |
root_layout.padding = root_layout.spacing = 10 | |
for i in xrange(6): | |
root_layout.add_widget(Button(text="DISABLED STYLING PROBLEM")) | |
root_layout.children[2].disabled=True | |
root_layout.children[5].disabled = True | |
return root_layout | |
def increase_size(self, *args): | |
self.my_unit += 1 | |
print self.my_unit | |
if __name__ == "__main__": | |
Test().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OK, just found a workaround for that issue, basically setting disabled_color did the trick (undoc'd, had to browse the sources to find that out), but it doesn't take opacity into account so I've used list comprehension to workaround that problem in the original workaround. Yeah, a workaround in the workaround.
Here's the working version: