She*_*nta 4 python tkinter python-2.7 tkinter-canvas
如何增加或定义 tkSimpleDialog 框的窗口大小?
import Tkinter, tkSimpleDialog
root = Tkinter.Tk()
root.withdraw()
test = tkSimpleDialog.askstring("testing", "Enter your search string text")
print test
Run Code Online (Sandbox Code Playgroud)
小智 5
使第二个参数尽可能大:
import Tkinter, tkSimpleDialog
root = Tkinter.Tk()
root.withdraw()
test = tkSimpleDialog.askstring("testing", "Enter your search string text in the space provided")
print test
Run Code Online (Sandbox Code Playgroud)
从以下位置开始: http: //effbot.org/tkinterbook/tkinter-dialog-windows.htm 我执行了以下操作:
import Tkinter as tk, tkSimpleDialog
class MyDialog(tkSimpleDialog.Dialog):
def body(self, master):
self.geometry("800x600")
tk.Label(master, text="Enter your search string text:").grid(row=0)
self.e1 = tk.Entry(master)
self.e1.grid(row=0, column=1)
return self.e1 # initial focus
def apply(self):
first = self.e1.get()
self.result = first
root = tk.Tk()
root.withdraw()
test = MyDialog(root, "testing")
print test.result
Run Code Online (Sandbox Code Playgroud)
如果您希望可以自定义几何图形和标签的文本,您可能需要覆盖__init__
(链接中给出的版本应该是一个很好的起点)。