User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Feb 2008
Posts: 2
Reputation: +--RagS--+ is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
+--RagS--+ +--RagS--+ is offline Offline
Newbie Poster

Anyone good with Tkinter??

  #1  
Feb 15th, 2008
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:

  1. from Tkinter import *
  2. from tkFileDialog import askdirectory
  3.  
  4. root = Tk()
  5.  
  6. e1 = Entry(root)
  7.  
  8. def browser():
  9. dir1 = askdirectory(title="Select A Folder", mustexist=1)
  10. if len(dir1) > 0:
  11. print dir1 ###<----------I would like this "dir1" to print into the "e1" Entry above
  12.  
  13. Button(root, text='Browse', command=browser)
  14.  
  15. 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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2006
Posts: 384
Reputation: woooee is on a distinguished road 
Rep Power: 2
Solved Threads: 52
woooee woooee is offline Offline
Posting Whiz

Re: Anyone good with Tkinter??

  #2  
Feb 15th, 2008
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
Reply With Quote  
Join Date: Oct 2004
Location: Mojave Desert
Posts: 2,394
Reputation: vegaseat will become famous soon enough vegaseat will become famous soon enough 
Rep Power: 9
Solved Threads: 172
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
Kickbutt Moderator

Re: Anyone good with Tkinter??

  #3  
Feb 16th, 2008
Here is one way to do this ...
  1. from Tkinter import *
  2. from tkFileDialog import askdirectory
  3.  
  4. def browser():
  5. dir1 = askdirectory(title="Select A Folder", mustexist=1)
  6. if len(dir1):
  7. #print dir1
  8. e1.insert(0, dir1)
  9.  
  10. root = Tk()
  11.  
  12. e1 = Entry(root)
  13. e1.pack()
  14. b1 = Button(root, text='Browse', command=browser)
  15. b1.pack()
  16.  
  17. root.mainloop()
May 'the Google' be with you!
Reply With Quote  
Join Date: Feb 2008
Posts: 2
Reputation: +--RagS--+ is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
+--RagS--+ +--RagS--+ is offline Offline
Newbie Poster

Re: Anyone good with Tkinter??

  #4  
Feb 16th, 2008
Thanks you guys for such a quick response. It totally worked!!! I couldn't get the insert() to work but I'm sure it was just a mistake on my end. Setting the control variable and using get() and set() did the trick. If only all forums worked this well...

- RagS
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Python Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Python Forum

All times are GMT -4. The time now is 11:09 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC