Python tkfiledialog.askopenfile() Examples

The following are 12 code examples of tkfiledialog.askopenfile(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tkFileDialog , or try the search function .
Example #1
Source File: MiniNAM.py    From MiniNAM with GNU General Public License v2.0 6 votes vote down vote up
def loadPrefs( self ):
        "Load command."
        c = self.canvas

        myFormats = [
            ('Config File','*.config'),
            ('All Files','*'),
        ]
        f = tkFileDialog.askopenfile(filetypes=myFormats, mode='rb')
        if f == None:
            return

        loadedPrefs = self.convertJsonUnicode(json.load(f))
        # Load application preferences
        if 'preferences' in loadedPrefs:
            self.appPrefs = dict(self.appPrefs.items() + loadedPrefs['preferences'].items())
        # Load application filters
        if 'filters' in loadedPrefs:
            self.appFilters = dict(self.appFilters.items() + loadedPrefs['filters'].items())
        f.close() 
Example #2
Source File: MiniNAM.py    From MiniNAM with GNU General Public License v2.0 6 votes vote down vote up
def loadPrefs( self ):
        "Load command."
        c = self.canvas

        myFormats = [
            ('Config File','*.config'),
            ('All Files','*'),
        ]
        f = tkFileDialog.askopenfile(filetypes=myFormats, mode='rb')
        if f == None:
            return

        loadedPrefs = self.convertJsonUnicode(json.load(f))
        # Load application preferences
        if 'preferences' in loadedPrefs:
            self.appPrefs = dict(self.appPrefs.items() + loadedPrefs['preferences'].items())
        # Load application filters
        if 'filters' in loadedPrefs:
            self.appFilters = dict(self.appFilters.items() + loadedPrefs['filters'].items())
        f.close() 
Example #3
Source File: MiniNAM.py    From MiniNAM with GNU General Public License v2.0 6 votes vote down vote up
def loadPrefs( self ):
        "Load command."
        c = self.canvas

        myFormats = [
            ('Config File','*.config'),
            ('All Files','*'),
        ]
        f = tkFileDialog.askopenfile(filetypes=myFormats, mode='rb')
        if f == None:
            return

        loadedPrefs = self.convertJsonUnicode(json.load(f))
        # Load application preferences
        if 'preferences' in loadedPrefs:
            self.appPrefs = dict(self.appPrefs.items() + loadedPrefs['preferences'].items())
        # Load application filters
        if 'filters' in loadedPrefs:
            self.appFilters = dict(self.appFilters.items() + loadedPrefs['filters'].items())
        f.close() 
Example #4
Source File: MiniNAM.py    From MiniNAM with GNU General Public License v2.0 6 votes vote down vote up
def loadPrefs( self ):
        "Load command."
        c = self.canvas

        myFormats = [
            ('Config File','*.config'),
            ('All Files','*'),
        ]
        f = tkFileDialog.askopenfile(filetypes=myFormats, mode='rb')
        if f == None:
            return

        loadedPrefs = self.convertJsonUnicode(json.load(f))
        # Load application preferences
        if 'preferences' in loadedPrefs:
            self.appPrefs = dict(self.appPrefs.items() + loadedPrefs['preferences'].items())
        # Load application filters
        if 'filters' in loadedPrefs:
            self.appFilters = dict(self.appFilters.items() + loadedPrefs['filters'].items())
        f.close() 
Example #5
Source File: fisheye.py    From DualFisheye with MIT License 5 votes vote down vote up
def load_config(self, filename=None):
        if filename is None:
            file_obj = tkFileDialog.askopenfile()
            if file_obj is None: return
        else:
            file_obj = open(filename, 'r')
        try:
            load_config(file_obj, self.lens1, self.lens2)
        except:
            tkMessageBox.showerror('Config load error', traceback.format_exc()) 
Example #6
Source File: fisheye.py    From DualFisheye with MIT License 5 votes vote down vote up
def _file_select(self, tkstr):
        result = tkFileDialog.askopenfile()
        if result is not None:
            tkstr.set(result.name)
            result.close()

    # Make a combined label/textbox/slider for a given variable: 
Example #7
Source File: gui.py    From sky3ds.py with MIT License 5 votes vote down vote up
def __init__(self):
        data_dir = user_data_dir('sky3ds', 'Aperture Laboratories')
        template_txt = os.path.join(data_dir, 'template.txt')

        file_name = tkFileDialog.askopenfile( initialdir = os.path.expanduser('~/Desktop'), filetypes=[ ("Text files","*.txt")] )

        if file_name:
            try:
                new_template = file_name.read()
                write_template = open(template_txt, 'w')
                write_template.write(new_template)

                file_name.close()
                write_template.close()

                tkMessageBox.showinfo("Template Updated", "Template.txt updated successfully")

            except:
                raise Exception("Template.txt could not be updated")

            try:
                titles.convert_template_to_json()
            except:
                raise Exception("Template.txt could not converted to JSON. Please verify that your template.txt is not corrupt.")
        else:
            return 
Example #8
Source File: builderWindow.py    From universalSmashSystem with GNU General Public License v3.0 5 votes vote down vote up
def loadFighter(self):
        fighter_file = askopenfile(mode="r",initialdir=settingsManager.createPath('fighters'),filetypes=[('TUSSLE Fighters','*.xml'),('Advanced Fighters', '*.py')])
        self.root.fighter_file = fighter_file
        self.root.fighter_properties = fighter_file.read()
        self.root.fighter_string.set(fighter_file.name)
        self.entryconfig("Action", state=NORMAL) 
Example #9
Source File: subactionSelector.py    From universalSmashSystem with GNU General Public License v3.0 5 votes vote down vote up
def pickFile(self,_resultVar, _filetype='file', _extensions=[]):
        if _filetype == 'file':
            loaded_file = askopenfile(mode="r",
                               initialdir=settingsManager.createPath('fighters'),
                               filetypes=_extensions)
            loaded_name = loaded_file.name
        elif _filetype == 'dir':
            loaded_name = askdirectory(initialdir=settingsManager.createPath(''))
        res = os.path.relpath(loaded_name,os.path.dirname(self.root.root.fighter_file.name))
        _resultVar.set(res) 
Example #10
Source File: dataSelector.py    From universalSmashSystem with GNU General Public License v3.0 5 votes vote down vote up
def loadImage(self):
        if self.target_object:
            imgfile = askopenfile(mode="r",initialdir=self.target_object.base_dir,filetypes=[('Image Files','*.png')])
            self.image_data.set(os.path.relpath(imgfile.name, self.target_object.base_dir)) 
Example #11
Source File: dataSelector.py    From universalSmashSystem with GNU General Public License v3.0 5 votes vote down vote up
def loadImage(self):
        if self.target_object:
            modulefile = askopenfile(mode="r",initialdir=self.target_object.base_dir,filetypes=[('TUSSLE ActionScript files','*.xml'),('Python Files','*.py')])
            self.module_data.set(os.path.relpath(modulefile.name, self.target_object.base_dir)) 
Example #12
Source File: gimodule.py    From geoist with MIT License 5 votes vote down vote up
def showfilebrowser(self):
        import tkFileDialog
        file = tkFileDialog.askopenfile()
        try:
            #Only do something if a file has been selected.
            if file.name:
                self.textentry.delete(0,255)
                self.textentry.insert(0, file.name)
        except:
            #If no file has been selected do nothing.
            pass