当前位置: 首页>>代码示例>>Python>>正文


Python filedialog.askopenfile方法代码示例

本文整理汇总了Python中tkinter.filedialog.askopenfile方法的典型用法代码示例。如果您正苦于以下问题:Python filedialog.askopenfile方法的具体用法?Python filedialog.askopenfile怎么用?Python filedialog.askopenfile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter.filedialog的用法示例。


在下文中一共展示了filedialog.askopenfile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: open_file

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import askopenfile [as 别名]
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 
开发者ID:shitwolfymakes,项目名称:Endless-Sky-Mission-Builder,代码行数:27,代码来源:openfile.py

示例2: select_input

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import askopenfile [as 别名]
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' 
开发者ID:alexd3rsan,项目名称:rollingshutterpy,代码行数:18,代码来源:rollingshutter.py

示例3: choose_a_file

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import askopenfile [as 别名]
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) 
开发者ID:JuanPotato,项目名称:Legofy,代码行数:17,代码来源:legofy_gui.py

示例4: ask_where_are_the_status_file

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import askopenfile [as 别名]
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 
开发者ID:rpotter12,项目名称:whatsapp-play,代码行数:13,代码来源:telegram_bot.py

示例5: ProcessNumbers

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import askopenfile [as 别名]
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 
开发者ID:rpotter12,项目名称:whatsapp-play,代码行数:17,代码来源:broadcast_message.py

示例6: open_file

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import askopenfile [as 别名]
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() 
开发者ID:Abdur-rahmaanJ,项目名称:greenBerry,代码行数:16,代码来源:gb_ide.py

示例7: load_preset

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import askopenfile [as 别名]
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." 
开发者ID:irmen,项目名称:synthesizer,代码行数:38,代码来源:keyboard_gui.py

示例8: _open

# 需要导入模块: from tkinter import filedialog [as 别名]
# 或者: from tkinter.filedialog import askopenfile [as 别名]
def _open(self):
        """ Open a file. """
        logger.debug("Popping Open browser")
        return filedialog.askopenfile(**self._kwargs) 
开发者ID:deepfakes,项目名称:faceswap,代码行数:6,代码来源:utils.py


注:本文中的tkinter.filedialog.askopenfile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。