- 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.
- 深入核心的敏捷開發(fā):ThoughtWorks五大關(guān)鍵實踐
- DevOps for Networking
- C#完全自學(xué)教程
- JIRA 7 Administration Cookbook(Second Edition)
- Arduino開發(fā)實戰(zhàn)指南:LabVIEW卷
- 編寫高質(zhì)量代碼:改善Python程序的91個建議
- Getting Started with CreateJS
- 數(shù)據(jù)結(jié)構(gòu)習(xí)題精解(C語言實現(xiàn)+微課視頻)
- Java程序設(shè)計與計算思維
- JavaScript從入門到精通(第3版)
- MySQL入門很輕松(微課超值版)
- Hands-On JavaScript for Python Developers
- Building Slack Bots
- 現(xiàn)代C:概念剖析和編程實踐
- Arduino電子設(shè)計實戰(zhàn)指南:零基礎(chǔ)篇