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


Python filedialog.askopenfilename函数代码示例

本文整理汇总了Python中tkinter.filedialog.askopenfilename函数的典型用法代码示例。如果您正苦于以下问题:Python askopenfilename函数的具体用法?Python askopenfilename怎么用?Python askopenfilename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: callback

def callback(type):
    if type == 'transfer':
        transfer_callback()
    elif type == 'content':
        global content_input
        # return file full path
        fname = askopenfilename(title='Select content image',
                                filetypes=[('image', '*.jpg'),
                                           ('All Files', '*')])
        if fname == '':
            return
        content_input = fname
        print('content image path: ', content_input)
        paint.update_img('content', content_input)

    elif type == 'style':
        global style_input
        # return file full path
        fname = askopenfilename(title='Select style image')
        if fname == '':
            return
        style_input = fname
        print('style image path: ', style_input)
        paint.update_img('style', style_input)

    elif type == 'cancel':
        sys.exit()
开发者ID:geekberu,项目名称:image_style_transfer,代码行数:27,代码来源:style_transfer.py

示例2: main

def main():
    # By default Tk shows an empty window, remove it
    tkinter.Tk().withdraw()

    input('Press enter to select the base file')
    baseFilePath = askopenfilename(title='Select the base file to read')
    print('Base file: ' + baseFilePath)

    input('Press enter to select the merge file')
    mergeFilePath = askopenfilename(title='Select the merge file to read')
    print('Merge file: ' + mergeFilePath)
    
    input('Press enter to select the save file')
    saveFilePath = asksaveasfilename()
    print('Save file: ' + saveFilePath)

    baseFile = csv.reader(open(baseFilePath, 'r', encoding='utf-8'))
    mergeFile = deque(csv.reader(open(mergeFilePath, 'r', encoding='utf-8')))
    saveFile = csv.writer(open(saveFilePath, 'w', encoding='utf-8'), delimiter=';', quoting=csv.QUOTE_NONE)

    mergeRow = mergeFile.popleft()
    for baseRow in baseFile:
        if mergeRow[0] == baseRow[0]:
            mergeCol = mergeRow[1]
            try:
                mergeRow = mergeFile.popleft()
            except:
                pass
        else:
            mergeCol = ''

        saveFile.writerow([baseRow[0], mergeCol, baseRow[1]])
开发者ID:sirrahd,项目名称:csv_merge,代码行数:32,代码来源:csv_merge.py

示例3: __init__

 def __init__(self, master, restore_project=False, **kw):
     Frame.__init__(self, master, **kw)
     
     #Load a project
     if restore_project:
         self.project = templify.Project.load(filedialog.askopenfilename())
     else:
         self.project = templify.Project(sample_file=filedialog.askopenfilename())
                 
     #Text
     self.text = Text(self)
     self.init_text()
     
     #Scrollbars
     self.vertical_scrollbar = ttk.Scrollbar(self)
     self.horizontal_scrollbar = ttk.Scrollbar(self)
     self.init_scrollbars()
     
     #Pop-up menu
     self.pop_up_menu = Menu(self)
     self.init_pop_up_menu()
     
     #Layout management        
     self.grid_conf()
     
     #Binding management
     self.master.bind('<Control-s>', lambda e:self.project.save())
     self.master.bind('<3>', lambda e: self.pop_up_menu.post(e.x_root, e.y_root))
开发者ID:NicoBernard,项目名称:templify,代码行数:28,代码来源:templify_ui.py

