python类askopenfilename()的实例源码

chartparser_app.py 文件源码 项目:hate-to-hugs 作者: sdoran35 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def load_chart(self, *args):
        "Load a chart from a pickle file"
        filename = askopenfilename(filetypes=self.CHART_FILE_TYPES,
                                   defaultextension='.pickle')
        if not filename: return
        try:
            with open(filename, 'rb') as infile:
                chart = pickle.load(infile)
            self._chart = chart
            self._cv.update(chart)
            if self._matrix: self._matrix.set_chart(chart)
            if self._matrix: self._matrix.deselect_cell()
            if self._results: self._results.set_chart(chart)
            self._cp.set_chart(chart)
        except Exception as e:
            raise
            tkinter.messagebox.showerror('Error Loading Chart',
                                   'Unable to open file: %r' % filename)
chartparser_app.py 文件源码 项目:hate-to-hugs 作者: sdoran35 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def load_grammar(self, *args):
        "Load a grammar from a pickle file"
        filename = askopenfilename(filetypes=self.GRAMMAR_FILE_TYPES,
                                   defaultextension='.cfg')
        if not filename: return
        try:
            if filename.endswith('.pickle'):
                with open(filename, 'rb') as infile:
                    grammar = pickle.load(infile)
            else:
                with open(filename, 'r') as infile:
                    grammar = CFG.fromstring(infile.read())
            self.set_grammar(grammar)
        except Exception as e:
            tkinter.messagebox.showerror('Error Loading Grammar',
                                   'Unable to open file: %r' % filename)
main.py 文件源码 项目:warpWarp 作者: ahwmrklas 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def loadGame(tkRoot):
    print("loadGame")
    #so we need to open a file select menu, filtering for .wwr
    #then we just parse the string to our dict.
    loadFileName = filedialog.askopenfilename(title = "Select file",filetypes = (("warpWar files","*.wwr"),("all files","*.*")))
    print (loadFileName)
    loadFile = open(loadFileName, 'r')
    gameString = loadFile.read()
    loadFile.close()
    gameDict = json.loads(gameString)

    #send the game to the server.
    sendJson = warpWarCmds().restoreGame(tkRoot.cfg.Profile.plid, gameDict)
    print (sendJson)
    tkRoot.hCon.sendCmd(sendJson)

# I don't like these. They don't seem very objecty
chartparser_app.py 文件源码 项目:FancyWord 作者: EastonLee 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def load_chart(self, *args):
        "Load a chart from a pickle file"
        filename = askopenfilename(filetypes=self.CHART_FILE_TYPES,
                                   defaultextension='.pickle')
        if not filename: return
        try:
            with open(filename, 'rb') as infile:
                chart = pickle.load(infile)
            self._chart = chart
            self._cv.update(chart)
            if self._matrix: self._matrix.set_chart(chart)
            if self._matrix: self._matrix.deselect_cell()
            if self._results: self._results.set_chart(chart)
            self._cp.set_chart(chart)
        except Exception as e:
            raise
            tkinter.messagebox.showerror('Error Loading Chart',
                                   'Unable to open file: %r' % filename)
chartparser_app.py 文件源码 项目:FancyWord 作者: EastonLee 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def load_grammar(self, *args):
        "Load a grammar from a pickle file"
        filename = askopenfilename(filetypes=self.GRAMMAR_FILE_TYPES,
                                   defaultextension='.cfg')
        if not filename: return
        try:
            if filename.endswith('.pickle'):
                with open(filename, 'rb') as infile:
                    grammar = pickle.load(infile)
            else:
                with open(filename, 'r') as infile:
                    grammar = CFG.fromstring(infile.read())
            self.set_grammar(grammar)
        except Exception as e:
            tkinter.messagebox.showerror('Error Loading Grammar',
                                   'Unable to open file: %r' % filename)
chartparser_app.py 文件源码 项目:beepboop 作者: nicolehe 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def load_chart(self, *args):
        "Load a chart from a pickle file"
        filename = askopenfilename(filetypes=self.CHART_FILE_TYPES,
                                   defaultextension='.pickle')
        if not filename: return
        try:
            with open(filename, 'rb') as infile:
                chart = pickle.load(infile)
            self._chart = chart
            self._cv.update(chart)
            if self._matrix: self._matrix.set_chart(chart)
            if self._matrix: self._matrix.deselect_cell()
            if self._results: self._results.set_chart(chart)
            self._cp.set_chart(chart)
        except Exception as e:
            raise
            tkinter.messagebox.showerror('Error Loading Chart',
                                   'Unable to open file: %r' % filename)
