- Tkinter GUI Application Development Blueprints
- Bhaskar Chaudhary
- 379字
- 2021-07-30 10:10:38
Setting up the editor skeleton
Our first goal is to implement the broad visual elements of the text editor. As programmers, we have all used text editors to edit code. We are mostly aware of the common GUI elements of a text editor. So, without much of an introduction, let's get started.
The first phase implements the Menu, Menubutton, Label, Button, Text and Scrollbar widgets. Although we'll cover all of these in detail, you might find it helpful to look at the widget-specific options in the documentation of Tkinter maintained by its author Frederick Lundh at http://effbot.org/tkinterbook/. You can also use the interactive shell, as discussed in Chapter 1, Meet Tkinter.
You might also want to bookmark the official documentation page of Tcl/Tk at http://www.tcl.tk/man/tcl8.6/TkCmd/contents.htm. This site includes the original Tcl/Tk reference. While it does not relate to Python, it provides a detailed overview of each widget and is a useful reference. Remember that Tkinter is just a wrapper around Tk.
In this iteration, we will complete the implementation of broader visual elements of the editor.
We will use the pack()
geometry manager to place all the widgets. We have chosen the pack
manager because it is ideally suited for the placing of widgets side by side or in a top-down position. Fortunately, in a text editor, we have all the widgets placed either side-by-side or in top-down locations. Thus, it is beneficial to use the pack
manager. We can do the same thing with the grid
manager as well.
Note
A note on code styling
One of the key insights of the Python community is that code is read much more often than it is written. Following good naming conventions and consistency in code styling are keys to maintaining readable and scalable programs.
We will try to stick to the official Python styling guide, which is specified in the PEP8 documentation at https://www.python.org/dev/peps/pep-0008.
Some important styling conventions that we will stick to include the following:
- Use 4 spaces per indentation level
- The variable and function names will be lowercase, with words separated by underscores
- The class names will use the CapWords convention
Lets start by adding the Toplevel window by using the following code:
from tkinter import *
root = Tk()
# all our code goes here
root.mainloop()
- OpenDaylight Cookbook
- Getting started with Google Guava
- 劍指MySQL:架構、調優與運維
- Visual Foxpro 9.0數據庫程序設計教程
- 移動互聯網軟件開發實驗指導
- Machine Learning With Go
- Visual FoxPro 6.0程序設計
- DB2SQL性能調優秘笈
- 征服C指針(第2版)
- Android開發權威指南(第二版)
- Python 3.6從入門到精通(視頻教學版)
- C語言從入門到精通(微視頻精編版)
- JavaScript程序設計基礎教程(慕課版)
- Kotlin入門與實戰
- Python High Performance(Second Edition)