官术网_书友最值得收藏!

Chapter 1. GUI Basics – Building an Interface

Kivy emerges as a successor of PyMT (a library for multitouch applications) with a simple but ambitious goal in mind — same code for every commonplace platform: Linux / Windows / Mac OS X / Macosx / Android / iOS (Mathieu Virbel, http://txzone.net/2011/01/kivy-next-pymt-on-android-step-1-done/). This support is being extended to Raspberry Pi thanks to a founding campaign started by Mathieu Virbel, the creator of Kivy. Kivy was introduced in the EuroPython 2011, as a Python framework designed for creating natural user interfaces.

So, let's start creating user interfaces using one of its fun and powerful components, the Kivy language (.kv). The Kivy language helps us to separate the logic from the presentation. This is a fundamental engineering concept that helps to keep an easy and intuitive code. Nonetheless, it is possible to build a Kivy application using pure Python and Kivy as a library. We will also learn those concepts in later chapters because they allow us to modify interfaces dynamically.

This chapter covers all the basics for building a graphical user interface (GUI) in Kivy. Afterwards, you will be able to build practically any GUI you have in your mind, and even make them responsive to the size of window! The following is a list of all the skills that you're about to learn:

  • Launching a Kivy application
  • The Kivy language
  • Creating and using widgets (GUI components)
  • Basic properties and variables of the widgets
  • Fixed, proportional, absolute, and relative coordinates
  • Organizing GUIs through layouts
  • Tips for achieving responsive GUIs

Apart from Python, this chapter requires some knowledge about Object-Oriented Programming (http://en.wikipedia.org/wiki/Object-oriented_programming) concepts. In particular, inheritance (http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming)) and the difference between instances (http://en.wikipedia.org/wiki/Instance_(computer_science)) and classes (http://en.wikipedia.org/wiki/Class_(computer_science)) will be assumed. Before starting, you will need to install Kivy (The instructions can be found in http://kivy.org/docs/installation/installation.html). The book examples were tested on Kivy 1.7.0 but a more recent version should work as well.

At the end of this chapter, we will be able to build a GUI starting from a pencil and paper sketch. We will introduce the main project of the book — the Comic Creator, and implement the main structure of the GUI.

主站蜘蛛池模板: 灌阳县| 苍南县| 文安县| 无极县| 郧西县| 新营市| 沁阳市| 通山县| 盐源县| 尼勒克县| 巴林左旗| 和政县| 涿州市| 九龙县| 丘北县| 施甸县| 菏泽市| 涞水县| 湖北省| 藁城市| 昭平县| 浦东新区| 沿河| 洛宁县| 合作市| 武川县| 曲靖市| 玉林市| 十堰市| 弥勒县| 长汀县| 蒙城县| 亚东县| 呼玛县| 长丰县| 驻马店市| 永福县| 新建县| 郎溪县| 晋江市| 江山市|