filedialog, tkinter and opening files

后端 未结 3 1108
谎友^
谎友^ 2020-11-28 05:55

I\'m working for the first time on coding a Browse button for a program in Python3. I\'ve been searching the internet and this site, and even python standard library.

<
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 06:35

    Did you try adding the self prefix to the fileName and replacing the method above the Button ? With the self, it becomes visible between methods.

    ...
    
    def load_file(self):
        self.fileName = filedialog.askopenfilename(filetypes = (("Template files", "*.tplate")
                                                         ,("HTML files", "*.html;*.htm")
                                                         ,("All files", "*.*") ))
    ...
    

提交回复
热议问题