Hello Everybodies.
I am a noobie with python. I don´t have any background in coding and i just learned python from some python youtube course. But i am interested in python coding. I´m greatfull if someone can help me with my issue
My goal is to create an application with pysimplegui. With this application i can browse to my desired folder and it will display contents within a listbox so i can pick and choose what to do with it. But right now i don´t get that result. I´m testing my code with the left hand side of listbox.
This is my code.
import os
import PySimpleGUI as pg
Step 1: Set Theme
pg.theme(“default1”)
Step 2: Create Layout
ml_folder_column = [
[
pg.Text(“ML Crown Folder”),
pg.In(size=(30, 1), enable_events=True, key="-ML FOLDER-"),
pg.FolderBrowse()
],
[
pg.Listbox(
values=[],
enable_events=True,
size=(50, 20),
key="-ML_FILE_LIST-",
)
],
[
pg.Button("Process", size=(7, 2)), pg.Button("Refresh", size=(7, 2))
]
]
ftb_folder_column = [
[
pg.Text(“FTB Folder”),
pg.In(size=(30, 1), enable_events=True, key="-FTB FOLDER-"),
pg.FolderBrowse()
],
[
pg.Listbox(
values=,
enable_events=True,
size=(50, 20),
key="-FTB_FILE_LIST-",
)
]
]
layout = [
[pg.Column(ml_folder_column),
pg.VSeparator(),
pg.vtop(pg.Column(ftb_folder_column))]
]
Step 3: Create Window
window = pg.Window(“ZIRCONIA CROWN APPLICATION”, layout)
Step 4: Event Loop
folder_location = “”
while True:
event, values = window.read()
if event == pg.WIN_CLOSED or event == "Exit":
break
elif event == "-ML Folder-":
folder_location = values["-ML FOLDER-"]
try:
files = os.walk(folder_location)
except ValueError:
files = []
file_names = [
file for file in files
if os.path.isfile(os.path.join(folder_location, file)) and file.lower().endswith((".JPEG", ".xlsx", "docs"))
]
window["-ML_FILE_LIST-"].update(file_names)
Thanks if i can get some helps.