Python知識分享網(wǎng) - 專業(yè)的Python學(xué)習(xí)網(wǎng)站 學(xué)Python,上Python222
tkinter-gui-programming-example PDF 下載
匿名網(wǎng)友發(fā)布于:2024-08-17 08:40:21
(侵權(quán)舉報)
(假如點擊沒反應(yīng),多刷新兩次就OK!)

tkinter-gui-programming-example PDF 下載 圖1

 

 

資料內(nèi)容:

 

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.