-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton (Label, Image)_Example.py
46 lines (36 loc) · 1.09 KB
/
Button (Label, Image)_Example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# import kivy
# from kivy.app import App
# from kivy.uix.label import Label
# class MyApp(App):
# def build(self):
# label = Label(text='Hello from Kivy App')
# return label
# if __name__ == '__main__':
# MyApp().run()
# from kivy.app import App
# from kivy.uix.image import Image
# class MainApp(App):
# def build(self):
# return Image(source='C:/Users/rahul.shah/Desktop/1.PNG')
# if __name__ == '__main__':
# app = MainApp()
# app.run()
import random
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
red = [1,0,0,1]
green = [0,1,0,1]
blue = [0,0,1,1]
purple = [1,0,1,1]
class HBoxLayoutExample(App):
def build(self):
layout = BoxLayout(padding=10)
colors = [red, green, blue, purple]
for i in range(10):
btn = Button(text="Button #%s" % (i+1), background_color=random.choice(colors))
layout.add_widget(btn)
return layout
if __name__ == "__main__":
app = HBoxLayoutExample()
app.run()