是否可以在Kivy中使Button
透明?
此处仅供参考:页面代码:
class home(Screen):
def __init__(self,**kwargs):
super (home,self).__init__(**kwargs)
bkg = GridLayout(cols = 1)
i = Image(source='/Users/User/Downloads/im3.jpg',y = bkg.height)
bkg.add_widget(i)
my_box1 = BoxLayout(orientation='vertical')
my_button1 = Button(text="Run tests",size_hint_y=None, size_y=100)
my_button2 = Button(text="View VG images",size_hint_y=None, size_y=100)
my_button3 = Button(text="View test logs",size_hint_y=None, size_y=100)
my_button1.bind(on_press=self.run)
my_button2.bind(on_press=self.vg)
my_button3.bind(on_press=self.logs)
my_box1.add_widget(my_button1)
my_box1.add_widget(my_button2)
my_box1.add_widget(my_button3)
self.add_widget(bkg)
self.add_widget(my_box1)
def run(self,*args):
self.manager.current = 'RunTests'
def vg(self,*args):
self.manager.current = 'vgMenu'
def logs(self,*args):
self.manager.current = 'logs'
答案 0 :(得分:1)
当然是!只需使用background_color
,然后使用color
。
如果您使用4位数的形状,则它是RGBA模式,即您也可以为颜色设置 alpha ,因此您可以使其透明:
from kivy.lang import Builder
from kivy.base import runTouchApp
runTouchApp(Builder.load_string('''
BoxLayout:
canvas:
Color:
rgba: 1, 0, 0, 1
Rectangle:
size: self.size
pos: self.pos
Button:
background_color: 0, 0, 0, 0
text: 'blob'
'''))