Python tkinter.filedialog.askopenfile() Examples
The following are 8
code examples of tkinter.filedialog.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
tkinter.filedialog
, or try the search function
.
Example #1
Source File: rollingshutter.py From rollingshutterpy with GNU General Public License v3.0 | 6 votes |
def select_input(self) -> None: file = askopenfile(title='Please select one (any) frame from your set of images.', filetypes=[('Image Files', ['.jpeg', '.jpg', '.png', '.gif', '.tiff', '.tif', '.bmp'])]) if not file: return None dir_ = os.path.dirname(file.name) filetype = os.path.splitext(file.name) self.files = [os.path.abspath(os.path.join(dir_, f)) for f in os.listdir(dir_) if f.endswith(filetype)] self.files.sort() self.btn_output['state'] = 'normal'
Example #2
Source File: legofy_gui.py From Legofy with MIT License | 6 votes |
def choose_a_file(self): options = {} options['defaultextension'] = '.jpg' options['filetypes'] = [('JPEG', '.jpg'), ('GIF', '.gif'), ('PNG', '.png'),] options['initialdir'] = os.path.realpath("\\") options['initialfile'] = '' options['parent'] = self options['title'] = 'Choose a file' self.chosenFile = filedialog.askopenfile(mode='r', **options) if self.chosenFile: self.chosenFilePath.set(self.chosenFile.name)
Example #3
Source File: openfile.py From Endless-Sky-Mission-Builder with GNU General Public License v3.0 | 6 votes |
def open_file(): """ This method handles reading in Endless Sky mission files. It creates a mission object for each mission it finds, and then calls the parser to parse the data """ #TODO: Add handling for mission preamble(license text) logging.debug("Selecting mission file...") f = filedialog.askopenfile() if f is None: # askopenfile() returns `None` if dialog closed with "cancel". return logging.debug("Opening file: %s" % f.name) with open(f.name) as infile: mission_lines = infile.readlines() infile.close() config.mission_file_items.empty() parser = MissionFileParser(mission_lines) parser.run() config.active_item = config.mission_file_items.items_list[0] config.gui.update_option_pane() #end open_file
Example #4
Source File: broadcast_message.py From whatsapp-play with MIT License | 5 votes |
def ProcessNumbers(): __logger.info("Processing numbers.") print("Choose a text file containing full numbers with country code, one number per line.") Tk().withdraw() filename = askopenfile( initialdir=data_folder_path, title='Choose a text file with numbers.', filetypes=[("text files", "*.txt")], mode="r" ) numbers = filename.readlines() for i in range(len(numbers)): number = numbers[i].strip("\n+") numbers[i] = number return numbers
Example #5
Source File: gb_ide.py From greenBerry with Apache License 2.0 | 5 votes |
def open_file(self, event=0): self.txt.delete("insert") # Ctrl+o causes a new line so we need to delete it ftypes = [("greenBerry files", "*.gb"), ("All files", "*")] file = filedialog.askopenfile(filetypes=ftypes) if file != None: self.file_dir = file.name self.parent.title("greenBerry IDE" + " - " + file.name.replace("/", "\\")) self.txt.delete("1.0", "end" + "-1c") text = self.read_file(file.name) self.txt.insert("end", text) self.old_text = self.txt.get("1.0", "end" + "-1c") self.key_pressed()
Example #6
Source File: keyboard_gui.py From synthesizer with GNU Lesser General Public License v3.0 | 5 votes |
def load_preset(self): file = askopenfile(filetypes=[("Synth presets", "*.ini")]) cf = ConfigParser() cf.read_file(file) file.close() # general settings self.samplerate_choice.set(cf["settings"]["samplerate"]) self.rendering_choice.set(cf["settings"]["rendering"]) self.a4_choice.set(cf["settings"]["a4tuning"]) self.to_speaker_lb.selection_clear(0, tk.END) to_speaker = cf["settings"]["to_speaker"] to_speaker = tuple(to_speaker.split(',')) for o in to_speaker: self.to_speaker_lb.selection_set(int(o)-1) for section in cf.sections(): if section.startswith("oscillator"): num = int(section.split('_')[1])-1 osc = self.oscillators[num] for name, value in cf[section].items(): getattr(osc, name).set(value) osc.waveform_selected() elif section.startswith("envelope"): num = int(section.split('_')[1])-1 env = self.envelope_filter_guis[num] for name, value in cf[section].items(): getattr(env, name).set(value) elif section == "arpeggio": for name, value in cf[section].items(): getattr(self.arp_filter_gui, name).set(value) elif section == "tremolo": for name, value in cf[section].items(): getattr(self.tremolo_filter_gui, name).set(value) elif section == "echo": for name, value in cf[section].items(): getattr(self.echo_filter_gui, name).set(value) self.statusbar["text"] = "preset loaded."
Example #7
Source File: utils.py From faceswap with GNU General Public License v3.0 | 5 votes |
def _open(self): """ Open a file. """ logger.debug("Popping Open browser") return filedialog.askopenfile(**self._kwargs)
Example #8
Source File: telegram_bot.py From whatsapp-play with MIT License | 4 votes |
def ask_where_are_the_status_file(): print('Choose a status text file.') status_file_path = filedialog.askopenfile( initialdir=data_folder_path / 'tracking_data', title='Choose a status text file.', filetypes=(("text files", "*.txt"), ("all files", "*.*")) ) if status_file_path == (): print("Error! Choose a status.") exit() return status_file_path