0

I am having trouble comprehending how to make a file dialogue with tkinter. I am trying to have a file dialogue open up once the program is running. The dialogue needs to have five buttons that the user can click looping till the user selects the "quit" button. Each button triggers a function from the file already open and executes, so on and so forth. For the life of me I cannot figure out how to make these buttons, much less have them trigger a function.

window = Tk()
window.title("Reading from a Text File")
infileName = askopenfilename()
inFile = open(infileName,"r")
fileLines = inFile.readlines()

Basically I have it reading from the file, but don't understand how to make the buttons. I am new to programming and don't know key things to look for on topics like this.

1
  • What have you tried so far? Can you show us your (minimal) code?
    – Adam Smith
    May 5, 2014 at 23:33

1 Answer 1

1

Buttons in tkinter look like this:

# from tkinter import *
Button(root_window, text="Text Goes here", command=function_goes_here)

place them on the root_window however you want to :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.