Kivy

【Kivy】Clock を利用する

定期的に実行する main.py from kivy.app import App from kivy.clock import Clock class MainApp(App): def on_start(self): Clock.schedule_interval(self.on_callback, 1.) def on_callback(self, delta: float): print('on_callback') if __name__ == '…

【Kivy】App の簡単な使い方

main.py from kivy.app import App class MainApp(App): def on_start(self): self.title = 'Hello world' print('on_start') def on_stop(self): print('on_stop') if __name__ == '__main__': MainApp().run()

【Kivy】StackLayout を利用して敷き詰めるように並べる

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 StackLayout: Button: text: 'button 1' size_hint: None, None size: 400, 80 Button: text: 'button 2' size_hint: None, Non…

【Kivy】ScatterLayout を利用してユーザが自由配置できるようにする

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 ScatterLayout: Button: text: 'button 1' size_hint: None, None size: 800, 600

【Kivy】RelativeLayout を利用し、画面サイズに応じて配置する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 RelativeLayout: Button: text: 'button 1' size_hint: None, None size: 400, 1200 pos_hint: {'x': .4, 'y': .1} Button: tex…

【Kivy】PageLayout でページ送りを実装する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 PageLayout: Button: text: 'page 1' Button: text: 'page 2' Button: text: 'page 3'

【Kivy】AnchorLayout を利用し、アンカーポイントを基準に配置する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 AnchorLayout: anchor_x: 'right' anchor_y: 'top' Button: text: 'button 1' size_hint: None, None size: 400, 100

【Kivy】GridLayout を利用し、表のように並べる

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 GridLayout: cols: 2 Button: text: 'button 1' Button: text: 'button 2' Button: text: 'button 3' Button: text: 'button 4'

【Kivy】FloatLayout を利用し、画面サイズに応じて配置する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 FloatLayout: Button: text: 'button 1' size_hint: .4, .2 pos_hint: {'x':.2, 'y':.3} Button: text: 'button 2' size_hint: …

【Kivy】BoxLayout を利用し、縦に並べる

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 BoxLayout: orientation: 'vertical' Button: text: 'button 1' Button: text: 'button 2' Button: text: 'button 3' Button: t…

【Kivy】BoxLayout を利用し、横に並べる

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 BoxLayout: orientation: 'horizontal' Button: text: 'button 1' Button: text: 'button 2' Button: text: 'button 3' Button:…

【Kivy】ActionBar を表示する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 ActionBar: ActionView: ActionPrevious: title: 'Previous' with_previous: False ActionButton: text: 'button'

【Kivy】Splitter を利用する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 BoxLayout: Splitter: sizable_from: 'right' strip_size: '10pt' Label: text: 'item 1' Label: text: 'item 2'

【Kivy】任意の描画を行う

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 <ColorBox@Widget>: color: [1, 1, 1] canvas: Color: rgb: root.color Rectangle: size: self.size pos: self.pos Widget: ColorBox: size_hint:</colorbox@widget>…

【Kivy】Accordion を表示する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 Accordion: AccordionItem: title: 'item 1 title' Label: text: 'item 1 contents' AccordionItem: title: 'item 2 title' Lab…

【Kivy】RecycleView を表示する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 RecycleView: data: [{'text': 'Item 1'}, {'text': 'Item 2'}, {'text': 'Item 3'}] viewclass: 'Label' RecycleBoxLayout: de…

【Kivy】FileChooserListView を表示する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 FileChooserListView:

【Kivy】Scatter を表示する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 Scatter: Image: source: 'sample.png' sample.png

【Kivy】ScreenManager を利用する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 <Screen_1@Screen>: name: 'Screen 1' BoxLayout: orientation: 'vertical' Label: text: 'Display 1' Button: size_hint_y: None height: 120 te</screen_1@screen>…

【Kivy】ScrollView を表示する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 ScrollView: do_scroll_x: False do_scroll_y: True Label: size_hint_y: None height: self.texture_size[1] padding: 10, 10 …

【Kivy】ModalView を表示する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 #:import Factory kivy.factory.Factory <MyModalView@ModalView>: auto_dismiss: False size_hint: .5, .5 pos_hint: {'center_x': .5, 'center_y': .5</mymodalview@modalview>…

【Kivy】ToggleButton を表示する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 BoxLayout: ToggleButton: text: 'item 1' group: 'group 1' ToggleButton: text: 'item 2' group: 'group 1' ToggleButton: te…

【Kivy】Switch を表示する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 Switch:

【Kivy】Slider を表示する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 Slider: min: 0 max: 100 value: 25

【Kivy】ProgressBar を表示する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 ProgressBar: max: 1.0 value: .5

【Kivy】Popup を表示する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 #:import Factory kivy.factory.Factory <MyPopup@Popup>: auto_dismiss: False size_hint: .5, .5 pos_hint: {'center_x': .5, 'center_y': .5</mypopup@popup>…

【Kivy】EffectWidget を利用する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 #: import ew kivy.uix.effectwidget EffectWidget: effects: ew.InvertEffect(), ew.HorizontalBlurEffect(size=2.0) Button: …

【Kivy】Camera を表示する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 Camera: resolution: 1280, 720

【Kivy】CodeInput を表示する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 CodeInput:

【Kivy】Drop-DownList を表示する

main.py from kivy.app import App class MainApp(App): pass if __name__ == '__main__': MainApp().run() main.kv #:kivy 1.0 DropDown: size_hint: 1.0, 1.0 Button: text: 'My first Item' size_hint_y: None height: 80 on_release: root.select('item1…