文件名称:
An Introduction to C & GUI Programming (2019).pdf
开发工具:
文件大小: 9mb
下载次数: 0
上传时间: 2019-10-20
详细说明:The first part of this book is an introduction to programming in C for absolute beginners; the second part shows how to use C to create desktop applications for Raspbian, using the GTK toolkit. You don’t need any programming experience, and a Raspberry Pi running Raspbian is all you need to get startedAN INTRODUCTION TO CAND GUI PROGRAMMING
PRESS
First published in 2019 by Raspberry Pi Trading Ltd, Maurice Wilkes Building
St Johns Innovation Park, Cowley Road, Cambridge, CB4 ODS
Publishing Director: Russell Barnes Editor: Phil King
Author: Simon Long. Design: Critical Media
CEO: Eben Upton
SBN:978-1912047-659
The publisher, and contributors accept no responsibility in respect of any omissions
or errors relating to goods, products or services referred to or advertised in this book
Except where otherwise noted the content of this book is licensed under a Creative
Commons Attribution-Non Commercial-ShareAlike 3.0 Unported
(CC BY-NC-SA 3.0
The gtk logo is copyright The GNOME Foundation and licensed under LGPL v2.1+
AN INTRODUCTION TO C AND GUI PROGRAMMING
AN INTRODUCTION TO CAND GUI PROGRAMMING
Welcome to
An Introduction to c
GUI Programming
he c programming language was invented in the early 1970s, and since then has
become one of the most popular and widely used general-purpose languages. C can
be used to create simple command line programs or embedded code to operate the
tiny microcontrollers in toasters and watches. At the other extreme, it can be used to create
rich graphical desktop applications -in fact, most of Linux(and Raspbian itself) is written
in it. It can give you control over the smallest details of how a processor operates, but is still
simple to learn and read. The first part of this book is an introduction to programming in C for
absolute beginners; the second part shows how to use c to create desktop applications for
Raspbian, using the gTK toolkit. You dont need any programming experience, and a Raspberry
Pi running raspbian is all you need to get started
About the author
non Long is an engineer working
for Raspberry Pi. He is responsible
for the Raspberry Pi Desktop and its
associated applications. Before joining
Raspberry Pi, he worked for Broadcom
where he first met Eben Upton and before
that spent ten years working as a software
engineer and user interface designer for
a major consultancy firm. In his spare
time, he enjoys solving those really hard
crosswords without any black squares
AN INTRODUCTION TO C AND GUI PROGRAMMING
AN INTRODUCTION TO CAND GUI PROGRAMMING
Contents
Chapter 1: Getting started
010
Learn how to use c to program the Raspberry Pi
Chapter 2: Variables and arithmetic
014
Create variables and do maths
Chapter 3: Conditions and comparisons
019
Control the flow of your C programs
Chapter 4: More advanced flow control
024
For loops and case statements
Chapter 5: Pointers
030
Variables have addresses too
Chapter 6: Functions
035
Split your code into bite-sized chunks
Chapter 7: Arrays and strings
041
Handle lists of values and letters
Chapter 8: The string library
046
Simplify common operations on strings
Chapter 9: User Input
052
Reading and interpreting user input
Chapter 10: File input and output
058
Learn to read from and write to files
Chapter 11: More about types and variables
063
Type definitions, enumerations, and more
Chapter 12: Header files and the preprocessor
068
Splitting code up into multiple files
Chapter 13: Introduction to GTK
074
Get ready to start creating GUls
Chapter 14: Your first GTK program
077
Start coding in C with the GTK library
Chapter 15: Buttons
081
Make your window more interesting by adding a button
Chapter 16: Labels and layout
085
Use a box widget to add a text label to your window
Chapter 17: More advanced layout
091
Expand your window, and position and resize buttons automatically
Chapter 18: GUI user input
097
Enable users to enter text and select options
Chapter 19: Combo boxes and list stores
103
Create combo boxes for user input and associate list stores with them
Chapter 20: Tree views
109
Use the gtk tree view widget to display information
Chapter 21: Menus
115
Create menu bars with drop-down menus
Chapter 22: Dialogs
120
Give users information and ask them questions
AN INTRODUCTION TO C AND GUI PROGRAMMING
AN INTRODUCTION TO CAND GUI PROGRAMMING
Chapter 23: Built-in dialogs
123
GTK contains some ready-made dialogs
Chapter 24: Customising widgets
131
Change the properties of widgets
Chapter 25: Glade
135
Create window layouts for applications
Chapter 26: C quick reference
144
Cheat sheets and code examples
Chapter 1
Getting started
C is one of the most widely used programming languages
learn how to use it to program the Raspberry Pi!
What's so great about C?
C is a very versatile and widely used programming language. It has been used to write
pretty much everything, from low-level routines to control the hardware in embedded
microcontrollers to complete operating systems like linux with graphical user interfaces. In
spite of this huge flexibility, it is also relatively simple- the language only has about 20 or so
keywords, but there are huge libraries of additional functions that you can call on when you
need them In the first part of this book, we are going to concentrate on learning about the
keywords, with a few of the more commonly used library functions; the second part of the
book shows how to use the gtK library to make it easy to write graphical interfaces in C
Many of the languages that you may have seen, such as Python, are what are called
interpreted languages. This means that the code you write is run directly: each line of code is
ead in and interpreted as you run it c is different it's a compiled language this means that
the code you write, known as the source code, is never run directly. The source code is passed
through a program called a compiler, which converts it into a machine-readable version called
an executable or a binary; you then run the resulting executable
This may seem complex, but it has a few big advantages. First, it means that you don' t need
have a copy of c itself on every computer you want to run your program on; once compiled,
the executable is standalone and self-contained. Second, the compilation process will find
a lot of errors before you even run the program but it won t usually find all of them).Most
mportantly, the compilation process means that the time-consuming translation of human
readable code into machine-readable instructions has already happened which means that
compiled code generally runs many times faster than interpreted code would
CHOOSE YOUR EDITOR
You can use whatever editor you like to enter code, as long as it saves it as plain text. The
Geany editor included in Raspbian is a good choice, but you can also use Leafpad, nano, or
any others that you prefer
10
AN INTRODUCTION TO C AND GUI PROGRAMMING
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.