7

Click here to load reader

From 0 to mine sweeper in pyside

Embed Size (px)

DESCRIPTION

These were the slides used in my talk at conf.kde.in 2011.

Citation preview

Page 1: From 0 to mine sweeper in pyside

Python.__init__(Qt)

Dinesh

Page 2: From 0 to mine sweeper in pyside

Why ANOTHER Language?

● Whats there in a language?- a few keywords and a little bit of grammar

● Then why NOT C/C++ ?�- developing in Python is way faster!- lot less hassle ?- you wouldn't want to use a canon to kill a mosquito ;)

● Even then, why Python!?- Easy , Extensible, Everywhere!

Page 3: From 0 to mine sweeper in pyside

So what IS Python?

● Interpreted Language :) (no more autotools, awk , cmake , qmake madness!)- But its an INTERPRETED Language!! :S

● Dynamically typed language. (no more int, char, float, etc.. ?!)

● Its Mixable. (You dont really have to build a class to print hello world)

● Indentation (and HENCE, the Beauty of your code!) Counts!

● Try using " help() " whenever needed...

Page 4: From 0 to mine sweeper in pyside

Python's keywords

and del �from not �while

as elif �global or with

assert �else �if �pass yield

break except �import �print �class

�exec �in �raise �continue �finally

�is �return �def for �lambda

�try

Page 5: From 0 to mine sweeper in pyside

Python's Core DatatypesObject type Example

Numbers 1234, 4, 999L , 3+ 4j , ..

Strings " Hello" , 'There' , ''' :) '''

Lists [1 , [2 , "Three"], 4]

Dictionaries {"Food" : 1 , :"Tastes" : "Good":}

Tuples (1 , "Is" , 'one' )

Files myfile = open ("door", 'r' )

Other types Sets , Types, None , Booleans

Page 6: From 0 to mine sweeper in pyside

OperatorsUnary + - ~

**

* / %

+ -

>> <<

&

^

|

< <= == >= > != <> is

not

and

or

Arithmetic , Boolean , Relational and Bitwise operators are all left to right associated

On the other hand, the assignment operator is right associated

9 / 3 * 3 = 9

*when confused, simply use parenthesis :)

Page 7: From 0 to mine sweeper in pyside

Hello Qt

from PySide.QtGui import *import sys

#Create a new application for me to work onmyApplication = QApplication ( sys.argv )

#A new push button with a Label!hello = QPushButton ( " Hi There " )

#Show the button!!hello.show()

#run my applicationmyApplicatioin.exec_()