View Windows Catalog GUI using Python 2.7

I am using Windows XP with the Python 2.7.2 suite and the Tkinter GUI. I want to create a simple graphical interface that has a text box and a Browse button that selects a file through directories such as C: \ (like Windows Explorer). This file will be displayed in the text box in the graphical interface. I hope this is quite descriptive.

+4
source share
3 answers

I have something else that can help you:

## {{{ http://code.activestate.com/recipes/438123/ (r1) # ======== Select a directory: import Tkinter, tkFileDialog root = Tkinter.Tk() dirname = tkFileDialog.askdirectory(parent=root,initialdir="/",title='Please select a directory') if len(dirname ) > 0: print "You chose %s" % dirname # ======== Select a file for opening: import Tkinter,tkFileDialog root = Tkinter.Tk() file = tkFileDialog.askopenfile(parent=root,mode='rb',title='Choose a file') if file != None: data = file.read() file.close() print "I got %d bytes from this file." % len(data) # ======== "Save as" dialog: import Tkinter,tkFileDialog myFormats = [ ('Windows Bitmap','*.bmp'), ('Portable Network Graphics','*.png'), ('JPEG / JFIF','*.jpg'), ('CompuServer GIF','*.gif'), ] root = Tkinter.Tk() fileName = tkFileDialog.asksaveasfilename(parent=root,filetypes=myFormats ,title="Save the image as...") if len(fileName ) > 0: print "Now saving under %s" % nomFichier ## end of http://code.activestate.com/recipes/438123/ }}} 

Here is the website I got it on: http://code.activestate.com/recipes/438123-file-tkinter-dialogs/

+8
source

Take a look at this (untested): http://www.java2s.com/Code/Python/GUI-Tk/SimpleEditor.htm You just need to add an open dialog, but using the Tkinter documentation this should be easy.

0
source

I suggest you not use tkinter, but use wxwindows. I used both before with varying levels of success (I just messed around with the basics). If you decide to use wxwindows, this is a really useful website: http://www.wxpython.org/onlinedocs.php

0
source

Source: https://habr.com/ru/post/1398917/


All Articles