Dans ce tutoriel vidéo, nous allons voir comment créer un éditeur de texte en Python avec la bibliothèque tkinter. Nous commençons par la création de l'architecture de l'application en Python ou patron de conception. En plus nous allons nous baser cette fois sur la programmation orientée objet POO en Python. Nous utilisons principalement l'objet Text Tkinter comme principal widget. Nous créons un constructeur python ayant comme paramètre le nom de la fenêtre principale tkinter et le nom du widget Text dont le paramètre expand sera mis à True et fill à both pour remplir totalement la fenêtre principale de l'éditeur.
In this video tutorial, we will see how to create a text editor in Python with the tkinter library. We start by creating the architecture of the application in Python or design pattern. In addition we will base this time on OOP object oriented programming in Python. We mainly use the Text Tkinter object as our main widget. We create a python constructor having as parameter the name of the main window tkinter and the name of the Text widget whose expand parameter will be set to True and fill to both to completely fill the main window of the editor. The version of Python used is Python 3 - windows 7 - Python 3 - windows 8 Python 3 - windows 10. For a good viewing of the video, use the Google Chrome browser.
Python - Programmation GUI (Tkinter)
Python fournit diverses options pour développer des interfaces utilisateur graphiques (GUI). Les plus importants sont énumérés ci-dessous.
Tkinter - Tkinter est l'interface Python de la boîte à outils Tk GUI livrée avec Python. Nous examinerions cette option dans ce chapitre.
wxPython - Il s'agit d'une interface Python open source pour wxWindows http://wxpython.org.
JPython - JPython est un port Python pour Java qui donne aux scripts Python un accès transparent aux bibliothèques de classes Java sur la machine locale http://www.jython.org.
Il existe de nombreuses autres interfaces disponibles, que vous pouvez trouver sur le net.
Programmation Tkinter
Tkinter est la bibliothèque GUI standard pour Python. Python lorsqu'il est combiné avec Tkinter fournit un moyen rapide et facile de créer des applications GUI. Tkinter fournit une puissante interface orientée objet à la boîte à outils Tk GUI.
La création d'une application GUI à l'aide de Tkinter est une tâche facile. Tout ce que vous avez à faire est d'effectuer les étapes suivantes -
Importez le module Tkinter.
Créez la fenêtre principale de l'application GUI.
Ajoutez un ou plusieurs des widgets mentionnés ci-dessus à l'application GUI.
Entrez dans la boucle d'événements principale pour prendre des mesures contre chaque événement déclenché par l'utilisateur.
Call Tkinter modules:
Python 2 Python 3
Tkinter -- tkinter
Tix -- tkinter.tix
ttk -- tkinter.ttk
tkMessageBox -- tkinter.messagebox
tkColorChooser --- tkinter.colorchooser
tkFileDialog --- tkinter.filedialog
tkCommonDialog --- tkinter.commondialog
tkSimpleDialog --- tkinter.simpledialog
tkFont --- tkinter.font
Tkdnd --- tkinter.dnd
ScrolledText --- tkinter.scrolledtext