KivyMD
KivyMD copied to clipboard
KivyMD ToggleButton disabled incorrect color
Description of the Bug
When disabling ToggleButtons, the button turns dark grey if the toggle button has been used but is very light grey if it hasnt been used
Below code is simple 2 toggle buttons and one switch.
Run the code:
First click switch, both buttons disabled and color is just faded - no fill.
Next, click switch to enable buttons and select one only then click it again to unselect it.
Next click the switch to disable buttons. This time one button is dark grey and the other is still faded.
If you do it all again and this time interact with both buttons then disable them, the selected button will be dark grey, the unselcted will be light grey.
I think correct behaviour should be when diabled button should be pale if unseleceted and light grey if selected prior to disabled.
The dark grey is getting in there and I dont think it should be!!
First time reporting a bug so hope it makes sense!!
Code and Logs
from kivy.lang import Builder
from kivymd.app import MDApp
from kivymd.uix.behaviors.toggle_behavior import MDToggleButton
from kivymd.uix.button import MDRoundFlatButton
KV = '''
FloatLayout:
MyToggleButton:
text: "Botton 1"
group: 1
pos_hint: {'center_x': .5, 'center_y': .2}
on_press: print("this is button 1")
disabled: checkbox.active
MyToggleButton:
text: "Botton 2"
group: 1
pos_hint: {'center_x': .5, 'center_y': .5}
on_press: print("this is button 2")
disabled: checkbox.active
MDSwitch:
id: checkbox
pos_hint: {'center_x': .5, 'center_y': .8}
'''
class MyToggleButton(MDRoundFlatButton, MDToggleButton):
pass
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
Versions
- OS: Windows
- Python: 3.10.6
- Kivy: 2.1
- KivyMD: 1.1.0.dev0
@eo93ed
from kivy.lang import Builder
from kivymd.app import MDApp
KV = '''
MDScreen:
MDBoxLayout:
id: btn1
adaptive_size: True
spacing: "12dp"
pos_hint: {'center_x': .5, 'center_y': .5}
MDRaisedButton:
id: btn2
md_bg_color: "red"
text: "MDRaisedButton"
MDRectangleFlatButton:
id: btn3
text: "MDRectangleFlatButton"
MDFlatButton:
id: btn4
text: "MDFlatButton"
MDFlatButton:
id: btn5
text: "MDFlatButton"
md_bg_color: "green"
MDRaisedButton:
text: "Disabled"
y: "24dp"
pos_hint: {'center_x': .5}
on_release:
btn1.disabled = not btn1.disabled
btn2.disabled = not btn1.disabled
btn3.disabled = not btn1.disabled
btn4.disabled = not btn1.disabled
btn5.disabled = not btn1.disabled
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
This is normal behavior for buttons that have md_bg_color
set.