Make GUI desktop applications python

This post will describe how to make GUI desktop applications.
1. Go to http://qt-project.org/downloads
2.Download latest QtCreator version compatible with your operating system.


3.Install Qtcreator 
4.Run the Designer inside qt package

6. select window


7.Drag and drop widgets 



8.qtCreator provides facility to make interactions between widgets through signal mode. Click the signal mode icon.


9.Select the button and draw a line from button to text field. It means you're creating interaction between the button and text field. It is like if this happen to button then what happen to text field.
In the figure below left side is actions of the button and actions of text field in right side. I selected click() for button and clear() for text field. It means I made an interaction when button clicks text field will be clear.


10. After setting interactions save the project in a appropriate location. Save it as .ui file. I saved it as firsthello.ui 


12. Run the saved .ui file (ctrl+r). Then the window will appear. Check the interactions you made. I typed something in the text field and pressed the button. Text field is cleared. 


Convert the GUI to python 
13. Now we have a working GUI built with Qtdesigner. To convert this to python code, we need additional software. called pyqt. Go to http://www.riverbankcomputing.com/software/pyqt/download and download appropriate version for your python version. 


14. Install pyqt. 
15. Open command prompt. go to the folder your GUI saved. Type following commands.

My pyqt version is pyqt4. I saved my GUI as firsthello.ui in Desktop/pycodes. So I go to that folder and type above command to convert firsthello.ui into hello.py. 

16. Open your python IDE and open hello.py.




17. hello.py will be open.


18. Run the python code


19. Now you have a working GUI made with python. Check whether the interactions are working. :)


more about python GUI programming will be posted soon 














 

No comments:

Post a Comment