示例4: fileselect

 def fileselect(self):
     #Create a set of variables to pass back to main program.
     global filePath1
     global filePath2 
     filePath1 = ""
     filePath2 = ""
     #self.master.withdraw()
     status_1 = 0
     status_2 = 0
     while filePath1 == "":
         if status_1 == 1:
             error_msg("Error","Please select a valid file.")
         filePath1 = tk.askopenfilename(title="Open First PDF (Old Drawing)")
         if platform == "win32":					   
             filePath1 = filePath1.replace("/","\\\\")
         status_1 = 1
     
     while filePath2 == "":
         if status_2 == 1:
             error_msg("Error","Please select a valid file.")
         filePath2 = tk.askopenfilename(title="Open Second PDF (New Drawing)")
         if platform == "win32":					   
             filePath2 = filePath2.replace("/","\\\\")
         status_2 = 1
     print ("Old Drawing: "+filePath1+"\n")  #Display first filepath
     print ("New Drawing: "+filePath2+"\n")  #Display second filepath
     #self.master.deiconify()
     v_status.set("Processing images...")
     v_status_f.set("Old Drawing:\n"+filePath1+"\n"+"New Drawing:\n"+filePath2)
     self.update_idletasks()
     maketmp(tempdir)
     process_images()
     self.master.destroy()
开发者ID:HyGear,项目名称:diff-dwg,代码行数:33,代码来源:diff-dwg3.py

示例5: getfile

def getfile(var):
    if var == "ours":
        global ours, invname
        ours = filedialog.askopenfilename(filetypes=[("CSV files", "*.csv")], title="OUR CSV")
        invname.set(ours)
    elif var == "wh":
        global warehouse, bv, whname
        bv = filedialog.askopenfilename(filetypes=[("CSV files", "*.csv")], title="BELVEDERE CSV")
        whname.set(bv)
        warehouse = csv.reader(open(bv, "rt"))
开发者ID:Vinlock,项目名称:DM-INV,代码行数:10,代码来源:belvedere.py

示例6: getfile

def getfile(var):
    if var == "ours":
        global inventory, ours, invname
        ours = filedialog.askopenfilename(filetypes=[("CSV files", "*.csv")], title="OUR CSV")
        invname.set(ours)
        inventory = csv.reader(open(ours, "rt"))
    elif var == "wh":
        global warehouse, wh, whname
        wh = filedialog.askopenfilename(filetypes=[("CSV files", "*.csv")], title="MAURI CSV")
        whname.set(wh)
        warehouse = csv.reader(open(wh, "rt"))
开发者ID:Vinlock,项目名称:DM-INV,代码行数:11,代码来源:mauri.py

示例7: open_file_log

def open_file_log(event, child, login):
    flag = True
    while(flag):
        try:
            file_voice_log = fd.askopenfilename()
            file_voice_pass = fd.askopenfilename()
        except:
            print("Невозможно открыть выбрать файл")
        else:
            flag = False
            registr_login(event, child, file_voice_log, file_voice_pass, login)
开发者ID:ksvinogradova,项目名称:rec_speech_diplom,代码行数:11,代码来源:interface.py

示例8: loadWorkSpace

 def loadWorkSpace(self):
     if self.workspace == None:
         self.workspace = ws.Workspace(self.root, widgets.StatusBar(self.root, self.images), self.images, gridX = 32, gridY = 32, width = 1920 * 3, height = 1080, option = con.WCC["LOAD"], 
                                       file = fd.askopenfilename(parent = self.root, defaultextension = ".blml", title = "Open", filetypes=[("rbr level file", ".blml"), ("All files", ".*")]))
         self.root.config(menu = widgets.MenuBar(self.root, self.workspace, self.images, self.newWorkSpace, self.loadWorkSpace))
     else:
         self.workspace.destroy()
         self.workspace = ws.Workspace(self.root, widgets.StatusBar(self.root, self.images), self.images, gridX = 32, gridY = 32, width = 1920 * 3, height = 1080, option = con.WCC["LOAD"], 
                                       file = fd.askopenfilename(parent = self.root, defaultextension = ".blml", title = "Open", filetypes=[("rbr level file", ".blml"), ("All files", ".*")]))
         self.root.config(menu = widgets.MenuBar(self.root, self.workspace, self.images, self.newWorkSpace, self.loadWorkSpace))
         
开发者ID:HaNaK0,项目名称:RBR_LD,代码行数:10,代码来源:main.py

