我希望允许用户使用将文件夹地址复制并粘贴到pysimplegui中,然后使用该文本获取文件夹中文件的列表
import PySimpleGUI as psg
import pathlib as pl
#set the theme for the screen/window
psg.theme("LightPurple")
#define layout
layout=[[psg.Text("Folder Address",size=(15, 1), font='Lucida',justification='right'),psg.Input()],
[psg.Button("SAVE", font=("Times New Roman",12)),psg.Button("CANCEL", font=("Times New Roman",12))]]
#Define Window
win =psg.Window("Data Entry",layout)
#Read values entered by user and pass that input to a windows path
v=win.read()
d = pl.WindowsPath(v)# I'm pretty sure this is where I'm going wrong.
#close first window
win.close()
#define layout for second windows to display data entered by user in first window
layout1=[[psg.Text("The data you entered is :", size=(20,1), font='Lucida', text_color='Magenta')],
[psg.Text(str([e for e in dir_path.iterdir()]), font='Lucida', text_color='Blue')]]
#Define Window and display the layout to print output
win1=psg.Window("Output Screen",layout1)
e,v=win1.read()
#close second window
win1.close()
我很乐意使用格式等,但如果有人有任何见解(或pysimplegui的良好教程),我将不胜感激
创建窗口布局后,在事件循环中等待键盘或鼠标输入的事件。一次又一次,直到窗口关闭或脚本结束
您可以在一个窗口中完成所有操作,修改代码如下。对于长输出,请在此处使用
sg.Multiline
相关问题 更多 >
编程相关推荐