- Tkinter GUI Application Development Blueprints(Second Edition)
- Bhaskar Chaudhary
- 197字
- 2021-06-24 18:35:09
Tags
Tags are used to annotate text with an identification string that can then be used to manipulate the tagged text. Tkinter has a built-in tag called SEL, which is automatically applied to the selected text. In addition to SEL, you can define your own tags. A text range can be associated with multiple tags, and the same tag can be used for many different text ranges.
Here are some examples of tagging:
my_text.tag_add('sel', '1.0', 'end') # add SEL tag from start(1.0) to end
my_text.tag_add('danger', "insert linestart", "insert lineend+1c")
my_text.tag_remove('danger', 1.0, "end")
my_text.tag_config('danger', background=red)
my_text.tag_config('outdated', overstrike=1)
You can specify the visual style for a given tag with tag_config, using options such as background (color), bgstipple (bitmap), borderwidth (distance), fgstipple (bitmap), font (font), foreground (color), justify (constant), lmargin1 (distance), lmargin2 (distance), offset (distance), overstrike
(flag), relief (constant), rmargin (distance), spacing1 (distance), tabs (string), underline (flag), and wrap (constant).
For a complete reference about text indexing and tagging, type the following command into the Python interactive shell:
>>> import Tkinter
>>> help(Tkinter.Text)
Equipped with a basic understanding of indexing and tagging, let's implement some more features in the code editor.
- Functional Python Programming
- DBA攻堅指南:左手Oracle,右手MySQL
- 數(shù)據(jù)庫程序員面試筆試真題與解析
- Spring Cloud Alibaba微服務(wù)架構(gòu)設(shè)計與開發(fā)實戰(zhàn)
- R語言數(shù)據(jù)可視化之美:專業(yè)圖表繪制指南
- 深入淺出WPF
- Visual Basic程序設(shè)計教程
- 深入理解Java7:核心技術(shù)與最佳實踐
- Learning ArcGIS Pro
- FFmpeg入門詳解:音視頻原理及應(yīng)用
- Android系統(tǒng)原理及開發(fā)要點詳解
- Getting Started with LLVM Core Libraries
- Emgu CV Essentials
- RESTful Web Clients:基于超媒體的可復(fù)用客戶端
- 玩轉(zhuǎn).NET Micro Framework移植:基于STM32F10x處理器