我希望有一个带有两个文本框输入的基本GUI:一个用于函数convert\u数据库中的每个参数,但我不确定如何传递这些参数(我见过一些使用lambda的示例,但我无法正确实现它们)。你知道吗
到目前为止,我的尝试主要来自Tkinter的本土教程:
from tkinter import *
from tkinter import ttk
def convert_databases(input_file, output_format):
#Function deleted for simplicity
root = Tk()
root.title("Title")
#Formatting
mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)
#Setting Variables
file = StringVar()
conversion = StringVar()
# Places to enter variables
file_entry = ttk.Entry(mainframe, width=50, textvariable=file)
file_entry.grid(column=2, row=2, sticky=(W, E))
type_entry = ttk.Entry(mainframe, width=50, textvariable=conversion)
type_entry.grid(column=2,row=3, sticky=(W,E))
# Convert Button
ttk.Button(mainframe, text="Convert", command= # Here is where I'm having trouble#)
#Label for the variable 1 input
ttk.Label(mainframe, text="Input file name: ").grid(column=1, row=2, sticky=W)
#Label for the variable 2 input
ttk.Label(mainframe, text="Input file type conversion: ").grid(column=1, row=3, sticky=W)
# This sets the window, I think?
for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5)
# Puts the cursor automatically in the text box
file_entry.focus()
# Runs the thing
root.mainloop()
谢谢!你知道吗
不要使用字符串变量我也被困在这一次,而不是使用条目获取方法
使用官方术语,如输入而不是文本框
相关问题 更多 >
编程相关推荐