Saturday, 5 November 2016

Hello friends, I am back with my next tutorial on the python Gui programming with the PyQt kit.
So,hope you prepare your environment for the programming, If not so read my last post on how to setup your environment for the PyQt development.
So, let's start developing our first Gui app.
Que:- So,What Gui is?
Ans:- The Term GUI stands for the Graphical User Interface. When we want to talk about our hardware we have basically two methods one is command line interface and the another is Graphical Interface, The Graphical Interface is the user interface through which a user interact with the amazing piece of hardware with graphical icons, visual indicators etc.

A PyQt Gui app have mainly five types of window
1) Dialog with Button at bottom
2)Dialog with Buttons at right
3) Dialog without Buttons
4)Main windows
5)Widget

In an GUI application dialogs play an important role they can be make announcements in the application like user asked to close the window or error occured and a lot more. In my imagination an application without the dialog is impossible to construct.
Dialogs are mainly of two types: - 1) Modal Dialog               2) Modeless Dialog

1) Modal Dialog:- A modal dialog is one which upon invoked takes all the control of the application. It means it is the only one through which the user can interact,when it is on the screen the whole application becomes dumb to the user. The user can interact to the application only after closing the window.

2)Modaless Dialog:- The other type of the dialog is modaless dialog. When this type of dialogs are invoked a user can interact the dialog as well as the whole application. There is no restriction to the user. This type of dialogs are used mainly to update the main window gui.

Let us understand the Modal dialog by implementing its code. So, here is the outline of what our application going to do, suppose we want to build an app in which we have all the records of our company employee and only a trusted people can see those records. In such case we want to implement an login mechanism first. If user successfully logged into the application only till it will see the list of employee otherwise it have to close the application. To build such application we think to implement the dialog window first and then show our main window only if we get the successfull login.

Now let us start the fun part by coding our application dialog.

To make the process easier I commented the whole code. Don't worry if you don't understand the code we will go through it line by line in the future tutorials.



Copy and paste the code to your file save it with the extension filename.pyw on windows.Double click on it to run the file.

Here is the output of the code:-

Don't worry we will come to the code bit by bit in the next tutorial.
Till then Happy Programming.
Have a great weekend.

Tuesday, 1 November 2016

Hello friends, first I want to say sorry to all of you for my absence till such a long time. I hardly come online in this period because of my personal issues. But now its all set so here we again.
Today I want to discuss a common problem arising for the people when they want to learn gui programming. So, I am thinking to start a gui programming tutorial series.
The first question comes in mind when we start to learn the gui programming is which language suits me best. The answer definitely depends upon your choice and command on the language. But in this tutorial series what I am following is Python. Because its really a simple language to start the fun part of the programming.
In this 1st part of our series adventure. I am going to tell you how to setup the environment for the programming.

Prelim for the tutorial series:-
1) A Basic knowledge of Python.
2) A Basic knowledge of class (Object Oriented) in Python.
3) A Trust in me. :) As all the three prelim are important for the series, but still the last one is mandatory. :D (Just Kidding :D )

Installing Python and PyQt on Windows:-
1) Go to the Python official site and download the python 2.7 package. It is the one which we follows in all our series. The link for the python official site is given below:-
 https://www.python.org/download/releases/2.7/
2) After installing the Python on the system update the Path variable of the window with Python interpreter location.
Note down the path shown above to update the path variable on Windows.

3) Now comes the other part download the PyQt package for the python. There are two main package available for the Python one is PyQt4 and other is PyQt5. PyQt4 is which we used in our complete series. Be aware when downloading the packages. Because these are for the Python 2.7 and Python 3 .Please download those which are compatible with the Python 2.7.
 A link of the official website is given below:-
https://www.riverbankcomputing.com/software/pyqt/download
                                               Or
You can use python pip command to install the PyQt4
4) After Downloading the package double click on it choose the right path (where python installed mine is shown in the pic below) to install the PyQt otherwise python interpreter will not find it.


5)After installing it open the python interpreter and run the following command:-
 from PyQt4 import *

If it is success means not showing any error then we successfully install python and PyQt4 on the system. You can see no error in the pic above. Congratulations You completed the first step of your journey. And now You have a road in front of you ahead.... In the next part of our series we are going to learn some basics of Gui and develop our first Gui application.
Bye Bye till the next part.
Happy programming..