2019年12月19日木曜日

開発環境

Kivy Blogの記事、Kivy tutorial 001: Say Hello

In every Kivy application, your first task is to create an App subclass as follows:
以下のコードのインデントがおかしいのがちょっと気になったから修正したコードを書いてみた。

コード

#!/usr/bin/env python3
from kivy.app import App
from kivy.uix.label import Label


class YourApp(App):
    def build(self):
        root_widget = Label(text='Hello world!')
        return root_widget


YourApp().run()

入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))

% ./sample.py
[INFO   ] [Logger      ] Record log in /Users/kamimura/.kivy/logs/kivy_19-12-19_1.txt
[INFO   ] [Kivy        ] v1.11.1
[INFO   ] [Kivy        ] Installed at "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/kivy/__init__.py"
[INFO   ] [Python      ] v3.7.5 (default, Oct 28 2019, 07:13:20) 
[Clang 11.0.0 (clang-1100.0.33.8)]
[INFO   ] [Python      ] Interpreter at "/opt/local/bin/python3"
[INFO   ] [Factory     ] 184 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 <sdl2>
[INFO   ] [GL          ] OpenGL version <b'2.1 INTEL-14.2.16'>
[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
[INFO   ] [WindowSDL   ] exiting mainloop and closing.
[INFO   ] [Base        ] Leaving application in progress...
%

すぐに気づくコードの誤りだし、修正は簡単なものの、Pythonのコードではインデントが重要な役割を果たすということで。

0 コメント:

コメントを投稿