
你好,textsget()需要两个参数,一个是开始,一个结束,下面是一个可以执行的代码。
import tkinter as tkimport tkinterscrolledtext as tkst
def put_text_in_lbl():
global text, lbl
fetched_content = textget('10', 'end-1c')
lbl['text'] = "What's written in text: " + fetched_content
root = tkTk()
text = tkstScrolledText(root)
lbl = tkLabel(root)
btn = tkButton(root, text="Display", command=put_text_in_lbl)
# display
textpack()
lblpack()
btnpack()
rootmainloop()
以前写的,你看看是否有所帮助
def center_window(self,master,width_flag = 0382,height_flag = 0382):
"""
窗口先隐藏到大小设置完成以后才恢复,主要原因是如果不这么做,会发生闪影现象。
width_flag 和 height_flag 值在 (0,1) ,是定位目标左上角的坐标的权重值。
都设置为 05 的话,则窗口居中。
withdraw() 函数是隐藏窗口,deiconify() 函数是显示窗口。
update() 函数是将前面原件摆放以后的窗口更新,以便获得摆放后窗口的自适配大小。
"""
masterwithdraw()
masterupdate()
current_window_width = masterwinfo_width()
current_window_height = masterwinfo_height()
screen_width = masterwinfo_screenwidth()
screen_height = masterwinfo_screenheight()
suitable_location_x = int((screen_width - current_window_width)width_flag)
suitable_location_y = int((screen_height - current_window_height)height_flag)
mastergeometry('+{}+{}'format(suitable_location_x,suitable_location_y))
masterdeiconify()
打开图像时,使用单选按钮注释值。在
在列表中收集此值
因此,在这个例子中,我有2个复合词,列表将有2个注释。在
在import Tkinter as tk
from PIL import ImageTk, Image
from tkFileDialog import askopenfilename
cmp_list = ["VU435DR","VU684DR"]
li = []
li_final = []
def sel():
selection = str(varget())
if selection == "1":
liappend("Antagonist")
elif selection == "2":
liappend("Agonist")
for i in range(len(cmp_list)):
root = tkTk()
var = tkIntVar()
ig = str(cmp_list[i] + 'png')
img = ImageTkPhotoImage(Imageopen(ig))
panel = tkLabel(root,image=img)
panelpack(side = "top",fill="none",expand="no")
#w = tkText(height=2,width=50)
#wpack(side='right")
q = tkRadiobutton(root,text="Antagonist",command=sel,value=1,variable=var)
qpack()
r = tkRadiobutton(root,text="Agonist",command=sel,value=2,variable=var)
rpack()
rootmainloop()
print li
Python编程中,用Tkinter中的文本框获取系统当前的时间并且显示,代码如下:
import sysfrom tkinter import
import time
def tick():
global time1
# 从运行程序的计算机上面获取当前的系统时间
time2 = timestrftime('%H:%M:%S')
# 如果时间发生变化,代码自动更新显示的系统时间
if time2 != time1:
time1 = time2
clockconfig(text=time2)
# calls itself every 200 milliseconds
# to update the time display as needed
# could use >200 ms, but display gets jerky
clockafter(200, tick)
root = Tk()
time1 = ''
status = Label(root, text="v10", bd=1, relief=SUNKEN, anchor=W)
statusgrid(row=0, column=0)
clock = Label(root, font=('times', 20, 'bold'), bg='green')
clockgrid(row=0, column=1)
tick()
rootmainloop()
以上就是关于tkinter python3 如何获取ScrolledText的内容,记得看详细说明。全部的内容,包括:tkinter python3 如何获取ScrolledText的内容,记得看详细说明。、python中tkinter界面居中,为什么运行开始时会在初始位置闪烁一下再居中代码如下,望高手指点一下!!、Python里tkinter如何重置单选按钮等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)