Note: Any reasonably recent version of Python is acceptable for this
course. If you have a version of Python 3.x on your computer already you should
be able to use it for this class.
Please download and install Python 3.x from:
http://www.python.org/download/
As you install Python, make sure to check the "Add Python 3.5 to PATH" so
that you can type
python at the command line prompt to run Python.
Installing the Atom Text Editor
Please download and install Atom from this site:
http://atom.io
111
2- How run Your Python Program in the Command Prompt
it is available to run any files that end with a ".py" suffix(Python file)
at the command line prompt.
2.1- Windows Command Line Prompt Notes
When the command line starts
up,
you are in your "home" directory. Your home directory is different for each of
the operating systems. In each of these examples, your logged in account
should be used instead of csev.
Windows XP: C:\Documents and Settings\csev
Windows Vista: C:\Users\csev
Windows 7: C:\Users\csev
Windows 10: C:\Users\csev
Windows 10 OneDrive: C:\Users\csev\OneDrive
The command line prompt usually includes some clue as to where you are in the
folder structure on your hard drive.
If you want to really figure out where you are, use the cd command with no
parameters
C:\Users\csev> cd
C:\Users\csev
Where can you go?
Generally the first thing you want to do when you open a command line
interface is to navigate to the right folder. Say you wanted to run a file
from your desktop. The command is
cd Desktop (or
cd
OneDrive\Desktop) to get into the folder that is your Desktop. You can
use the
dir command to see which files are in the current directory and
the
cd .. command to go "
up"
a directory
Nifty Trick: On the cd command, you can partially type a folder name
like Desktop and then press the TAB key and the system will auto-complete the
folder name if you have typed enough that the system can accurately guess what
you mean to type.
If you get Lost...
If you can't figure out what folder you are in and/or cannot figure out how
to get to the folder you want to get to - simply close and re-open the Command
Line / Terminal window. You will be back to your "home" directory - so you can
start from a known location.
Some Cool Hints on the Windows Command Line Interface
If you click on the little icon in the upper-left of the command prompt
window and select Preferences - you can set many things about the command line
- probably the most important is to set the Command History Buffer Size to be
999.
2.2- Running Your Python Program in the Command Line
To run your program in the command line you type at the command line prompt.
Windows knows that files that end with a ".py" suffix are Python programs.
python firstprog.py
or
firstprog.py
Where firstprog.py is the name of the file
containing your Python program. Make sure to use the cd command to be in the
correct directory that contains your program file(s).
You can run your program over and over again in the command window. Hint:
You can use the
up-arrow key to
scroll back through previous commands and re-execute them by pressing enter.
This allows you to quickly edit and rerun your program to make and test
changes.
Example:
-
- firstprog.py - python file
- firstprog.py stored at folder
C:\Users\csev\prog\pypr
- how to run firstprog at command line prompt
- run command line prompt
Command Prompt |
Micosoft windows ...
C:\Users\csev> cd\
- type cd\
display: C:\>
C:\> chdir C:\Users\csev\prog\pypr
- type chdir C:\Users\csev\prog\pypr
display: chdir C:\Users\csev\prog\pypr>
C:\Users\csev\prog\pypr> python firstprog.py - type
python firstprog.py
if firstprog no error, display the output resultat
.......... -
display the first line of he output resultat
.......... -
display the second line of he output resultat
.......... -
display the 3th line of he output resultat
|
- finish
|
|
3-Notes:
3.1- Python Desktop
Application - Best Python framework for building a desktop application
and GU |
|
|
Python has been the most trending programming
language used for object oriented progamming. With python you
can run simple statement over and over again without having to
compile a whole program of which it's output functionality is
superb.
Of course, Python is an interactive programming which has a
diverse range of options for GUI (Graphical User Interface)
framework (help developers create GUI applications in an easy
and secure manner). This article discusses the Best Python
framework for building a desktop application and GUI.
NB: It is essential that you have a basic knowledge of Python
programming language before you can use these python frameworks.
Let's delve it to the discus |
|
- PyQT
PyQt is a Graphical User Interface widget toolkit. It is one of the
most powerful and popular Python interfaces. It is a combination of
the Qt (owned by Nokia) library and Python programming language
which leaves a developer to decide whether to create a program by
coding or create visual dialogs using Qt Designer.
PyQt is a free Python bindings software open-source widget-toolkit
Qt, implemented for cross-platform application development
framework. In the free version, certain features may not be
available but if your application is open source then you can use it
under a free license.
PyQt is available on Windows, MacOSX, Linux, Android iOS and
Raspberry Pi and different python versions ranging from v2 to Qt v5.
- Tkinter
Tkinter is the most popular programming package for graphical user
interface or desktop apps. It is so named because of its simplicity.
Tkinter is the combination of Tk and Python's standard GUI
framework.
TKinter comes with an abundance of resources of codes and reference
books which is the major merit of choosing it as a package. It
provides diverse widgets, such as labels, buttons, and text boxes
used in a graphical user interface application. The Button control
also called widgets are used to display buttons in developed
application while the Canvas widget is used to draw shapes (lines,
ovals, polygon...) in your application.
tkinter is easy to get help when you come across a hurdle in the
course of developing your application since Tkinter has thousands of
users because it has been in use for a very long time. Tkinter is an
open source and it is available under the Python License.
- Kivy
Kivy as an OpenGL ES 2 accelerated framework for the creation of
new user interfaces empowers you with the ease to write your code
once and have it run on different platforms or Operating Systems
(Windows, MacOSX, Linux, Android iOS and Raspberry Pi).
Kivy apps creation is fun, easy and rewarding because it is free and
is an open source Python library for creating application software
with an enabled natural user interface . Kivy comes twenty widgets
in its toolkit.
- WxPython
WxPython is a python extension module. It is also an open source
wrapper for cross-platform graphical user interface library Widget.
As a developer, you can develop traditional applications for
Windows, Unix and Mac OS.
- PyGUI
PyGUI is the simplest and most lightweight of all GUIs because it is
purely in sync with Python programming language. It is a
cross-platform graphical application framework for Windows, Mac OS,
and Unix.
A PyGUI developer inserts very less code between the GUI platform
and Python application which in turn displays the natural GUI of the
platform.
|
Summary
The above listed are the most widely used and best Python graphical
user interface frameworks available. It's up to the developer to
choose the Python GUI framework that best suits him/her. |
|
|
|
|
|
3.2- Python PIP |
|
|
What is PIP?
PIP is a package manager for Python packages, or modules if you
like.
Note:
If you have Python version 3.4 or later, PIP is included by
default. |
|
pip
is a package manager for Python. That means it’s a tool that
allows you to install and manage additional libraries and dependencies that
are not distributed as part of the standard library. |
|
Example: |
- Need to
connect Python to MS Access database using pyodbc?
- To start, install
the pyodbc package that will be used to connect Python with
Access. You can use the PIP install method to install the
pyodbc package
- Using Command
Prompt(Admin) to install ..., Look Pic1
Pic 2 |
|
|
|
|
|