In my code I'm very confused why on button press my labels disappear after the next button press. What I'm trying to do is get the file path + file name to stay on the interface after button click
The first part goes over the open_file commands that will operate on button click. The next part goes over the file labels, and the final part are the actual buttons.
# Import the required libraries
from tkinter import *
from tkinter import ttk
from PIL import Image, ImageTk
import tkinter.filedialog as fd
import pandas as pd
import csv
import os
# Create an instance of tkinter frame or window
win = Tk()
# Set the geometry of tkinter frame
win.geometry("700x350")
# Choose a Trace File window
def open_file():
file = fd.askopenfilename(parent=win, title='Choose a Trace File')
print(win.splitlist(file))
# Display file path
file_label.config(text=file)
file_label.place(relx = 0.59, rely = 0.77)
# Display file name
fullpath = file
just_the_name = os.path.basename(fullpath)
file_label2.config(text=just_the_name)
file_label2.place(relx = 0.7, rely = 0.8)
# Choose a Supplementary File window
def open_file2():
file = fd.askopenfilename(parent=win, title='Choose a Supplementary File')
print(win.splitlist(file))
file_label.config(text=file)
file_label.place(relx = 0.59, rely = 0.77)
fullpath = file
just_the_name = os.path.basename(fullpath)
file_label2.config(text=just_the_name)
file_label2.place(relx = 0.7, rely = 0.8)
# File Path and File Name labels
file_label = Label(win, text="")
file_label.pack()
file_label2 = Label(win, text="")
file_label2.pack()
# Add a Button Widget
# Add file path and file name next to button when clicked
btn1 = ttk.Button(win, text="Select the Trace File", command=open_file).pack()
btn2 = ttk.Button(win, text="Select the Supplementary File", command=open_file2).pack()
btn3 = ttk.Button(win, text="Select the Output File", command=convert_file).pack()
win.mainloop()
I would appreciate any help in trying to figure out how to get these labels to stick.

