In addition to the built-in modules, Python also has a large number of third-party modules.
Basically, all third-party modules are registered on the Https://pypi.python.org/pypi, and can be installed with PIP as long as the corresponding module name is found.
This chapter describes commonly used third-party modules.
1. PIL
Pil:python Imaging Library, is already the Python platform in fact the image processing standard libraries. The PIL feature is very powerful, but the API is very easy to use.
Since PIL only supported Python 2.7 and was in disrepair, a group of volunteers created a compatible version of PIL based on the name Pillow,https://github.com/python-pillow/pillow, supporting the latest Python 3.x, adding a lot of new features, so we can directly install the use of pillow
Use the PIP3 install Pillow Direct installation.
To learn more about the powerful features of PiL, please refer to the Pillow official documentation:
https://pillow.readthedocs.org/
Summary
PIL provides a powerful function of manipulating images, which can be done with simple code to complete complex image processing.
Reference source
https://github.com/michaelliao/learn-python3/blob/master/samples/packages/pil/use_pil_resize.py
https://github.com/michaelliao/learn-python3/blob/master/samples/packages/pil/use_pil_blur.py
https://github.com/michaelliao/learn-python3/blob/master/samples/packages/pil/use_pil_draw.py
2. virtualenv
Using different Python names (Python2,python2.7,python3, and so on) is a good use of virtualenv and Linux to preserve multiple sets of development environments on a single host.
3. Graphical interface
Python supports third-party libraries for a variety of graphical interfaces, including: TK,WXWIDGETS,QT,GTK and more. The Python-brought library is a tkinter that supports T-look, and GUI programming is possible without having to install any packages.
Tkinter
Let's comb the concept:
The Python code we write will call the built-in Tkinter,tkinter to encapsulate the interface to the TK;
TK is a graphics library that supports multiple operating systems and is developed using TCL language;
TK will invoke the local GUI interface provided by the operating system to complete the final GUI.
So, our code just needs to invoke the interface provided by Tkinter.
#!/usr/env/bin Python3#-*-coding:utf-8-*-#filename:gui_test.py#function: fromTkinterImport*classApplication (Frame):def __init__(Selfself, master=None): Frame.__init__(self, Master) Self.pack () self.createwidgets ()defcreatewidgets (self): Self.hellolabel= Label (self, text='hello,world!') Self.helloLabel.pack () Self.quitbutton= Button (self, text='Quit', command=self.quit) Self.quitButton.pack () app=application ()#Config window ' s titleApp.master.title ('Hello World')#The Master CircleApp.mainloop ()
# error, the bug is missing a _tkinter, should be not installed in the OS what components, yum search TK search out a lot of, do not know which to install, the Internet searched the next said that TK is not good, so I skipped it first.
/usr/local/python-3.5.2/bin/python3.5/opt/workspace/python3/gui_test.py
Traceback (most recent):
File "/opt/workspace/python3/gui_test.py", line 6, <module>
From Tkinter Import *
File "/usr/local/python-3.5.2/lib/python3.5/tkinter/__init__.py", line A, in <module>
Import _tkinter # If This fails your Python is not being configured for Tk
Importerror:no module named ' _tkinter '
Process finished with exit code 1
Mark
Python common third-party modules