파이썬[Python]: kivyMD - MDTabs 클래스 - kv
kivymd.uix.tab 모듈 - MDTabs 클래스(class)
/// 설명 (kivy + kivyMD)
탭(tab) 입니다.
참고: kivyMD 모듈 목록
※ 형식
MDTabs(**kwargs)
reference
https://kivymd.readthedocs.io/en/latest/components/tabs/
참고: kivyMD 모듈 목록
※ 형식
MDTabs(**kwargs)
reference
https://kivymd.readthedocs.io/en/latest/components/tabs/
/// 예제
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | import kivy kivy.require('2.0.0') from kivy.core.window import Window from kivy.lang import Builder from kivymd.app import MDApp from kivymd.uix.tab import MDTabsBase from kivymd.uix.floatlayout import MDFloatLayout from kivymd.icon_definitions import md_icons Window.size = (563, 1001) Window.top, Window.left = 30, 700 kv = ''' MDScreen: # Phone-like radius: (25, 25, 25, 25) md_bg_color: (1, 1, 1, 1) size_hint: (.99, .98) pos_hint: {'right': .995, 'top': .985} MDBoxLayout: orientation: 'vertical' Widget: size_hint_y: None height: 20 MDToolbar: title: 'Toolbar Tabs' MDTabs: id: id_MDt on_tab_switch: app.on_tab_switch(*args) <Tab>: MDLabel: id: id_MDl text: 'ab-testing' halign: 'center' theme_text_color: 'Custom' text_color: (0, .5, .5, 1) ''' class Tab(MDFloatLayout, MDTabsBase): pass class FantasticApp(MDApp): def on_tab_switch(self, instance_tabs, instance_tab, instance_tab_label, tab_text): print(instance_tabs) print(instance_tab) print(instance_tab_label) print(tab_text) instance_tab.ids.id_MDl.text = instance_tab.title def on_start(self): for name_tab in list(md_icons.keys())[:15]: self.root.ids.id_MDt.add_widget(Tab(icon=name_tab, title=name_tab)) def build(self): self.theme_cls.theme_style = 'Dark' return Builder.load_string(kv) FantasticApp().run() | cs |
/// 출력
* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)
– 당신을 응원합니다. –
댓글
댓글 쓰기