【问题标题】:How do I insert the values in askdirectory into entry? Python3如何将 askdirectory 中的值插入条目? Python3
【发布时间】:2020-05-05 13:44:51
【问题描述】:

我正在尝试将目录路径放入 Te 的输入字段中

图形文件

    self.btn_browseOne = tk.Button(self.master,width=13, height=2, text='Browse...', command=lambda:func.getDir())

函数文件

def getDir():
getPath = filedialog.askdirectory()
txt_browseEntryOn.insert(0,getPath)
return getPath


if __name__=="__main__":
    pass

【问题讨论】:

  • txt_browseEntryOn 在一个类中吗?您使用 self. 作为按钮,所以我假设该条目也在一个类中。
  • @Mike-SMT 我只是找不到它

标签: python-3.x tkinter tkinter-entry


【解决方案1】:
from tkinter import *
from tkinter import ttk, filedialog as fd
root = Tk()
entry1 = ttk.Entry(root)
entry1.pack()
def getDirPath():
    z = fd.askdirectory()
    entry1.insert(END,z)
b1 = ttk.Button(root,text="ok",command=getDirPath)

b1.pack()


root.mainloop()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-15
    • 1970-01-01
    • 1970-01-01
    • 2021-07-02
    • 2016-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多