Python Forum
[Tkinter] Tkinter - I need to read file excel from GUI app to script file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Tkinter - I need to read file excel from GUI app to script file
I have an app by Tkinter this is my code :

import os
from tkinter import *
from tkinter import ttk
from tkinter import filedialog

root = Tk()
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
print(path) # PATH EXCEL


def read_excel():
    return path # FilePaht

def start_app():
    print('app running')
    os.system('python ..\\Tests\\')


Seconde file :

I need to add function to import FilePath and use it in my script:

Like change Path = "../Resources/KDP.xlsx" and add Path = FilePath

import openpyxl
Path = "../Resources/t.xlsx"  # EXCEL
wb = openpyxl.load_workbook(Path)
sheet = wb['sheet']
firstcell = sheet["A2"].value

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] It it possible to make a help file explorer with tkinter? Clunk_Head 0 470 Aug-07-2021, 06:02 PM
Last Post: Clunk_Head
  [PyGUI] Python Application Not Finding Excel File dseals26 2 960 Feb-17-2021, 01:45 AM
Last Post: thewolf
  [Tkinter] Python - Tkinter : How can I send path Excel from GUI to scripte johnjh 2 1,957 Aug-28-2020, 05:38 PM
Last Post: maaad
  Import a file and show file name on qcombobox GMCobraz 1 791 Jul-02-2020, 01:38 PM
Last Post: GMCobraz
  [Tkinter] Override the paste function(copy from excel file - paste in separate tkinter entryes) AndreiV 3 1,930 Jun-05-2020, 04:46 PM
Last Post: AndreiV
  [Tkinter] Tkinter - I have problem after import varaible or function from aGUI to script johnjh 2 1,201 Apr-17-2020, 08:12 PM
Last Post: johnjh
  python file(.py) not working with my tkinter project DeanAseraf1 9 3,805 Mar-22-2020, 10:58 PM
Last Post: ifigazsi
  [PyQt] Import Excel file and use pandas WBPYTHON 2 3,004 Mar-22-2020, 11:28 AM
  [PyQt] How to run Ubuntu desktop AppImage file from script? jungx148 0 712 Mar-17-2020, 10:36 AM
Last Post: jungx148
  [Tkinter] Problem with tkinter when creating .exe file Jan_97 2 2,560 Feb-27-2020, 05:17 PM
Last Post: Jan_97

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020