From Kivy environment construction to displaying Hello World

Summary

When holding a study session, it seems that there are many cases where the environment construction is stumbled, so make a note. This method is not always the correct answer.

What is Kivy

By the way. Kivy is a Python framework for NUI development. It is relatively easy to develop GUI applications that operate cross-platform and support multi-touch.

Kivy environment construction

To build the environment, please download the one suitable for each OS from http://kivy.org/#download. スクリーンショット 2015-11-10 12.06.38.png

Windows Building a Windows environment is relatively easy. First of all, run the downloaded Kivy-1.9.0-py \ *. \ *-Win32-x \ * \ . Exe. ( Is the version number, etc.) Then you will have a folder called Kivy-1.9.0-py \ *. \ * -Win32-x \ * \ * in the same directory. The contents are like an image. dir_kivy.PNG

Double-click kivy-\ *. \ *. Bat in this to start it. kidou.PNG Then, the environment has been set and the command prompt will be launched. After that, move to the directory with the source code

python <file name>.py


 It is OK if you execute. (Be careful not to close the command prompt)

 It will be convenient if you set various environment variables and paths, but I will omit it this time.
 Mac
 You can easily build a Mac.
 When you open the downloaded Kivy-1.9.0-rev3-osx.dmg, it will be displayed as shown in the image below.
 <img width="529" alt="スクリーンショット 2015-11-10 12.04.18.png " src="https://qiita-image-store.s3.amazonaws.com/0/98851/22366017-6fb4-c6f0-ba6d-c4c9e495cc29.png ">

 First, let's put Kivy in Applications. Then double-click MakeSymlinks to run it.
 After that, start the terminal and type in the following.
``` $ kivy ```

 If all goes well, Python should start as shown in the image.
 <img width="571" alt="スクリーンショット 2015-11-10 11.50.19.png " src="https://qiita-image-store.s3.amazonaws.com/0/98851/604cb878-14ef-bc6e-3aff-4b8e57ab20e5.png ">
 This completes the environment construction.
 All you have to do is write the source. Execution

#### **` $ kivy <file name>.py `**
```py 

 Just do.


 Linux(Ubuntu)
 How to build an environment on Ubuntu. This time, we will not use an environment such as virtualenv.
 First, run the following command

#### **`kivy-team/kivy`**
``` $ sudo add-apt-repository ppa


 For Python2, use the following command
```$ sudo apt-get install python-kivy```

 For Python3, use the following command
```$ sudo apt-get install python3-kivy```

 I haven't tried this, so I don't know, but I think the command can be executed with `` `$ kivy``` or ``` $ python```.

# Try to display Hello World
## First of all, normally

#### **`main.py`**
```py

import kivy
kivy.require('1.9.0')

from kivy.app import App
from kivy.uix.label import Label

class HelloApp(App):
    
    def build(self):
        return Label(text='Hello World')

if __name__ == '__main__':
    HelloApp().run()

Using the Kv language

Let's display Hello World using the Kv language, which is also a feature of Kivy. Think of the Kv language as something like CSS.

main.py


import kivy
kivy.require('1.9.0')

from kivy.app import App
from kivy.uix.label import Label

class HelloApp(App):
    
    def build(self):
        return Label()

if __name__ == '__main__':
    HelloApp().run()

The file name that describes the Kv language should be `hello.kv```. This must be a promise before the App in the class name of ``` class HelloApp (App):` `. MainApp (App): If it is , name it `main.kv```.

hello.kv


#:kivy 1.9.0

<Label>:
	text: 'Hello World'

Execution result (slightly increased font size) hello_world.PNG

This is how to display from environment construction to Hello World. Please feel free to comment if you say "I'm wrong".

Kivy study sessions are also held regularly, so if you are interested ... http://pyky.connpass.com/

Recommended Posts

From Kivy environment construction to displaying Hello World
From Ubuntu 20.04 introduction to environment construction
From setting up a Rust environment to running Hello World
Flask tutorial (from installation to hello world)
From building a Python environment for inexperienced people to Hello world
First python ① Environment construction with pythonbrew & Hello World !!
From 0 to Django development environment construction to basic operation
From Python environment construction to virtual environment construction with anaconda
From Kafka to KSQL --Easy environment construction with docker
RaspberryPi3 (STRETCH) setup from OS installation to Hello World
Python development environment construction 2020 [From Python installation to poetry introduction]
Procedure to exe python file from Ubunts environment construction
From environment construction to deployment for flask + Heroku with Docker
RabbitMQ Tutorial (1) -From Installation to Hello World (Official Site Translation)
Introduction to TensorFlow --Hello World Edition
Introduction to Ansible Part 1'Hello World !!'
Deep learning tutorial from environment construction
From PyCUDA environment construction to GPGPU programming on Mac (MacOS 10.12 Sierra)
[Google App Engine] Flow from development environment construction to application creation
[Python] Web application from 0! Hands-on (2) -Hello World-
How to build Hello, World on #Nix
[Python] Road to snake charmer (1) Environment construction
C language to see and remember Part 1 Call C language from Python (hello world)
Try to prepare each environment of kivy
Re: Heroku life begin with Flask from zero - Environment and Hello world -
Hello world
[Windows 10] "Deep Learning from scratch" environment construction
How to display Hello world in python
Collecting information from Twitter with Python (Environment construction)
Hello World with gRPC / go in Docker environment
Python explosive environment construction starting from zero (Mac)
Say hello to the world with Python with IntelliJ
Problems connecting to MySQL from Docker environment (Debian)
To myself as a Django beginner (3)-Hello world! ---
Django environment construction
DeepIE3D environment construction
Emacs-based environment construction
Linux environment construction
Python environment construction
Pymacs hello world
Environment construction (python)
Sum from 1 to 10
django environment construction
CodeIgniter environment construction
python environment construction
Python --Environment construction
Python environment construction
Golang environment construction
python environment construction
cython hello world
Word2vec environment construction
From setting up Raspberry Pi to installing Python environment
Steps from installing Django to displaying an html page
Study from the beginning of Python Hour1: Hello World
Environment construction with anyenv + pyenv (migrate from pyenv only (Mac))
[Introduction to RasPi4] Environment construction; OpenCV / Tensorflow, Japanese input ♪
Let's add it to the environment variable from the command ~
Procedure from environment construction to operation test of testinfra, a server environment test tool made by Python