是否可以使用 python 和导入的库创建桌面应用程序?

Is it possible to create a desktop application with python and imported libraries?

我是编码初学者。我使用 python 和 windows 10

我编写了一个非常简单的代码来捕获并打开图像,然后循环匹配模板,以便使用包含所有可能答案的列表来确定该图像中的对象是什么。代码使用pyautogui和opencv:

import pyautogui
import cv2 as cv


def my_func():

    #train image
    pyautogui.screenshot("train.png") #I am looking at the picture of an animal and the robot takes a screenshot and stores it.
    train_img = cv.imread("train.png", 0) 

    #Contains all the images to iterate through
    template_list = ["apple.png", "person.png", "animal.png"]

    for i in template_list:
        #template image
        template_img = cv.imread(i,0)

        #match template
        result = cv.matchTemplate(train_img, template_img, cv.TM_CCOEFF_NORMED)
        min_val, max_val, min_loc, max_loc = cv.minMaxLoc(result)

        if max_val >= .85:
            print(i) #prints the name of the matched image
            return True

    print("could not match the train image to one of the available templates.")
    return False

预期输出仅供控制台打印:

animal.png

我想创建一个应用程序,一个 window 或任何您单击显示“运行”的按钮然后代码将 运行 的应用程序。完成后,它将显示控制台日志。

你可以用 VS Code 做到这一点,但是当代码是 运行ning 时,我看不到控制台日志(因为我需要转到图像,它会在那里截屏)并且我希望能够看到它。

所以我的问题是:

是否可以为 windows 创建桌面应用程序来执行此任务?

该应用程序可以在我以外的其他计算机上运行吗?

您是否推荐任何其他替代方案?

感谢@The Laggy Tablet,我做了一些研究,找到了 100 多个关于 Tkinter 的 youtube 视频教程,作者是 John Alder。我不确定我是否可以 post 链接,所以我不会,但是很容易找到。

它实际上非常容易使用,当你完成它并把它做成一个实际的 GUI 时,其他人可以使用它而不需要安装任何依赖项,甚至 Python。

希望这对以后的人有所帮助。干杯!