Dec-09-2019, 09:53 PM
(This post was last modified: Dec-09-2019, 09:53 PM by kenwatts275.)
Below is my full python program in case you cannot figure it out from the program excerpt.
When you run the program, all the frames appear on the same line.
If anybody can figure out why it does this, it would be appreciated.
When you run the program, all the frames appear on the same line.
If anybody can figure out why it does this, it would be appreciated.
from tkinter import filedialog from tkinter import * import tkinter.font as font #import tkinter as tk def show_entry_fields(): fname1 = e1.get() fname2 = e2.get() print("Input File: %s\nOutput File: %s" % (fname1, fname2)) f1 = open(fname1,"r") lines = f1.readlines() for x in lines: print(x) f1.close() def get_file1(): file1 = filedialog.askopenfilename(title = "Select file",filetypes = (("all files","*.*"),("jpeg files","*.jpg"),("python files","*.py"))) e1.delete(0,'end') e1.insert(0,file1) def get_file2(): file2 = filedialog.askopenfilename(title = "Select file",filetypes = (("all files","*.*"),("jpeg files","*.jpg"),("python files","*.py"))) e2.delete(0,'end') e2.insert(0,file2) mw = Tk() # 999x999 is size of window, 999+999 is the location of the window mw.geometry('800x400+400+200') mw.title("Test Program") frame1 = Frame(mw).pack(side=TOP,anchor=W,fill=X,expand=YES) frame2 = Frame(mw).pack(side=TOP,anchor=W,fill=X,expand=YES) framebot = Frame(mw).pack(side=BOTTOM,anchor=W,fill=X,expand=YES) w1 = Label(frame1, text="Input File: ",font=("Times",25)).pack(side=LEFT) e1 = Entry(frame1,width=25,font=("Times",25)) e1.insert(0, "infile.txt") e1.pack(side=LEFT) Button(frame1,text='Search',font=("Times",25),command=get_file1).pack(side=LEFT) w2 = Label(frame2, text="Output File: ",font=("Times",25)).pack(side=LEFT) e2 = Entry(frame2,width=25,font=("Times",25)) e2.insert(0, "outfile.txt") e2.pack(side=LEFT) Button(frame2,text='Search',font=("Times",25),command=get_file2).pack(side=LEFT) Button(framebot,text='Go',font=("Times",25),command=show_entry_fields).pack() Button(framebot,text='Exit',font=("Times",25),command=mw.quit).pack() mw.mainloop()