- 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.
- Mastering NetBeans
- INSTANT Sencha Touch
- Python機器學習算法與實戰
- Learning Apache Mahout Classification
- 自然語言處理Python進階
- Python時間序列預測
- Learning Probabilistic Graphical Models in R
- R語言與網絡輿情處理
- Go語言編程
- JavaScript悟道
- Mastering Embedded Linux Programming
- Applied Deep Learning with Python
- Java Web開發教程:基于Struts2+Hibernate+Spring
- Mastering XenApp?
- 美麗洞察力:從化妝品行業看顧客需求洞察