Book Image

Getting Started with Python and Raspberry Pi (Redirected from Learning Python By Developing Raspberry Pi Applications)

By : Nixon
Book Image

Getting Started with Python and Raspberry Pi (Redirected from Learning Python By Developing Raspberry Pi Applications)

By: Nixon

Overview of this book

The Raspberry Pi is one of the smallest and most affordable single board computers that has taken over the world of hobby electronics and programming, and the Python programming language makes this the perfect platform to start coding with. The book will start with a brief introduction to Raspberry Pi and Python. We will direct you to the official documentation that helps you set up your Raspberry Pi with the necessary equipment such as the monitor, keyboard, mouse, power supply, and so on. It will then dive right into the basics of Python programming. Later, it will focus on other Python tasks, for instance, interfacing with hardware, GUI programming, and more. Once you get well versed with the basic programming, the book will then teach you to develop Python/Raspberry Pi applications. By the end of this book, you will be able to develop Raspberry Pi applications with Python and will have good understanding of Python programming for Raspberry Pi.
Table of Contents (13 chapters)
12
Index

Launching the UI

To launch the UI, we will add a simple function to the __init__.py file in the gui module:

import sys
from PyQt4.QtGui import QApplication
from UnitConverter import UnitConverter

The run_gui function is used to create a new Qt application and start a new instance of the unit converter user interface. This is the function that will be called by the launch command that we set in the package in the next section.

def run_gui():
    app = QApplication(sys.argv)
    ui_window = UnitConverter(None)
    ui_window.show()
    app.exec_()