Python Forum
[Tkinter] tkinter How to pass label fiilename to another module? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [Tkinter] tkinter How to pass label fiilename to another module? (/thread-25992.html)



tkinter How to pass label fiilename to another module? - johnjh - Apr-17-2020

This is work fine if I pass entry but I don't understand how to do it in label filename.
this is same example to pass entry to another function https://www.raspberrypi.org/forums/viewtopic.php?t=195973:

File GUI.py


import os
from tkinter import *
from tkinter import ttk
from tkinter import filedialog
 
root = Tk()
root.title("Fisrt")
ttk.Label(root, text="Add Excel File :").grid(row=0, column=0, padx=20, pady=20)
open_file = ttk.Button(root, text="Open files")
open_file.grid(row=0, column=1, columnspan=2, padx=20, pady=20)
ttk.Label(root, text="Name Excel :").grid(row=1, column=0, padx=20, pady=20)
box_red_path = ttk.Label(root, text="")
box_red_path.grid(row=1, column=1, columnspan=4, padx=20, pady=20)
stare_scripte = ttk.Button(root, text="Start")
stare_scripte.grid(row=3, column=2, columnspan=2, padx=20, pady=20)
 
def upload_excel():
    global path
    filename = filedialog.askopenfilename(title="Select a File", filetype=(("Excel", "*.xlsx"), ("Excel", "*.xls")))
 
 
path = filename
box_red_path.configure(text=path)
print(path) # PATH EXCEL
 
open_file.config(command=upload_excel)
 
def read_excel():
    return path # FilePaht
 
def start_app():
    print('app running')
    os.system('python ..\\Tests\\AllTests.py')
 
stare_scripte.config(command=start_app)
 
root.mainloop()
--------------

I need to pass label FilePaht to another module called Excel.py