파이썬[Python]: kivy - ScreenManager 클래스
kivy.uix.screenmanager 모듈 - ScreenManager 클래스(class)
/// 설명
여러 스크린의 사용을 관리하여주는 위젯입니다.
참고: uix 모듈 목록
※ 형식
ScreenManager(**kwargs)
reference
https://kivy.org/doc/stable/api-kivy.uix.screenmanager.html
참고: uix 모듈 목록
※ 형식
ScreenManager(**kwargs)
reference
https://kivy.org/doc/stable/api-kivy.uix.screenmanager.html
/// 예제
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 | import kivy kivy.require('2.0.0') from kivy.app import App from kivy.core.window import Window from kivy.uix.boxlayout import BoxLayout from kivy.uix.button import Button from kivy.uix.screenmanager import ScreenManager, Screen, \ FadeTransition Window.clearcolor = (.6, 1, .8, 1) Window.size = (563, 1001) Window.top, Window.left = 30, 700 class TestFirst(BoxLayout, Screen): def _bt_pressed(self, bt_instance): self.manager.current = 'SecondScreen' def __init__(self, **kwargs): super(TestFirst, self).__init__(**kwargs) self.add_widget(Button(text='GUI Programming', on_press=self._bt_pressed)) class TestSecond(BoxLayout, Screen): def _bt_pressed(self, bt_instance): self.manager.current = 'FirstScreen' def __init__(self, **kwargs): super(TestSecond, self).__init__(**kwargs) self.add_widget(Button(text='It is interesting.', on_press=self._bt_pressed)) class FantasticApp(App): def build(self): sm = ScreenManager(transition=FadeTransition()) sm.add_widget(TestFirst(name='FirstScreen')) sm.add_widget(TestSecond(name='SecondScreen')) return sm FantasticApp().run() | cs |
/// 출력
* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)
– 당신을 응원합니다. –
댓글
댓글 쓰기