chartparser_app.py 文件源码 项目:beepboop 作者: nicolehe 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def load_grammar(self, *args):
        "Load a grammar from a pickle file"
        filename = askopenfilename(filetypes=self.GRAMMAR_FILE_TYPES,
                                   defaultextension='.cfg')
        if not filename: return
        try:
            if filename.endswith('.pickle'):
                with open(filename, 'rb') as infile:
                    grammar = pickle.load(infile)
            else:
                with open(filename, 'r') as infile:
                    grammar = CFG.fromstring(infile.read())
            self.set_grammar(grammar)
        except Exception as e:
            tkinter.messagebox.showerror('Error Loading Grammar',
                                   'Unable to open file: %r' % filename)
chartparser_app.py 文件源码 项目:kind2anki 作者: prz3m 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def load_chart(self, *args):
        "Load a chart from a pickle file"
        filename = askopenfilename(filetypes=self.CHART_FILE_TYPES,
                                   defaultextension='.pickle')
        if not filename: return
        try:
            with open(filename, 'rb') as infile:
                chart = pickle.load(infile)
            self._chart = chart
            self._cv.update(chart)
            if self._matrix: self._matrix.set_chart(chart)
            if self._matrix: self._matrix.deselect_cell()
            if self._results: self._results.set_chart(chart)
            self._cp.set_chart(chart)
        except Exception as e:
            raise
            tkinter.messagebox.showerror('Error Loading Chart',
                                   'Unable to open file: %r' % filename)
chartparser_app.py 文件源码 项目:kind2anki 作者: prz3m 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def load_grammar(self, *args):
        "Load a grammar from a pickle file"
        filename = askopenfilename(filetypes=self.GRAMMAR_FILE_TYPES,
                                   defaultextension='.cfg')
        if not filename: return
        try:
            if filename.endswith('.pickle'):
                with open(filename, 'rb') as infile:
                    grammar = pickle.load(infile)
            else:
                with open(filename, 'r') as infile:
                    grammar = CFG.fromstring(infile.read())
            self.set_grammar(grammar)
        except Exception as e:
            tkinter.messagebox.showerror('Error Loading Grammar',
                                   'Unable to open file: %r' % filename)
chartparser_app.py 文件源码 项目:but_sentiment 作者: MixedEmotions 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def load_chart(self, *args):
        "Load a chart from a pickle file"
        filename = askopenfilename(filetypes=self.CHART_FILE_TYPES,
                                   defaultextension='.pickle')
        if not filename: return
        try:
            with open(filename, 'rb') as infile:
                chart = pickle.load(infile)
            self._chart = chart
            self._cv.update(chart)
            if self._matrix: self._matrix.set_chart(chart)
            if self._matrix: self._matrix.deselect_cell()
            if self._results: self._results.set_chart(chart)
            self._cp.set_chart(chart)
        except Exception as e:
            raise
            tkinter.messagebox.showerror('Error Loading Chart',
                                   'Unable to open file: %r' % filename)
chartparser_app.py 文件源码 项目:but_sentiment 作者: MixedEmotions 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def load_grammar(self, *args):
        "Load a grammar from a pickle file"
        filename = askopenfilename(filetypes=self.GRAMMAR_FILE_TYPES,
                                   defaultextension='.cfg')
        if not filename: return
        try:
            if filename.endswith('.pickle'):
                with open(filename, 'rb') as infile:
                    grammar = pickle.load(infile)
            else:
                with open(filename, 'r') as infile:
                    grammar = CFG.fromstring(infile.read())
            self.set_grammar(grammar)
        except Exception as e:
            tkinter.messagebox.showerror('Error Loading Grammar',
                                   'Unable to open file: %r' % filename)
gui.py 文件源码 项目:qcri 作者: douville 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _load_run_results(self):
        filename = filedialog.askopenfilename()
        if not filename:
            return
        self.runresultsvar.set(filename)

        valid_parsers = importer.get_parsers(filename, self.cfg)
        if not valid_parsers:
            messagebox.showerror(
                'Unknown Format', 'Unable to parse this file. '
                'View log for details.')
            self.choose_parser['values'] = ['']
            self.choose_parser.current(0)
            self.choose_parser.event_generate('<<ComboboxSelected>>')
            return

        self.valid_parsers = {p.__name__: p for p in valid_parsers}
        self.choose_parser['values'] = list(self.valid_parsers.keys())
        if len(valid_parsers) > 1:
            self.choose_parser.config(state='enabled')
        self.choose_parser.current(0)
        self.choose_parser.event_generate('<<ComboboxSelected>>')
