Mainly for the (cross-platform) Python GUI frontend options.
- CEF (Chromium Embedded Framework). Pro: can use the same way of MVC thinking (modern html5); build-in chromium browser. Con: someone said it may need a little c++.
- PyQt (v5). Pro: big community, good doc (for c++). Con: c++ way of thinking, just the language is py (the official GUI tutorial lacks GUI screenshots!); pay for commercial usage; still often needs c++.
- Tkinter. Pro: build-in w/ py, big community. Con: //TODO.
- electron / nwjs (bad word of mouth) /javafx / swiftui / flutter : Pro: quick to develop. Con: using node.js, too slow to run and to learn. // though it is possible for experts to make VSCode using electron.
- wxPython: Pro: small-to-middle-size community… Con: too new, few people.
ref: zhihu & youtube
...
As the pyhon-docx
does not want to provide a documentation (except some APIs) and the API doc web is really hard to browse and read, here are some small tips/demo tutorials to remember/avoid pits and falls.
Please note:
- lib (0.8) provides only basic functions mainly for adding something (seems to be for test purpose). The main actions we do in a docx file should be done using MS API via this lib.
- copy.deepcopy(.) should be used within the lib, not applying on MS objects.
Two methods of downloading & converting pictures/images to a combined pdf file with parallel (multi-thread) from Mark Needham.
f.write(img2pdf.convert(…)) [ref MarkHNeedham]
from PIL import Image [ref DataToFish]
Note: fpdf is not suggested as it canNOT support jpg natively. [ref stackoverflow]
Books & Docs
#
- Seaborn tutorial & gallary
- OReilly 2017 - [easy to find common examples] Python Data Science Handbook
- Packt 2015 - [nice code grammar] Python Data Visualization Cookbook, 2nd Ed. (Igor Milovanovic)
- Packt 2015 - [rich & various content] Mastering Python Data Visualization
- Packt 2015 - [advanced nice plots & deployments] Mastering matplotlib (D.M. McGreggor)
- [Very bad composition] Packt 2018 - Matplotlib for Python Developers - 2nd Ed (by Allen Yu, Claire Chung)
Overview of Libs
#
Python Data Visualisation Landscape
...
See also:
Pandas
#
Get column_nr in pandas/numpy.
if isinstance(X, pd.DataFrame):
X_is_df = True
row_nr = X.shape[0]
column_nr = X.shape[1]
if isinstance(X.columns, pd.core.index.MultiIndex):
df_columns_is_multi_index = True
else:
df_columns_is_multi_index = False
else: # non-DF
X_is_df = False
row_nr = np.shape(X)[0]
column_nr = np.shape(X)[1]
use dataframe directly against spark
#
lib Optimus
from optimus import Optimus
op = Optimus(master="local")
df = op.create.df(<some data>)
...
Sourcing/Importing
#
execfile or os.system
#
execute the other python file in place:
...
execfile or os.system
#
execute the other python file in place:
execfile("/path/to/my/lib/mylib.py")
or:
import os
os.system("python /path/to/my/lib/mylib.py")
import
#
import sys
import os
sys.path.append(os.path.abspath("/path/to/my/lib"))
import mylib
ref
#
See other methods here.
A great 5-video tutorial: 35minutes on YouTube (6 tomatoes / 2.5 hours for non-stop studing by coding).
Author’s Github (py2), My Github (py3).
Differences in my Github code:
- py3, not py2
- using
on_put()
to test validity of input json from client
using on_delete()
to test params (just to test, should NOT be used in real-world)
- using another route
/test2?x=1&y=3
to test params
Usage in Nix:
pip3 install falcon gunicorn
gunicorn app:api # in the folder of app.py
Usage in Win (tested in bash sub system):
...
Related:
PRE-INSTALL: CONDA VS. PIP
#
Pip requires apt. Thus, pip+apt. Pip chose to live together with apt (or other package manager) as apt is better at managing packages, especially when related to system. Some pip packages requires system (apt) to cooperate, such as uwsgi, graphviz, ffmpeg, gcc, python3-dev.
...
(updated 2021.1)
Related:
Learn Python
Ref: This is a combined learning note of:
Update: newly tested w/ Ubuntu 1804 + py 3.8.5 + django 3.1.
...
INSTALL
#
Anaconda Way
#
This is suggested for very new users to use a stable environment.
It is NOT suitable for normal users / experienced programmers / engineers.
for windows
#
Download Python 3 from Anaconda and install.
From Windows “Start” menu, run “Jupyter” directly. (at least since v5.3.1)
Old versions needs to run from navigator as below:
anaconda for linux
#
Similar to win, for details, see here.
...