Yab*_*usa 5 python user-interface tkinter python-3.x
通过一本书学习python,tkinter.END在一段代码中使用,不解释
import tkinter
def count(text, out_data):
""" Update out_data with the total number of As, Ts, Cs, and Gs found in text."""
data = text.get('0.0', **tkinter.END**)
counts = {}
for char in 'ATCG':
counts[char] = data.count(char)
out_data.set('Num As: {0} Num Ts: {1} Num Cs: {2} Num Gs: {3}'.format(
counts['A'], counts['T'], counts['C'], counts['G']))
...
Run Code Online (Sandbox Code Playgroud)
我在网上查过,我只遇到过它的例子,从来没有提到它的功能。我help(tkinter)
在 shell 中尝试过END = 'end'
,结果不是很有用。如果需要更多代码,请告诉我。不想发布整个代码,让您无缘无故地阅读更多内容。
Bry*_*ley 10
它不“做”任何事情。它是一个常量,字面字符串“end”。在这种情况下,它表示用户输入的最后一个字符之后的点。get
文本小部件上的函数需要两个值:开始位置和结束位置。
注意:在行中text.get('0.0', tkinter.END)
,'0.0'
是无效的(尽管,tkinter 欣然接受它,并将其与 一样对待'1.0'
)。文本索引的形式为line.character。行从 1 开始计数,字符从 0 开始。因此,第一个字符是'1.0'
,而不是'0.0'
。
归档时间: |
|
查看次数: |
10098 次 |
最近记录: |