[問題] button回傳值
如題,對python還不熟,請教一下(我使用python 3)
想做一個功能,按下button,跳出視窗選取資料夾,選完後把路徑列在label上
def ChoiceDierctory():
str = filedialog.askdirectory(initialdir = os.environ ,
title = "選擇資料夾")
Directory.set(str);
app = Tk()
Directory = StringVar()
Button(app,text = "Choice Directory",command = ChoiceDierctory).pack()
Label(app,textvariable=Directory).pack()
已經實作出這個效果,但是如果把這個func移到別的*.py,執行時就會出錯
當我把func移到別的py檔時,請了Button內的command要再補上模組名稱
Directory這個變數我要怎麼修改,程式才可正常運作?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.163.52.121
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1434952684.A.5F0.html
推
06/23 08:24, , 1F
06/23 08:24, 1F
→
06/23 08:24, , 2F
06/23 08:24, 2F
→
06/23 08:50, , 3F
06/23 08:50, 3F
→
06/23 08:50, , 4F
06/23 08:50, 4F
Python 近期熱門文章
PTT數位生活區 即時熱門文章