简体   繁体   English

TKinter 中的下拉菜单和文件菜单

[英]Drop Down and File menu in TKinter

I'm trying to read file and display it and get user input like in how many minutes he want that file to be displayed.我正在尝试读取文件并显示它并获取用户输入,例如他希望在多少分钟内显示该文件。 Currently I'm using .get() to input file path and minutes after which he want that file to be displayed but to make it more user readable I want to implement drop down menu showing minutes and file box (D:/ drive view of particular folder where file resides).目前我正在使用.get()输入文件路径和分钟,之后他希望显示该文件,但为了使其更具用户可读性,我想实现显示分钟和文件框的下拉菜单(D:/ drive view of文件所在的特定文件夹)。

How can I code it using python Tkinter ?如何使用 python Tkinter 对其进行编码?

I researched but no luck as of now.我研究过,但到目前为止还没有运气。

----EDIT---- - - 编辑 - -

Snippet of how I'm doing it manually我如何手动操作的片段

def add_item():
 print(link_text.get(),small_break.get(),large_break.get(),maxrun_hours.get(),maxrun_minutes.get()
    ,exerun_hours.get(),exerun_minutes.get())

if link_text.get() == '' or small_break.get() == '' or large_break.get() == '' or maxrun_hours.get() == '' or maxrun_minutes.get() == '' or exerun_hours.get() == '' or exerun_minutes.get() == '':
messagebox.showerror('Required Fields', 'Please include all fields')
return

How I take input:我如何接受输入:

link_text = StringVar()
link_label = Label(app, text='TT-LINK', font=('bold', 14), pady=20, foreground="white",bg="black")
link_label.grid(row=0, column=0, sticky=W)
link_entry = Entry(app, textvariable=link_text, relief="solid")
link_entry.grid(row=0, column=1)

Any suggestions would be much appreciated !我们欢迎所有的建议 !

TRY:尝试:

example = StringVar()
example_label = Label(app, text='example')
example_label.grid(add positional cords)
list = ttk.Combobox(app, textvariable=example)
# Adding combobox drop down list
list['values'] = ('Enter entries manually to populate')
list.grid(add positional cords)
list.current()

Hope that helps...!希望对您有所帮助...!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM