2019年2月6日水曜日

開発環境

Kivyプログラミング ―Pythonで作るマルチタッチアプリ― (実践Pythonライブラリー) (原口 和也(著)、久保 幹雄(監修)、朝倉書店)の4(KV言語)、4.5(演習問題)、演習4.2の解答を求めてみる。

コード

Python 3

#!/usr/bin/env python3
from kivy.app import App
# 日本語用
from kivy.core.text import LabelBase, DEFAULT_FONT
LabelBase.register(DEFAULT_FONT, 'NotoSansCJKjp-Regular.otf')


class Sample3App(App):
    pass


Sample3App().run()

KV言語

BoxLayout:
    orientation: 'vertical'
    Label:
        id: label
        font_size: 200
    BoxLayout:
        orientation: 'horizontal'
        size_hint_y: 0.2
        Button:
            text: '0'
            on_press: label.text = label.text[-6:] + self.text; print(self.text)
        Button:
            text: '1'
            on_press: label.text = label.text[-6:] + self.text; print(self.text)          
        Button:
            text: '2'
            on_press: label.text = label.text[-6:] + self.text; print(self.text)          
        Button:
            text: '3'
            on_press: label.text = label.text[-6:] + self.text; print(self.text)          
        Button:
            text: '4'
            on_press: label.text = label.text[-6:] + self.text; print(self.text)          
        Button:
            text: '5'
            on_press: label.text = label.text[-6:] + self.text; print(self.text)          
        Button:
            text: '6'
            on_press: label.text = label.text[-6:] + self.text; print(self.text)          
        Button:
            text: '7'
            on_press: label.text = label.text[-6:] + self.text; print(self.text)          
        Button:
            text: '8'
            on_press: label.text = label.text[-6:] + self.text; print(self.text)          
        Button:
            text: '9'
            on_press: label.text = label.text[-6:] + self.text; print(self.text)          
                
            

入出力結果(Terminal、cmd(コマンドプロンプト)、Jupyter(IPython))

$ python3 sample3.py
[INFO   ] [Logger      ] Record log in /...
[INFO   ] [Kivy        ] v1.10.1
[INFO   ] [Python      ] v3.7.2 (default, Dec 30 2018, 08:55:50) 
[Clang 10.0.0 (clang-1000.11.45.5)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_imageio, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
[INFO   ] [GL          ] Backend used <gl>
[INFO   ] [GL          ] OpenGL version <b'2.1 INTEL-12.4.7'>
[INFO   ] [GL          ] OpenGL vendor <b'Intel Inc.'>
[INFO   ] [GL          ] OpenGL renderer <b'Intel(R) Iris(TM) Pro Graphics 6200'>
[INFO   ] [GL          ] OpenGL parsed version: 2, 1
[INFO   ] [GL          ] Shading version <b'1.20'>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <16>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO   ] [Base        ] Start application main loop
[INFO   ] [GL          ] NPOT texture support is available
0
0
1
2
3
4
5
6
7
8
9
9
[INFO   ] [Base        ] Leaving application in progress...
$

0 コメント:

コメントを投稿

関連コンテンツ