PyFusionWindow.py 文件源码 项目:PyFusionGUI 作者: SyntaxVoid 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def restore_clustering(self):
        # A window pops up asking the user to specify the path of a *.ANobj (Analysis Object) file
        # and attempts to restore it using the Analysis.restore classmethod. Then opens a ClusteringWindow
        # which gives the user the option to plot clusters, save the object, or close the window.
        fname = askopenfilename(initialdir=IRIS_CSCRATCH_DIR,
                                filetypes=(("Analysis File Object", "*.ANobj"), ("All Files", "*.*")))
        if fname == "" or fname == (): return None
        try:
            self.AN = analysis.Analysis.restore(fname)
            self._restore_settings_from_loaded_object()
            self.root.event_generate("<<clustering_restored>>", when="tail")
            self.using_analysis_var.set("Using analysis object from\n{}".format(jt.break_path(fname, 24)))
            self.using_analysis_label.config(fg="dark green")
        except:
            ErrorWindow(self.root, "Incorrect file format.")
        return None
codegui.py 文件源码 项目:dayworkspace 作者: copie 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def upfile(self):

        url = "http://" + HOST + ":" + PORT + "/upfile"
        # ???????
        filename = filedialog.askopenfilename()
        self.lfc_field_1_t.delete('0.0', 'end')
        self.lfc_field_1_t.insert('0.0', "??????......")
        try:
            files = {'file': open(str(filename), 'rb')}
            req = requests.post(url, files=files)
            if req.status_code == 200:
                messagebox.showinfo("??", "????")
            else:
                messagebox.showinfo("??", "????????")
        except:
            messagebox.showinfo("??", "????????")
        finally:
            self.lfc_field_1_t.delete('0.0', 'end')

    # ????
hsv-tuner.py 文件源码 项目:RunescapeBots 作者: lukegarbutt 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def open_file(self):
        global once
        once = True
        img_file = filedialog.askopenfilename()
        # this makes sure you select a file
        # otherwise program crashes if not
        if img_file  != '':
            self.img_path = img_file 
            # this just makes sure the image shows up after opening it
            self.low_hue.set(self.low_hue.get()+1)
            self.low_hue.set(self.low_hue.get()-1)
        else:
            print('picked nothing')
            return 0
tkdialog.py 文件源码 项目:sc8pr 作者: dmaccarthy 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def __init__(self, response=str, text="", title=None, accept=0, **options):
        if response is bool:
            self.dialog = [askyesno, askokcancel, askretrycancel][accept]
        else: self.dialog = {None:showinfo, str:askstring, int:askinteger, float:askfloat,
            0:askopenfilename, 1:asksaveasfilename, 2:askdirectory}[response]
        self.options = options.copy()
        if "initialdir" in options:
            self.options["initialdir"] = abspath(options["initialdir"])
        if type(response) is int:
            self.args = tuple()
            if title: self.options["title"] = title
        else:
            if title is None:
                title = "Info" if response is None else "Confirm" if response is bool else "Input"
            self.args = title, text
trainer.py 文件源码 项目:decaptcha 作者: Orzzet 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def drawhistorigram(self, master):
        try:
            self.Lb1.delete(0, END)
        except:
            self.Lb1 = Listbox(master, selectmode=MULTIPLE)

        self.filename = askopenfilename()
        mostpixels = historigram(self.filename)
        for i in range(len(mostpixels)):
            self.Lb1.insert(i+1, "Pixels: " + str(mostpixels[i][1]) + ', ' + "Value: " +str(mostpixels[i][0]))
            self.Lb1.pack()
tkinter_windows.py 文件源码 项目:Physics-2.0 作者: rschwa6308 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def open_file(self):
        filename = filedialog.askopenfilename()
        if filename and (
            not self.bodies or messagebox.askokcancel("Discard Changes", "Are you sure you want to discard changes?")):
            self.filename = filename
            self.name.set(os.path.split(filename)[-1])
            for window in self.properties_windows:
                window.destroy()
            self.properties_windows = []
            with open(filename) as file:
                self.bodies[:] = generate_bodies(load_save(self, file))
desert_mirage_gui.py 文件源码 项目:desert-mirage 作者: valentour 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def select_json():
    selection = filedialog.askopenfilename(initialdir=getcwd(),
                                           title='Select project json file')
    _jsonVar.set(selection)
    print('Selected json file: {}'.format(_jsonVar.get()))
desert_mirage_gui.py 文件源码 项目:desert-mirage 作者: valentour 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def select_seed():
    selection = filedialog.askopenfilename(initialdir=getcwd(),
                                           title='Select IVS seed file')
    _seedVar.set(selection)
    print('Selected seed file: {}'.format(_seedVar.get()))


问题


面经


文章

微信
公众号

扫码关注公众号