Python知识分享网 - 专业的Python学习网站 学Python,上Python222
tkinter-gui-programming-example PDF 下载
发布于:2024-08-17 08:40:21
(假如点击没反应,多刷新两次就OK!)

tkinter-gui-programming-example PDF 下载 图1

 

 

资料内容:

 

Beginning our text editor
Before writing any code, be sure to make a new folder to hold the files for this chapter.
Inside this folder, create a file called textarea.py. This file will hold the main part of our
text editora subclass of the Text widget.
The Text widget is such as a textarea tag within HTML. It holds multiple lines of text
and many formatting options. In the next chapter, we will see just how powerful this
widget can be with the use of concepts like tags and indexing, which alter the text's
appearance and give us control over certain regions of the text, allowing us to search all
over the document within.
For now, we will just need a simple instance of the widget with a couple of configuration
options set:
import tkinter as tk
class TextArea(tk.Text):
def __init__(self, master, **kwargs):
super().__init__(**kwargs)
self.master = master
self.config(wrap=tk.WORD)
Although initially short, this is all we need at the moment for our Text widget subclass.
After initializing the Text widget superclass, we assign the master widget as an attribute
which will allow us to send information back to the main application window in the future.