专栏首页Python爬虫与数据挖掘Python开发GUI实战:图片转换素描画工具!

Python开发GUI实战:图片转换素描画工具!

今天被这句话触动了,所以开篇分享给大家。鸡汤有毒,但有时大家却靠它激励自己继续前行!

python开发GUI

程序员的自我救赎,使用python开发性格分析工具 这篇文章,通过Python编写了GUI的性格分析工具。一位从我公众号开始结识的朋友,询问关于如何快速编写一个exe工具的问题。由于功能简单且之前无相关GUI编程基础,为了快速完成开发,我向他推荐了easygui模块。 python作为胶水语言,几乎没有不能做的事情,但个人一直觉得在GUI开发方面,python可以算作是短板了,为什么?因为性能…python的性能问题,往往出现在其他编程语言对其的鄙夷中。但不管如何python在GUI编程上,也是有大量优秀模块的。

1

tkinter

也许有些人不知道这个模块,但如果你安装python后,使用过自带的IDLE,那么你就应该了解它。tkinter作为python自带的GUI模块,IDLE便是通过该模块开发的,也是我比较喜欢的一个模块。

2

easygui

第一次了解这个模块,还是在小甲鱼的《零基础入门学习python》时学习的,它对Tkinter进行了二次封装,使得GUI操作变得更为简单,但同时也局限于表层的使用,无法自定义更优雅的实现方案。

3

wxpython

wxpython是一个Python对于wxWidgets(这是用 C++ 编写)包装后的产物,算是个流行的跨平台GUI工具包。wxpython的优势在于运行速度较快,但编写起来较为复杂,而且界面美化效果较差…当然有第三方开发的wxFormBuiler拖拽编辑器,能替代部分的底层代码实现。不在乎外观但追求速度的朋友,可以考虑它。

4

PYQT5

Qt是一套跨平台的C++库,不论是C++、Java还是Python,都可以通过它来实现GUI界面的开发。PyQt5是Qt v5的一套全面的Python绑定。它实现为超过35个扩展模块,上千个实现函数。使Python能够在所有支持的平台(包括iOS和Android)上用作C++的替代开发语言。 如果你对GUI编程非常感谢兴趣,可以用心学学这个模块,但如果你只是想快速的实现一些GUI的功能,我更推荐大家学习tkinter模块,为什么?

  1. tkinter作为python默认自带的模块库,无需单独安装
  2. tkinter相比于wxpython与pyqt在制作小工具的方面,更为高效
  3. tkinter在网上存在大量的快速入门教程

tkinter实战

为了证明tkinter的方便与高效,今天来编写一个将图片转化为素描画的小工具,先给大家看看实现效果:

避坑指南

1

tktiner添加图片

大家看到,tktiner中附带了一个我的微信二维码,这里只是为了演示tkinter添加图片,没有丝毫推广的味道,哈哈…这里要注意下,tktiner在添加图片时,PhotoImage(file='tmp.gif')要求图片必须是.gif结尾的图片,否则就会报错:

_tkinter.TclError: couldn’t recognize data in image file

2

关于base64

大家看到我没有加载图片,而是通过base64提前转码好二进制文件后,再进行导入,这样我们打包的exe在使用时,就无需附带一个图片文件了!

import base64

with open('清风Python.gif','rb') as f:
    data = f.read()
img = base64.b64encode(data)
print(img)

tkinter打包

既然我们开发的是GUI工具,必须得打包成exe才更好玩啊!但是昨天有朋友反馈,打包的地方说的太粗,光看动图不知道该如何操作。那么今天我简单说下。

首先python的打包工具很多,但我一直以来比较喜欢使用pyinstaller,当然大家也可以去尝试cx_freeze、Py2exe等。

首先,我们需要安装pyinstaller:使用pip install pyinstaller。

安装完成,会在python程序根目录的Scripts文件夹下生成pyinstaller.exe。

