Copyright 2
Acknowledgments 4
About the Author 5
Contens 6
Intrduction 11
Chapter 1 Python and Its Features 15
1.1 Python 16
1.2 Installing Python 19
1.3 Interacting with Python 24
1.4 Writing Your First Python Program 27
1.5 Data Types in Python 29
1.6 Basic Elements in a Program 31
1.7 Comments 32
1.8 Continuation Lines 33
1.9 Printing 34
Summary 37
Chapter 2 Getting Wet in Python 38
2.1 Performing Arithmetic Operations 39
2.2 Bitwise Operations 49
2.3 Complex Numbers 52
2.4 Making Decisions 54
Table of Contents
2.5 Logical Operators 58
2.6 Chaining Comparison Operators 60
2.7 Loops 63
Summary 73
Chapter 3 Sequences 74
3.1 Sequences 75
3.2 Strings 76
3.3 Lists 90
3.4 Tuples 96
3.5 Sets 100
Summary 103
Chapter 4 Functions and Modules 104
4.1 Functions 105
4.2 Function Attributes 115
4.3 Recursion 117
4.4 Iterators 120
4.5 Modules 124
Summary 129
Chapter 5 Classes 130
5.1 The Class Statement 131
5.2 Class Methods 139
5.3 Static Methods 141
5.4 Garbage Collection 144
5.5 Inheritance 146
5.6 Multilevel Inheritance 153
5.7 Operator Overloading 163
5.8 Descriptors 168
Summary 172
Chapter 6 File Handling 173
6.1 Exception Handling 186
6.2 Raising an Exception 191
Summary 193
Chapter 7 PyQt 194
7.1 Qt Toolkit 196
7.2 PyQt 197
7.3 Installing PyQt 198
7.4 Window and Dialogs 201
7.5 Creating a GUI Application with Code 202
7.6 Using Qt Designer 205
7.7 Understanding Fundamental Widgets 220
7.8 Event Handling in PyQt 223
7.9 First Application in Qt Designer 224
7.10 Using Custom Slots 231
7.11 Converting Data Types 234
7.12 Defining Buddies 237
Summary 242
Chapter 8 Basic Widgets 243
8.1 Using Radio Buttons 244
8.2 Using Checkboxes 249
8.3 Entering Integer and Float Values Using a Spin Box
256
8.4 ScrollBars and Sliders 260
8.5 Working with a List Widget 266
Summary 274
Chapter 9 Advanced Widgets 275
9.1 Displaying System Clock Time in LCD Format 276
9.2 Working with Calendar and Displaying Dates in Different
Formats 280
9.3 Using Combo Box 286
9.4 Displaying a Table 291
9.5 Displaying Web Pages 295
9.6 Displaying Graphics 299
Summary 303
Chapter 10 Menus and Toolbars 304
10.1 Understanding Menus 305
10.2 Creating a Toolbar 312
10.3 Dock Widget 319
10.4 Tab Widget 325
10.5 Converting a Tab Widget 332
Summary 337
Chapter 11 Multiple Documents and Layouts 338
11.1 Multiple-Document Interface 339
11.2 Layouts 347
Summary 355
Chapter 12 Database Handling 356
12.1 Why MySQL? 357
12.2 Creating a Database 361
12.3 Database Maintenance Through Console-Based Programs
365
12.4 Database Maintenance Through GUI Programs 374
Summary 387
Index 38
- Log in to post comments