小编Nic*_*ger的帖子

使用 PySimpleGui,如何让按钮起作用?

第一次尝试 PySimpleGui,想要创建一个 exec 程序,允许用户将目录/文件移动或复制到他们选择的目的地,但并不真正了解如何将操作链接到按钮。

我当前的程序如下所示:

import PySimpleGUI as sg
import shutil, errno
src = ""
dest = ""
def copy(src, dest):
    try:
        shutil.copytree(src, dest)
    except OSError as e:
        # If the error was caused because the source wasn't a directory
        if e.errno == errno.ENOTDIR:
            shutil.copy(src, dest)
        else:
            print('Directory not copied. Error: %s' % e)

#Me testing out commands in PSG
layout = [[ sg.Text("Select path from source to 
destination")],
[sg.Text("Source Folder", size=(15,1)), sg.InputText(src), 
sg.FolderBrowse()],
[sg.Text("Destination Folder", size=(15,1)), 
sg.InputText(dest), sg.FolderBrowse()],
[sg.Button("Transfer", …
Run Code Online (Sandbox Code Playgroud)

python button file-transfer python-3.x pysimplegui

4
推荐指数
1
解决办法
9281
查看次数

标签 统计

button ×1

file-transfer ×1

pysimplegui ×1

python ×1

python-3.x ×1