示例9: open_file_enter

def open_file_enter(event, child):
    flag = True
    while(flag):
        try:
            file_voice_log = fd.askopenfilename()
            file_voice_pass = fd.askopenfilename()
        except:
            print("Невозможно открыть выбрать файл")
        else:
            flag = False
            but_ok = tk.Button(child, text = 'ok')
            but_ok.pack()
            but_ok.bind("<Button-1>", lambda event:search_login(event, child, file_voice_log, file_voice_pass))
开发者ID:ksvinogradova,项目名称:rec_speech_diplom,代码行数:13,代码来源:interface.py

示例10: get_filename

    def get_filename(self, init_dir, name, filetype):
        """
        This function sets the filename of the input csv file

        :param init_dir: Initial directory to look for input csv files
        :param name: Name of the selecting button
        :param filetype: File type allowed as the input
        """
        try:
            self.filename =  filedialog.askopenfilename(initialdir = init_dir,title = name,filetypes = (filetype,("csv files","*.csv")))
        except Exception as inst:
            self.pop_up(inst)
            self.filename =  filedialog.askopenfilename(initialdir = init_dir,title = name,filetypes = (filetype,("csv files","*.csv")))
开发者ID:xy008areshsu,项目名称:Sudoku,代码行数:13,代码来源:gui.py

示例11: openDirSearchBox

    def openDirSearchBox(data, canvas):
        if (data.mode == "mainProgram"):
            fileOpened = filedialog.askopenfilename()

            # Check if correct file type:
            while (not fileOpened.endswith(".gif") and (fileOpened != "")):
                tkinter.messagebox.showinfo("Warning", 
                        "Upload an IMAGE(.gif), please.")
                fileOpened = filedialog.askopenfilename()

            data.filename = fileOpened
            init(data, canvas)

        canvas.update()
开发者ID:LthorneCMU,项目名称:LthorneCMU.github.io,代码行数:14,代码来源:LaserCutterFINAL.py

示例12: loadChoreography

    def loadChoreography(self):

        if self.debug_FLAG:
            if self.db == 'salsa':
                tempf =self.debug_fastaccess
                tempf = list(tempf)
                tempf[0] = tempf[0].upper()
                tempf = ''.join(tempf)

                fname = "Data\\Salsa\\SVL\\" + tempf + "_DanceAnnotationTool.svl"

            elif self.db == 'calus':
                fname = "Data\\Calus\\DanceAnnotationTool.txt"
        else:
            if self.db == 'salsa':
                fname  = askopenfilename(initialdir='Data\\Salsa\\SVL', filetypes=(("svl file", "*.svl"), ("txt file", "*.txt"), ("All files", "*.*") ))
            elif self.db == 'calus':
                fname  = askopenfilename(initialdir='Data\\Calus', filetypes=(("txt file", "*.txt"), ("svl file", "*.svl"), ("All files", "*.*") ))



        dummy, fextension = os.path.splitext(fname)

        if fname:
            try:
                if fextension == '.svl':
                    params, self.annotationSecs, self.labels = readsvl.extractSvlAnnotRegionFile(fname)
                    self.entry_name_choreo.insert(0,"..." + fname[-30:])
                    self.choreoStatusSTR.set(str(len(self.labels)) + " labels")
                    self.choreoLoadedFlag = True
                    self.checkContinueEnable()
                elif fextension == '.txt':
                    self.annotationSecs, self.labels, self.annotationSecsB, self.labelsB = readtxt.parse(fname)
                    self.entry_name_choreo.insert(0,"..." + fname[-30:])
                    self.choreoStatusSTR.set(str(len(self.labels)) + " labels")
                    self.choreoLoadedFlag = True
                    self.checkContinueEnable()
                else:
                    showerror("Waring", "Parser does not exists for such a file, only svl or txt are supported")

            except Exception as e:
                self.choreoLoadedFlag = False
                self.checkContinueEnable()
                msg = "There was a problem in loading!\n'%s'" % e
                if messagebox.askyesno("Error", msg + "\n" + "Do you want to choose another file?"):
                    self.loadChoreography()
                else:
                    return
        return
