本文介绍了增加 tkSimpleDialog 窗口大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何增加或定义 tkSimpleDialog 框的窗口大小?
How do i increase or define window size of tkSimpleDialog box ?
import Tkinter, tkSimpleDialog
root = Tkinter.Tk()
root.withdraw()
test = tkSimpleDialog.askstring("testing", "Enter your search string text")
print test
推荐答案
起始于:http://effbot.org/tkinterbook/tkinter-dialog-windows.htm我做了以下事情:
Starting from: http://effbot.org/tkinterbook/tkinter-dialog-windows.htmI did the following:
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
如果您希望几何图形和标签文本可自定义,您可能需要覆盖 __init__
(链接中给出的版本应该是一个很好的起点).
If you want geometry and the label's text to be customizable, you will probably need to override __init__
(the version given in the link should be a good starting point).
这篇关于增加 tkSimpleDialog 窗口大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!