【问题标题】:How to fix a kivy button that appears transparent by default如何修复默认显示为透明的 kivy 按钮
【发布时间】:2018-12-23 14:31:57
【问题描述】:

我在使用 kivy == 1.11 时遇到了奇怪的行为。我的按钮看起来是透明的,即使我专门给它们完全不透明。我的代码如下:

from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.scrollview import ScrollView
from kivy.uix.button import Button

class Names(BoxLayout):

    def __init__(self,tb = {}, **kwargs):
        super().__init__(**kwargs)
        names = ["Jane","Joe","John","Janet"]
        table = GridLayout(cols=columns,padding=30,spacing=.5,size_hint_y=None)
        table.bind(minimum_height=table.setter('height'))
        floor = ScrollView(size_hint=(1, None), size=(Window.width, Window.height-180),bar_color=(0.06,.47,.47, 1),bar_inactive_color=(.06,.47,.47, 1),bar_width=10,scroll_type=['bars'])
        floor.add_widget(table)
        self.add_widget(floor)

        for h in names:
            btn = Button(text=h,color=(1,0,0,1), disabled=True)
            btn.background_color=(.06, .45, .45, 1)
            btn.background_disabled=''
            table.add_widget(btn)

class SAPP(App):
    def build(self):
        return Names()

if __name__=='__main__':
    SAPP().run(

任何人有类似的问题?或解决方案?

【问题讨论】:

  • background_color 可能是您的问题。根据documenttionbackground_coloracts as a multiplier to the texture colour。试试去掉background_color看看效果。

标签: python-3.x user-interface kivy


【解决方案1】:

我认为您没有更改的默认禁用按钮图像是半透明的。你的意思是设置btn.background_disabled_normal

【讨论】:

    【解决方案2】:

    原来问题出在 Kivy 本身,我使用的是 github Kivy-1.11-dev 版本,不用说,它仍在开发中。回滚到 Kivy-1.10,当前稳定的构建解决了我的问题。我还用其他程序测试了这个,似乎是同样的问题/修复

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-10
      • 1970-01-01
      • 1970-01-01
      • 2021-10-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多