6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

kivyのドロップダウンリストはDrop-Down ListではなくSpinnerで作る

Last updated at Posted at 2018-10-27

はじめに

あなたが本当に欲しいドロップダウンリストは、こちらではないですか?
Spinner — Kivy 1.10.1 documentation

確認した環境

  • Windows 10 Pro 64bit
  • Python 3.6.6
  • pip 18.0
  • kivy 1.10.1

kvファイルを使ったサンプルコード

main.py
main.py
# -*- coding: utf-8 -*
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.spinner import Spinner

class CustomSpinner(Spinner):
    pass

class MainRoot(BoxLayout):

    def on_spinner_change(self, text):
        print('The spinner', self, 'have text', text)

class MainApp(App):
    def build(self):
        self.title = 'Spinner Test'

if __name__ == "__main__":
    MainApp().run()
main.kv
main.kv
MainRoot:

<MainRoot>:
    CustomSpinner:
        text: 'Home'
        values: 'Home', 'Work', 'Other', 'Custom'
        size_hint: None, None
        size: 100, 44
        pos_hint: {'center_x': .5, 'center_y': .5}
        on_text: root.on_spinner_change(self.text)

あとがき

Drop-Down List — Kivy 1.10.1 documentation
状況証拠からの推測でしかないのですが、こちらのDrop-Down ListはSpinnerやその他のウィジェトを作るための部品であって、気軽に直接使うものではないのではと感じています。

6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?