Python tkinter.filedialog 模块,Open() 实例源码

我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用tkinter.filedialog.Open()

项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def browseFile(self):
        filetypes = [
            ("HTML Files", "*.htm *.html", "TEXT"),
            ("PDF Files", "*.pdf", "TEXT"),
            ("Windows Help Files", "*.chm"),
            ("Text Files", "*.txt", "TEXT"),
            ("All Files", "*")]
        path = self.path.get()
        if path:
            dir, base = os.path.split(path)
        else:
            base = None
            if sys.platform[:3] == 'win':
                dir = os.path.join(os.path.dirname(sys.executable), 'Doc')
                if not os.path.isdir(dir):
                    dir = os.getcwd()
            else:
                dir = os.getcwd()
        opendialog = tkFileDialog.Open(parent=self, filetypes=filetypes)
        file = opendialog.show(initialdir=dir, initialfile=base)
        if file:
            self.path.set(file)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def browseFile(self):
        filetypes = [
            ("HTML Files", "*.htm *.html", "TEXT"),
            ("PDF Files", "*.pdf", "TEXT"),
            ("Windows Help Files", "*.chm"),
            ("Text Files", "*.txt", "TEXT"),
            ("All Files", "*")]
        path = self.path.get()
        if path:
            dir, base = os.path.split(path)
        else:
            base = None
            if sys.platform[:3] == 'win':
                dir = os.path.join(os.path.dirname(sys.executable), 'Doc')
                if not os.path.isdir(dir):
                    dir = os.getcwd()
            else:
                dir = os.getcwd()
        opendialog = tkFileDialog.Open(parent=self, filetypes=filetypes)
        file = opendialog.show(initialdir=dir, initialfile=base)
        if file:
            self.path.set(file)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def browseFile(self):
        filetypes = [
            ("HTML Files", "*.htm *.html", "TEXT"),
            ("PDF Files", "*.pdf", "TEXT"),
            ("Windows Help Files", "*.chm"),
            ("Text Files", "*.txt", "TEXT"),
            ("All Files", "*")]
        path = self.path.get()
        if path:
            dir, base = os.path.split(path)
        else:
            base = None
            if sys.platform[:3] == 'win':
                dir = os.path.join(os.path.dirname(sys.executable), 'Doc')
                if not os.path.isdir(dir):
                    dir = os.getcwd()
            else:
                dir = os.getcwd()
        opendialog = tkFileDialog.Open(parent=self, filetypes=filetypes)
        file = opendialog.show(initialdir=dir, initialfile=base)
        if file:
            self.path.set(file)
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def askopenfile(self):
        dir, base = self.defaultfilename("open")
        if not self.opendialog:
            self.opendialog = tkFileDialog.Open(master=self.text,
                                                filetypes=self.filetypes)
        filename = self.opendialog.show(initialdir=dir, initialfile=base)
        return filename
项目:PyGram    作者:achillesrasquinha    | 项目源码 | 文件源码
def __init__(self,
                 window_aspect_ratio = PyGramConfig.WINDOW_ASPECT_RATIO,
                 window_width        = PyGramConfig.WINDOW_WIDTH,
                 window_height       = PyGramConfig.WINDOW_HEIGHT,
                 btngrid_rows        = PyGramConfig.BTNGRID_ROWS,
                 btngrid_cols        = PyGramConfig.BTNGRID_COLS,
                 resizable           = False):
        self.window_size  = (int(window_width), int(window_height))
        self.btngrid_size = (btngrid_rows, btngrid_cols)
        self.root         = tk.Tk()
        self.root.title('{name} v{version}'.format(
            name    = PyGramConfig.NAME,
            version = PyGramConfig.VERSION
        ))
        self.root.geometry('{width}x{height}'.format(
            width   = window_width + 2,
            height  = window_height
        ))
        self.root.resizable(width  = resizable,
                            height = resizable)
        self.frame        = PyGram.Frame(self.root,
                                         window_size  = self.window_size,
                                         btngrid_size = self.btngrid_size)
        self.frame.filemenu.add_command(label   = 'Open File',
                                        command = self.on_open_file)
        self.frame.filemenu.add_command(label   = 'Save',
                                        command = self.on_save)
项目:PyGram    作者:achillesrasquinha    | 项目源码 | 文件源码
def on_open_file(self):
        filetypes = PyGramConfig.ACCEPTED_FILES

        dialog    = filedialog.Open(self.frame, filetypes = filetypes)
        filename  = dialog.show()

        self.open_image(filename)
项目:FFT-spectrum-analyzer    作者:ariquezada    | 项目源码 | 文件源码
def open_file(self):
        """Opens dialog to select a file, reads data from file and plots the data"""
        ftypes = [('Text files', '*.txt'), ('All files', '*')]
        dlg = filedialog.Open(root, filetypes = ftypes)
        fl = dlg.show()
        if fl != '':
            # Open file for reading
            arch = open(fl, "r")
            datos_arch = arch.read()
            # Searches for every channel, delimited by L1, L2 and L3 tags.
            canal_1 = extraer_int_tag(datos_arch, 'L1')
            canal_2 = extraer_int_tag(datos_arch, 'L2')
            canal_3 = extraer_int_tag(datos_arch, 'L3')

            print("Amount of samples in channel 1: %s" %len(canal_1))
            print("Amount of samples on channel 2: %s" %len(canal_2))
            print("Amount of samples on channel 3: %s" %len(canal_3))
            message_string = "Amount of samples channel 1: {0} \n".format(len(canal_1))
            message_string += "Amount of samples channel 2: {0} \n".format(len(canal_2))
            message_string += "Amount of samples channel 3: {0} \n".format(len(canal_3))
            self.show_message(self.text_message, message_string)

            global g_canal_1, g_canal_2, g_canal_3
            #Keep a copy of the original values
            g_canal_1 = canal_1[:]            #Copy list by value not by reference
            g_canal_2 = canal_2[:]
            g_canal_3 = canal_3[:]

            self.window_var.set(1)        #Option rectangular window
            self.plot(self.tab1, self.tab2, canal_1, canal_2, canal_3, win_var=1)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def askopenfile(self):
        dir, base = self.defaultfilename("open")
        if not self.opendialog:
            self.opendialog = tkFileDialog.Open(parent=self.text,
                                                filetypes=self.filetypes)
        filename = self.opendialog.show(initialdir=dir, initialfile=base)
        return filename
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def askopenfile(self):
        dir, base = self.defaultfilename("open")
        if not self.opendialog:
            self.opendialog = tkFileDialog.Open(master=self.text,
                                                filetypes=self.filetypes)
        filename = self.opendialog.show(initialdir=dir, initialfile=base)
        return filename