Код: Выделить всё
def stpFinder(source_dir):
stp_files = []
for root, dirs, files in os.walk(source_dir):
for file in files:
if file.endswith(".stp"):
stp_files.append(os.path.join(root, file))
elif file.endswith(".step"):
stp_files.append(os.path.join(root, file))
return stp_files
import PySimpleGUI as sg
import functions_new as fn
sg.theme("Default1")
input1 = sg.Input()
archive_choose = sg.FolderBrowse("Select Source Directory",
key="source",
pad=(5, 5))
input2 = sg.Input()
BOM_choose = sg.FileBrowse("Select BOM",
key="excel",
pad=(5, 5))
exec_button = sg.Button("Execute",
pad=(5, 5),
button_color=('White', 'NavyBlue'))
window = sg.Window(title="Step Name Replace",
layout=[[input1, archive_choose],
[input2, BOM_choose],
[exec_button]],
font=("Segoe UI Variable", 10))
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == "Exit":
break
stp_files = fn.stpFinder(values['source'])
print(stp_files)
window.close()
Я не знаю, откуда взялись две обратные косые черты
Подробнее здесь: https://stackoverflow.com/questions/788 ... -file-type