Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wiseplat
GitHub Repository: wiseplat/python-code
Path: blob/master/mobile-test/file12.py
5925 views
1
from kivy.lang import Builder
2
3
from kivymd.app import MDApp
4
5
from kivy.uix.floatlayout import FloatLayout
6
from kivymd.uix.tab import MDTabsBase
7
8
KV = '''
9
#https://stackoverflow.com/questions/65698145/kivymd-tab-name-containing-icons-and-text
10
# this import will prevent disappear tabs through some clicks on them)))
11
#:import md_icons kivymd.icon_definitions.md_icons
12
#:import fonts kivymd.font_definitions.fonts
13
14
Screen:
15
16
MDNavigationLayout:
17
18
ScreenManager:
19
20
Screen:
21
22
BoxLayout:
23
orientation: 'vertical'
24
25
MDTabs:
26
id: tabs
27
height: "48dp"
28
tab_indicator_anim: False
29
30
Tab:
31
id: tab1
32
name: 'tab1'
33
text: f"[size=20][font={fonts[-1]['fn_regular']}]{md_icons['star']}[/size][/font] Star"
34
35
BoxLayout:
36
orientation: 'vertical'
37
padding: "10dp"
38
39
BoxLayout:
40
orientation: 'horizontal'
41
42
MDIconButton:
43
icon: "calendar"
44
45
MDTextField:
46
id: start_date
47
hint_text: "Date"
48
text: "Why this text grey? I want blue text here!!! (with no Focus)"
49
text_hint_color:[0,0,1,1]
50
51
BoxLayout:
52
orientation: 'horizontal'
53
54
MDIconButton:
55
icon: "cash"
56
57
MDTextField:
58
id: test
59
hint_text: "test"
60
text: "Why this text grey? I want blue text here!!!"
61
text_hint_color:[0,0,1,1]
62
Tab:
63
id: tab2
64
name: 'tab2'
65
text: f"[size=20][font={fonts[-1]['fn_regular']}]{md_icons['star']}[/size][/font] Star 2"
66
67
BoxLayout:
68
orientation: 'vertical'
69
padding: "10dp"
70
71
BoxLayout:
72
orientation: 'horizontal'
73
74
MDIconButton:
75
icon: "calendar"
76
77
MDTextField:
78
id: start_date2
79
hint_text: "Date"
80
81
BoxLayout:
82
orientation: 'horizontal'
83
84
MDIconButton:
85
icon: "cash"
86
87
MDTextField:
88
id: test2
89
hint_text: "test2"
90
91
Tab:
92
id: tab3
93
name: 'tab3'
94
text: f"[size=20][font={fonts[-1]['fn_regular']}]{md_icons['star']}[/size][/font] Star3"
95
96
BoxLayout:
97
orientation: 'vertical'
98
padding: "10dp"
99
100
BoxLayout:
101
orientation: 'horizontal'
102
103
MDIconButton:
104
icon: "calendar"
105
106
MDTextField:
107
id: start_date3
108
hint_text: "Date"
109
110
BoxLayout:
111
orientation: 'horizontal'
112
113
MDIconButton:
114
icon: "cash"
115
116
MDTextField:
117
id: test3
118
hint_text: "test3"
119
120
121
122
'''
123
124
125
class Tab(FloatLayout, MDTabsBase):
126
'''Class implementing content for a tab.'''
127
128
129
class TestApp(MDApp):
130
131
def __init__(self, **kwargs):
132
super().__init__(**kwargs)
133
self.screen = Builder.load_string(KV)
134
135
def build(self):
136
self.theme_cls.theme_style = "Light" # "Dark" # "Light"
137
# return Builder.load_string(KV)
138
return self.screen
139
140
def on_start(self):
141
pass
142
143
def on_tab_switch(self, instance_tabs, instance_tab, instance_tabs_label, tab_text):
144
pass
145
146
147
TestApp().run()
148
149