看板 Python 關於我們 聯絡資訊
如題,對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
eight0: 一樣從原本的模組引入 Directory 06/23 08:24
eight0: 不過為何要拆開放到不同 module? 06/23 08:24
tyc5116: 算是在做測試而已,現在不知道怎麼引入,會顯示 06/23 08:50
tyc5116: Directory未定義耶 06/23 08:50