开发者ID:MKLab-ITI,项目名称:DanceAnno,代码行数:49,代码来源:DanceAnno_Loader.py

示例13: import_datashop_file

 def import_datashop_file(self):
     
     filename = filedialog.askopenfilename()
     
     with open(filename,"r") as filein:
         header_line = filein.readline()
         headers = header_line.split("\t")
     
     filelen = file_len(filename)       
     count =0
     
     with open(filename,"r") as filein:
         filein.readline() #skip header line
         while 1:
             line = filein.readline()
             if not line:
                 break
             
             rt.status.config(text="Status: Importing Datashop file... " + str(count) + " / " + str(filelen))
             rt.status.update_idletasks()
             
             count+=1
             
             values = line.split("\t")
             transaction = dict(zip(headers,values))
             
             skills = get_skills(transaction)
             
             #("problem_name","step_text","transaction_text","skill_names","outcome")
             rt.treeview.insert("","end",text= "Transaction", values=(transaction["Problem Name"],transaction["Step Name"],transaction["Transaction Id"],json.dumps(skills),transaction["Outcome"]))
     
     rt.status.config(text="Status: Idle")
     rt.status.update_idletasks()
     
     print("file " + filename)
开发者ID:rcarlson-cli,项目名称:hpit_services,代码行数:35,代码来源:replay2.py

示例14: open

 def open(self):
     filen = filedialog.askopenfilename(
             defaultextension=".js",
             initialfile="worldfile.js",
             initialdir="../",
             filetypes=(("Javascript files", "*.js"),
                        ("All files", "*")),
             title="Save")
     if filen != () and filen != "":
         with open(filen, "r") as fileo:
             header = fileo.readline()
             if header != "var worldfile = \n":
                 print("Not a proper worldfile")
                 return
             data = fileo.readline()
             self.roomset.load(json.loads(data))
         self.drawgrid(0,0)
         self.currentx = 0
         self.currenty = 0
         self.room = self.roomset.getroom(0,0)
         self.drawroom()
         self.objectlist.delete(0, tk.END)
         for i,x in enumerate(self.room.objects):
             if (x[0] >= 200):
                 self.objectlist.insert(
                     i, "Arbitrary {}: {}, {}".format(*x))
             else:
                 self.objectlist.insert(
                     i, "{}: {}, {}".format(Type[x[0]], x[1], x[2]))
开发者ID:nicolebranagan,项目名称:games-js,代码行数:29,代码来源:editor.py

示例15: auto

   def auto(self, id):
      if (id == AutoSel.OPEN):
         gcodefile = filedialog.askopenfilename(parent=self, title="Open Gcode File")
         if (len(gcodefile) != 0):
            self.auto_val.set(gcodefile)
            self.display_max_line(gcodefile)
      elif (id == AutoSel.RUN):
         gcodefile = self.auto_val.get()
         if (gcodefile == ''):
            return
         if (not self.safety_check_ok()):
            return

         self.display_max_line(gcodefile)
         self.set_idle_state(ButtonState.BUSY)
         m = {}
         m['id'] = MechEvent.CMD_RUN
         m['file'] = gcodefile
         self.mechq.put(m)
         self.bp3d.clear_plot()
      else:
         gcodefile = self.auto_val.get()
         if (gcodefile == ''):
            return
         if (self.dog.get_state() & MechStateBit.VERIFY):
            self.dog.verify_cancel()
         else:
            self.display_max_line(gcodefile)
            self.set_idle_state(ButtonState.VERIFY)
            m = {}
            m['id'] = MechEvent.CMD_VERIFY
            m['file'] = gcodefile
            self.mechq.put(m)
            self.bp3d.clear_plot()
开发者ID:myrickml,项目名称:rtstepperemc,代码行数:34,代码来源:pymini.py


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