Learn Python : https://www.stavros.io/tutorials/python/
A) Installation :
https://www.python.org/downloads/release/python-373/
pip3 install --user pyqt5
sudo apt-get install python3-pyqt5
sudo apt-get install pyqt5-dev-tools
sudo apt-get install qttools5-dev-tools
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
label = Gtk.Label(label="This is a normal label")
B) Pour Android KIVY :
Python sous android : https://python-for-android.readthedocs.io/en/latest/
Installation sous windows :
https://kivy.org/doc/stable/installation/installation-windows.html#install-win-dist
Installation sous Linux :
https://kivy.org/doc/stable/installation/installation-linux.html
Exemple :
python C:\Program Files\Python37\share\kivy-examples\demo\showcase\main.py
http://tableauxmaths.fr/spip/spip.php?rubrique74
https://ressources.labomedia.org/Kivy_Exemples_simples_pour_apprendre
Utilisation de Buildozer :
1°) Renommer le fichier source xxx.py en main.py
2°) tapez buildozer init
3°) éditer le fichier spec
D) IDE :
Utilisez IDLE (sous Windows via le menu démarrer) sous Linux sudo apt-get install idle-python3.xxx
PYCHARM : Ide Windows et Linux
plugins - in the plugins list, rope is called "Refactoring, Rope" and jedi is called "Completions, Jedi". Eric Python IDE : https://eric-ide.python-projects.org/eric-tutorials.html
E) Tuto / apprentissage :
x = 1
if x == 1:
# retrait de quatre espaces
print("x vaut 1.")
C) Framework Python destiné au web : Django
Installation : pip install Django==2.0 puis pip install Django –upgrade
Création du site : django-admin startproject <<nom_du_site>>
Lancement du site : python manage.py runserver (http://127.0.0.1:8000/)
Utilisation json :
pip install simplejson
import simplejson as json
j = json.loads(‘{« one » : « 1 », « two » : « 2 », « three » : « 3 »}’)
print (j[‘two’])
pip install requests
import requests
r = requests.get(url=’https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty’)
print(r.json())
Pour Requests : http://fr.python-requests.org/en/latest/user/quickstart.html#creer-une-requete
https://stackoverflow.com/questions/35120250/python-3-get-and-parse-json-api
Pour connaitre la version installée :
python --version
Pour lire une page web : BeautifulSoup
# import libraries
import urllib.request
from bs4 import BeautifulSoup
# specify the url
quote_page = « http://www.bloomberg.com/quote/SPX:IND »
# query the website and return the html to the variable ‘page’
request = urllib.request.Request(quote_page)
response = urllib.request.urlopen(request)
# parse the html using beautiful soup and store in variable `soup`
soup = BeautifulSoup(response, « html.parser »)
# Take out the <div> of name and get its value
name_box = soup.find(« h1 », attrs={« class »: « name »})
name = name_box.text.strip() # strip() is used to remove starting and trailing
print (name)
# get the index price
price_box = soup.find(« div », attrs={« class »: »price »})
price = price_box.text.strip()
print (price)
http://apprendre-python.com/page-beautifulsoup-html-parser-python-library-xml
https://www.crummy.com/software/BeautifulSoup/bs4/doc/
Pour rendre un ficher python 2.x exécutable sous windows utilisez PyInstaller :
- easy_install -U pip ==> Met à jour l’installateur pip.
- pip install pyinstaller ==> Installe PyInstaller.
Utilisation :
- pyinstaller VotreFichier.py : Création d’un exe et de tous les fichiers nécessaires dans le répertoire « dist »
- pyinstaller -w -F VotreFichier.py : Création d’un exe d’un ficher python « windows » (utilisant Tkinter) en incorporant tous les fichiers nécessaires.
Pour changer l’icône, utilisez RessourceHacker
Pour la version 3.x :
https://anthony-tuininga.github.io/cx_Freeze/
Références :
https://www.supinfo.com/articles/single/5437-distribuer-programme-python-avec-pyinstaller
Références :
http://www.tkdocs.com/tutorial/firstexample.html
http://apprendre-python.com/page-editeurs-python-gratuits-payants-ide