•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 392,038 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,329 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser:
Views: 483 | Replies: 3
![]() |
•
•
Join Date: Feb 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Hello,
I'm using a askdialog box from tkinter with a form. My problem is when I use "print" or "return" to get the selected directory it prints it to the terminal (if open) and I would like it to print to an Entry textbox. For example:
I feel like this should be pretty easy but can't seem a way to figure it out. I'm new to Python and taking the learn-as-I-go approach. Any help would be much appreciated.
- RagS
I'm using a askdialog box from tkinter with a form. My problem is when I use "print" or "return" to get the selected directory it prints it to the terminal (if open) and I would like it to print to an Entry textbox. For example:
Python Syntax (Toggle Plain Text)
from Tkinter import * from tkFileDialog import askdirectory root = Tk() e1 = Entry(root) def browser(): dir1 = askdirectory(title="Select A Folder", mustexist=1) if len(dir1) > 0: print dir1 ###<----------I would like this "dir1" to print into the "e1" Entry above Button(root, text='Browse', command=browser) root.mainloop()
I feel like this should be pretty easy but can't seem a way to figure it out. I'm new to Python and taking the learn-as-I-go approach. Any help would be much appreciated.
- RagS
Last edited by +--RagS--+ : Feb 15th, 2008 at 3:52 pm.
•
•
Join Date: Dec 2006
Posts: 384
Reputation:
Rep Power: 2
Solved Threads: 52
You want to use .set() but it must be with a Tkinter control variable. Look for the paragraph that starts with "For example, you could link an Entry widget to a Label widget" and the "Entry" paragraph at this link. The New Mexico Tech Tkinter pages are well done.
http://infohost.nmt.edu/tcc/help/pub...variables.html
http://infohost.nmt.edu/tcc/help/pub...variables.html
•
•
Join Date: Oct 2004
Location: Mojave Desert
Posts: 2,394
Reputation:
Rep Power: 9
Solved Threads: 172
Here is one way to do this ...
python Syntax (Toggle Plain Text)
from Tkinter import * from tkFileDialog import askdirectory def browser(): dir1 = askdirectory(title="Select A Folder", mustexist=1) if len(dir1): #print dir1 e1.insert(0, dir1) root = Tk() e1 = Entry(root) e1.pack() b1 = Button(root, text='Browse', command=browser) b1.pack() root.mainloop()
May 'the Google' be with you!
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Python Marketplace
Similar Threads
- Drawing a moving circle with Python Tkinter + good GUI tutorial (Python)
- tkinter calendar (Python)
- Something similar to def in Tkinter (Python)
- Loading a Tkinter Listbox (Python)
- Tkinter exception (Python)
- Tkinter: protecting text in the Entry widget (Python)
Other Threads in the Python Forum
- Previous Thread: help with mysql bindings
- Next Thread: Keeping track of time



Linear Mode