如果在软件安装时,没有将Scripts添加至系统环境变量,需要手动添加到环境变量的PATH中,否则无法在cmd下使用该命令。

以往很正常的打包,有位朋友反馈使用相同的代码打包失败:

pyinstaller报错 找了半天才发现从python 3.6开始,enum34库不再与标准库兼容。该库也是不必要的,因此只需卸载它即可。 pip uninstall enum34 再次执行打包操作即可。

总体代码

最后附上工具的整体代码,可供大家参考:

# -*- coding: utf-8 -*-
# @Author   : 王翔
# @JianShu  : 清风Python
# @Date     : 2019/11/14 01:18
# @Software : PyCharm
# @version  :Python 3.7.3
# @File     : ChangeImage.py


from tkinter.messagebox import *
from tkinter.filedialog import *
from tkinter import *
import base64
from PIL import Image, ImageFilter, ImageOps
import os

img_bs64 = b'R0lGODlhwADBAPcAAAAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzACA/wCqAACqMwCqZgCqmQCqzACq/wDVAADVMwDVZgDVmQDVzADV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pWf4wppIoV6orRKxOeohZJbLaFITEQDBrEkNSlKrWpTF0qGjAKFk1Wh6qnyslirlMeHc7RO+WRYwwUl7T7zLQ9qBlK8WqENNQ47CfueVhh0oAnnPKncpWTTU+FVBWqEQMrUZGaFFEzhaDBeooi9YvZeFCSohQtho1bzVuJCtYSx4Tnju0JgApWuhO0Gu5wnuVjUc5KFPrgIJf+iZzkouUji2UlagDCKW1Wu7nAsmWwtnWQDDqSl5DQozyrSsleXKcZ1tUuQ7iLXZRe0k7FxZNXxjMIqXxyFqPOaZXRTcOMlOcpzA3DAAuVzVSi4l0ebe5iApHNMB4yqfDVIy37CLnfRW2LoAlRBDcgykT/EqOZEuHgLyk66/L8G5j+fYQ9AETDWUHzsJ8AaihjQINSAmO4d9noPWcFVIyUascxZAJAkBES5qIimOxN668exCt+ByKJg5IxdPJFUGEFstWanOlfj52ReWgZJbYKTkzsBM8CaTk4HS2MlmpFoFhWypmVomaztHwcVqgXJEhiMHtejErYaKvlLXO5y17+MpjDLOYxk7nMZj4zmtOs5jWzuc1ufjOc4yznOSMpIAA7'


def dodge(a, b, alpha):
    return min(int(a * 255 / (256 - b * alpha)), 255)


def draw(dir_info, blur=25, alpha=1.0):
    base_dir = os.path.dirname(os.path.abspath(__file__))
    save_file_name = os.path.join(base_dir, 'final.png')
    img = Image.open(dir_info)
    img1 = img.convert('L')  # 图片转换灰色
    img2 = img1.copy()
    img2 = ImageOps.invert(img2)
    for i in range(blur):
        img2 = img2.filter(ImageFilter.BLUR)
    width, height = img1.size
    for x in range(width):
        for y in range(height):
            a = img1.getpixel((x, y))
            b = img2.getpixel((x, y))
        img1.putpixel((x, y), dodge(a, b, alpha))
    img1.save(save_file_name)
    img1.show()


