Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9249591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:14:10+00:00 2026-06-18T10:14:10+00:00

Hi I am trying to create a tool that browses a time machine image

  • 0

Hi I am trying to create a tool that browses a time machine image with Tkinter in python. I plan on using the code from here: http://code.google.com/p/python-ttk/source/browse/trunk/pyttk-samples/dirbrowser.py?r=21 for the directory browser. I have written a start menu and upon clicking on the ‘browse’ button I want the directory browser to open where the user can select a file and the path is then passed back to the Label (I need to add this as its not in the directory browser code yet). Below is the code for my start menu:

#!/usr/bin/python

from Tkinter import *
import ttk

class App:

    def __init__(self,master):

        frame = Frame(master)
        frame.pack()

        self.label = Label(frame, text="Please enter file path or browse to a file")
        self.label.pack(side=TOP)

        self.button = Button(frame, text="OK", command=messageWindow)
        self.button.pack(side=BOTTOM)

        self.hi_there = Button(frame, text="Browse")
        self.hi_there.pack(side=BOTTOM)

        self.entry = Entry(frame, width = 30)
        self.entry.pack(side=LEFT)

root = Tk()

app = App(root)

root.mainloop()

I have read that you cannot have two root frames at once with Tkinter but I am struggling to find an alternative as the directory browser also has a root frame. I am not sure if what I am doing is correct but on the button for browse I have added:

 self.hi_there = Button(frame, text="Browse", command=dir)

I have put the directory browser code inside of a class and called it dir. So my thinking is that I should be calling the entire class? But then I get an error stating that the name dir is not defined. What ways can I go about getting this right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:14:11+00:00Added an answer on June 18, 2026 at 10:14 am

    I don’t quite understand what you mean by “a time machine image”, but I’ve got a few things that might help you: don’t use the variable name dir, as that’s a builtin keyword and you’re bound to run into problems. If you’re having trouble finding the method called dir which is inside a class, make sure you’re telling it to look inside the class.

        def sayHello():
            print "Hello!"
    
    
        class Person:
    
            def sayHello():
                print "Hello from Person"
    
        a_person = Person()
    
        sayHello() 
        ##"Hello"
    
        a_person.sayHello()
        ## "Hello from Person"
    

    Calling printHello and class_instance.printHello are two different functions, and you’ll want to pass class_instance.dir to the button.

    I’m sure you know about them, but there are premade file dialogs to help with getting filepaths, filenames etc.

    Another thing is you don’t want a new root instance, you’re looking for a new TopLevel instance, which is essentially the same thing as a new root, but not quite.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a tool that can generate XSDs for the XAML produced
Ok so I am trying create a login script, here I am using PHP5
I'm trying to create a tool that converts the dynamic DHCP-provided IPv4 address, gateway
I'm trying to think of a way that prevents others from using your published
I am trying to create a tool that will draw a shape in openGL
I'm trying to create a T4 template which inherits from another one that is
I am trying to create a simple python script that deploys my EAR file
I'm trying to create a tool that can estimate how many days a project
I am trying to create a import tool that would read the csv file
First, context: I'm trying to create a command-line-based tool (Linux) that requires login. Accounts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.