Page 1 of 1

[SOLVED] Why does 'background' in the condition disable 'hover_background'?

Posted: Thu Oct 27, 2022 3:03 am
by span4ev
I have a layout with non-standard sized buttons that I create in the loop, so I have to set my own background for a particular button.

Code: Select all

vbox:
    for i in range(len(btns)):
        hbox:
            for k in range(len(btns[i]))
                textbutton btns[i][k]:
                    background If(i == 0 or k == 3, btn_opers_bg, btn_nums_bg)
And because of this all the buttons don't have hover_background, which are written in the styles

Code: Select all

style main_button:
    background btn_nums_bg
    hover_background btn_nums_hover_bg
    xysize              btn_size
Why the conditions for background dominate - I understand. But I don't understand why it disables the visibility of the already existing hover_background in the styles, because it's a different property. Also, it's about the background, but not about other parameters, which are also set in the styles, for example - height.

I understand that I can explicitly specify hover_background here

Code: Select all

for k in range(len(btns[i]))
    textbutton btns[i][k]:
        background If(i == 0 or k == 3, btn_opers_bg, btn_nums_bg)
        hover_background 'some_color'
But I want to understand the principle of this problem and, if possible, put all the styles in style blocks instead of specifying them in the loop body

Re: Why does 'background' in the condition disable 'hover_background'?

Posted: Thu Oct 27, 2022 12:08 pm
by _ticlock_
span4ev wrote:
Thu Oct 27, 2022 3:03 am
I understand that I can explicitly specify hover_background.

But I want to understand the principle of this problem and, if possible, put all the styles in style blocks instead of specifying them in the loop body
Setting the background property sets the idle_background and hover_background properties.
If you are using style for the button and want to override only idle_background:

Code: Select all

                textbutton btns[i][k]:
                    idle_background If(i == 0 or k == 3, btn_opers_bg, btn_nums_bg)

Re: Why does 'background' in the condition disable 'hover_background'?

Posted: Thu Oct 27, 2022 9:40 pm
by span4ev
_ticlock_ wrote:
Thu Oct 27, 2022 12:08 pm
span4ev wrote:
Thu Oct 27, 2022 3:03 am
I understand that I can explicitly specify hover_background.

But I want to understand the principle of this problem and, if possible, put all the styles in style blocks instead of specifying them in the loop body
Setting the background property sets the idle_background and hover_background properties.
If you are using style for the button and want to override only idle_background:

Code: Select all

                textbutton btns[i][k]:
                    idle_background If(i == 0 or k == 3, btn_opers_bg, btn_nums_bg)
Thank you so much!