Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Pyside GUI Application Development- Second Edition

You're reading from   Pyside GUI Application Development- Second Edition Develop more dynamic and robust GUI applications using PySide, an open source cross-platform UI framework

Arrow left icon
Product type Paperback
Published in Jan 2016
Publisher Packt
ISBN-13 9781785282454
Length 144 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Venkateshwaran Loganathan Venkateshwaran Loganathan
Author Profile Icon Venkateshwaran Loganathan
Venkateshwaran Loganathan
Gopinath Jaganmohan Gopinath Jaganmohan
Author Profile Icon Gopinath Jaganmohan
Gopinath Jaganmohan
Arrow right icon
View More author details
Toc

Importing PySide objects

Congratulations on setting up Pyside successfully on your system. Now, it's time to do some real work using PySide. We have set up PySide and now we want to use it in our application. To do this, you have to import the PySide modules in your program to access the PySide data and functions. Here, let's learn some basics of importing modules in your Python program.

There are basically two ways that are widely followed when importing modules in Python. The first is to use a direct import <module> statement. This statement will import the module and creates a reference to the module in the current namespace. If you have to refer to entities (functions and data) that are defined in module, you can use module.function. The second is to use from module import*. This statement will import all of the entities that the module provides and set up references in the current namespace to all the public objects defined by that module. In this case, referencing an object within the module will boil down to simply stating its literal name in code.

Therefore, in order to use PySide functions and data in your program, you have to import it by saying either import PySide or from PySide import*. In the former case, if you have to refer to some function from PySide you have to prefix it with PySide, such as PySide.<function_name>. In the latter, you can simply call the function by <function_name>. Also, please note that in the latter statement, * can be replaced by specific functions or objects. The use of * denotes that we are trying to import all the available functions from that module. Throughout this book, I would prefer to use the latter format as I do not have to prefix the module name every time when I have to refer to something inside that module.

You have been reading a chapter from
Pyside GUI Application Development- Second Edition - Second Edition
Published in: Jan 2016
Publisher: Packt
ISBN-13: 9781785282454
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime