tk

Python--tkinter之Text

孤者浪人 提交于 2020-01-24 22:50:13
Text部件 Text是tkinter中提供的一个多行文本区域,显示多行,可用来收集用户输入的文字,格式化文本显示,允许你用不同的样式和属性来显示和编辑文本,同时支持内嵌图像和窗口。 案列如下: 代码如下: import tkinter as tk window = tk . Tk ( ) window . title ( 'My window' ) window . geometry ( '600x400' ) e = tk . Entry ( window , show = None ) #显示为明文 e . pack ( ) #定义两个函数 def insert_point ( ) : #在鼠标点处插入输入内容 var = e . get ( ) #得到变量e的值,e = tk.Entry(window, show=None) t . insert ( 'insert' , var ) #插入text中,其中t为 t=tk.Text(window,height=2) def insert_end ( ) : #在文本框内容最后接着插入输入内容 var = e . get ( ) t . insert ( 'end' , var ) #创建两个按钮分别触发两种情况 b1 = tk . Button ( window , text = 'i love you' , width =

Tcl/Tk LstBox width in CombBox

流过昼夜 提交于 2020-01-24 18:17:07
问题 How can I configure the listbox component width in a combobox, so that it will fit to longest entry? The widget width itself (the entry component) can be short, but I'm looking for a way to configure the listbox component to be wider than the entry... 回答1: This is possible, but not without a bit of hacking ;) You can find the implementation of combobox in combobox.tcl (in my case /usr/share/tcltk/tk8.5/ttk/combobox.tcl . There you see that if you have a combobox set cb [ttk::combobox .cb

Parent/master vs. in_ in tkinter

南笙酒味 提交于 2020-01-24 06:02:10
问题 Examine the following code: import Tkinter as tk root=tk.Tk() f1 = tk.Frame(width=200, height=200, background="red") f2 = tk.Frame(width=100, height=100, background="blue") f1.pack(fill="both", expand=True, padx=20, pady=20) f2.place(in_=f1, anchor="c", relx=.5, rely=.5) root.mainloop() Taken from: How do I center a frame within a frame in Tkinter? One of the comments there says "The root window is the default when a widget doesn't explicitly specify a parent" and also " In this case f1 is

免费tk域名+freewebhostingarea空间

余生长醉 提交于 2020-01-22 01:48:31
1.申请免费域名 进入 http://www.dot.tk (推荐注册tk域名),申请一个新的域名,每次申请12个月以下是免费的,到期前 14天 可以免费续期 在此页面执行下一步之前,需要进行设置DNS服务器 2.获取DNS服务器 申请进入 http://freewebhostingarea.com/ ,如下图填写刚刚申请的域名,然后按PROCEED继续 跳转至下一页提示: 3.根据下图提示,完善步骤1 如图设置,执行下一步。 这样,基本上就申请完了。以后的操作就是登录空间后台进行管理,和登录FTP上传网页了。这一部分就不再叙述了。域名生效一般要等几个小时,所以申请好后,不要心急~ 来源: https://www.cnblogs.com/jpfss/p/10947588.html

Tkinter: How to make Tkinter to refresh and delete last lines?

人盡茶涼 提交于 2020-01-21 14:40:56
问题 Problem is: Clock hands in Tkinter flashes because I use w.delete , but if i don't use it then clock hands duplicate.. Please help. import Tkinter as tk; import time from math import cos,sin,pi import sys root=tk.Tk(); root.title("Clock") w = tk.Canvas(root, width=320, height=320, bg="#456", relief= "sunken", border=10) w.pack() size=300 def funA(): s=time.localtime()[5] m=time.localtime()[4] h=time.localtime()[3] w.update() degrees = 6*s angle = degrees*pi*2/360 ox = 165 oy = 165 x = ox +

Tkinter: How to make Tkinter to refresh and delete last lines?

早过忘川 提交于 2020-01-21 14:38:09
问题 Problem is: Clock hands in Tkinter flashes because I use w.delete , but if i don't use it then clock hands duplicate.. Please help. import Tkinter as tk; import time from math import cos,sin,pi import sys root=tk.Tk(); root.title("Clock") w = tk.Canvas(root, width=320, height=320, bg="#456", relief= "sunken", border=10) w.pack() size=300 def funA(): s=time.localtime()[5] m=time.localtime()[4] h=time.localtime()[3] w.update() degrees = 6*s angle = degrees*pi*2/360 ox = 165 oy = 165 x = ox +

When to use Variable classes? (BooleanVar, DoubleVar, IntVar, StringVar)

被刻印的时光 ゝ 提交于 2020-01-18 17:59:46
问题 Can't tkinter.widget.configure(text="our text") be used for all widgets? What is the advantage, or the main purpose of using: var_cls = tkinter.StringVar() tkinter.widget.configure(textvariable=var_cls) Is it that var_cls can be more easily shared among methods/classes etc? Example with a Variable class: import tkinter as tk root = tk.Tk() var = tk.StringVar(value="This will be on the label.") tk.Label(root, textvariable=var).pack() root.mainloop() Example without a Variable class: import

When to use Variable classes? (BooleanVar, DoubleVar, IntVar, StringVar)

空扰寡人 提交于 2020-01-18 17:56:09
问题 Can't tkinter.widget.configure(text="our text") be used for all widgets? What is the advantage, or the main purpose of using: var_cls = tkinter.StringVar() tkinter.widget.configure(textvariable=var_cls) Is it that var_cls can be more easily shared among methods/classes etc? Example with a Variable class: import tkinter as tk root = tk.Tk() var = tk.StringVar(value="This will be on the label.") tk.Label(root, textvariable=var).pack() root.mainloop() Example without a Variable class: import

When to use Variable classes? (BooleanVar, DoubleVar, IntVar, StringVar)

二次信任 提交于 2020-01-18 17:55:27
问题 Can't tkinter.widget.configure(text="our text") be used for all widgets? What is the advantage, or the main purpose of using: var_cls = tkinter.StringVar() tkinter.widget.configure(textvariable=var_cls) Is it that var_cls can be more easily shared among methods/classes etc? Example with a Variable class: import tkinter as tk root = tk.Tk() var = tk.StringVar(value="This will be on the label.") tk.Label(root, textvariable=var).pack() root.mainloop() Example without a Variable class: import

When to use Variable classes? (BooleanVar, DoubleVar, IntVar, StringVar)

余生颓废 提交于 2020-01-18 17:55:06
问题 Can't tkinter.widget.configure(text="our text") be used for all widgets? What is the advantage, or the main purpose of using: var_cls = tkinter.StringVar() tkinter.widget.configure(textvariable=var_cls) Is it that var_cls can be more easily shared among methods/classes etc? Example with a Variable class: import tkinter as tk root = tk.Tk() var = tk.StringVar(value="This will be on the label.") tk.Label(root, textvariable=var).pack() root.mainloop() Example without a Variable class: import