class LoginPage(object):
    def __init__(self, master=None):
        self.root = master
        self.root.geometry('%dx%d' % (450, 250))
        self.page = Frame(self.root)
        self.Dir = StringVar()
        self.Port = StringVar()
        self.path = StringVar()
        self.dir_info = StringVar()
        self.create_page()

    def create_page(self):
        self.page.grid()
        with open('tmp.gif', 'wb+') as f:
            f.write(base64.b64decode(img_bs64))
        self.photo = PhotoImage(file='tmp.gif')
        os.remove('tmp.gif')
        Label(self.page, text='''

        公众号: 清风Python
        作者  : 王翔 
        时间  :2019-11-14
        工具  :Python 3. 7. 3 Tkinter        
        详情  : 图片转素描画工具''', justify=LEFT).grid(row=0, column=0, columnspan=2, rowspan=1, stick=NW)
        Label(self.page, text="图片路径").grid(row=3, column=0, sticky=W, pady=5)
        self.dir_info = Entry(self.page, textvariable=self.path)
        self.dir_info.grid(row=3, column=1, columnspan=1, padx=20)
        Button(self.root, text="选择路径", command=lambda: self.select_path()).grid(row=0, column=0, sticky=S, padx=20,
                                                                                pady=5)
        Label(self.page, image=self.photo).grid(row=0, column=2)
        Button(self.page, text='转换', command=self.login_check, width=10).grid(row=3, column=2, padx=10, pady=5)

    def select_path(self):
        path_ = askopenfilename(filetypes=[("file", "*.*")])
        self.path.set(path_)

    def login_check(self):
        img_dir = self.dir_info.get()
        if img_dir == "":
            showinfo(title='错误', massage='路径错误')
        else:
            draw(img_dir)


root = Tk()
root.title('素描画转化工具')
LoginPage(root)
root.mainloop()

本文分享自微信公众号 - Python爬虫与数据挖掘(crawler_python)

原文出处及转载信息见文内详细说明,如有侵权,请联系 yunjia_community@tencent.com 删除。

原始发表时间:2019-11-30

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • 手把手教你使用Python打造一个智能搜索淘宝商品,生成操作日志的系统

    随着网购的兴起,使得很多传统店铺转型做线上生意,电子商务的产生极大便利了我们的生活。

    Python进阶者
  • 一篇文章教会你用Python多线程获取小米应用商店App

    小米应用商店给用户发现最好的安卓应用和游戏,安全可靠,可是要下载东西要一个一个的搜索太麻烦了。而已速度不是很快。

    Python进阶者
  • 手把手教你利用Python网络爬虫获取链家网的房产信息

    随着人们生活方式的的提高,房子成为了我们必不可少的一部分。而网上的信息太过于复杂,为了了解最近房价的变化趋势。小编以链家这个网站为例,抓取房价的信息。

    Python进阶者
  • python自学成才之路 类详细用法

    python是一门面向对象编程的语言,python的类和java中的类思想上有很多一样的地方,比如python类也是通过class修饰,里面也有成员属性,成员方...

    我是李超人
  • Python GUI项目实战(一)登录窗体的设计与实现

    前面我们学习了Python GUI 图型化界面Tkinter的基础知识,为了检测我们的学习成果,学以致用。我们从今天开始做一个综合Tkinter案例--基于Tk...

    小雨编程
  • PyQt5 字体/颜色/打印/打印预览对话框

    用户6021899
  • Loxodon.Framework.XLua

    Loxodon.Framework.XLua 是一个XLua的开源的MVVM框架,它做为Unity3D的MVVM框架Loxodon.Framework的插件来使...

    Loxodon Studio
  • Backtrader量化平台教程(七)Optimizer

    AD:(本人录制的backtrader视频课程,大家多多支持哦~ https://edu.csdn.net/course/detail/9040)       

    钱塘小甲子
  • ReactiveCocoa,最受欢迎的iOS函数响应式编程库(2.5版),没有之一!

    简介 项目主页: ReactiveCocoa 实例下载: https://github.com/ios122/ios122 简评: 最受欢迎,最有价值的iOS响...

    ios122
  • 小蛇学python(2)两百行代码实现旅游中国34座大城市最短路径

    直接说基础语法,也许大家不会感兴趣。前言之后的这一章,给大家介绍一下我最近写出来的一个小功能。用python语言实现GA算法来解决TSP问题,希望以此来激发大家...

    用户2145057

扫码关注云+社区

领取腾讯云代金券