Skip to content

November 2020

Use Python PIL module to merge two images

Last Updated on 2020-11-30 by Clay


Introduction

Recently, because I have been studying the interface of the program, I got many strange problems.

I want to record today is how to merge two pictures. I found that if I simply use the composite() function in PIL, the second picture will be overwritten by the first picture. So, I started to try convert the background of the second picture to transparent.

After converting the image to a transparent background, the result of the merging is quite natural to me.

I will start to introduce how to merge two pictures in below.

Read More »Use Python PIL module to merge two images

[Solved][Python] AttributeError: module 'win32ctypes.pywin32.win32api' has no attribute 'error'

Last Updated on 2020-11-24 by Clay

python
Display Python code on the screen

Introduction

Today I used PyInstaller to package my Python program to execute file on Windows, I got an error message:

AttributeError: module 'win32ctypes.pywin32.win32api' has no attribute 'error'

After I searching some information on Internet, I found it is a common problem about icon picture of our GUI program. The icon need to use the .ico file, but I use a .png file.

This icon is on the computer desktop dock, not the icon on the program window.

Read More »[Solved][Python] AttributeError: module 'win32ctypes.pywin32.win32api' has no attribute 'error'

[PyQt5] Use icon from QStyle

Last Updated on 2020-11-22 by Clay

PyQt5

Introduction

When we using PyQt5 framework to develop a GUI program, we usually need some icon to display our buttons or components. Many times we can load pictures from outside, but if we need common icons, such as play icon, close icon, minimum icon ... etc, we can use the built-in icon picture from QStyle module.

This has another advantage: we don't have to worry about pictures when packing the GUI program.

Below I will introduce how to use the icons in QStyle.

Read More »[PyQt5] Use icon from QStyle

How to use Pickle module to store data in Python

Last Updated on 2020-11-18 by Clay

Python is the most popular programming language!

Introduction

Hello! Today I want to record the "pickle" module in Python. The "pickle" module is very famous module in Python, its usage is like another Python package "Json", it can compress the data and store it. If we want to load the data we store, we can easily call the "load()" function to restore our session.

Read More »How to use Pickle module to store data in Python

[Python] How to use filter() function

Last Updated on 2020-11-12 by Clay

Python is the most popular programming language!

Introduction

Today when I was answering a question asked by a friend, I see a filter() function in my friend's code, and my friend just asked me what was wrong with this paragraph.

This is a awkward question. I have been learning Python for two years, but I never used this function in my program.

Read More »[Python] How to use filter() function

Using Python package "ujson" to increase Json processing speed

Last Updated on 2020-11-10 by Clay

Python is the most popular programming language!

Introduction

Whatever programming language we used, we always selected Json format to store our data.

Json (JavaScript Object Notation) is a lightweight data-interchange format, and it is readable and suitable for storing data. But in Python, sometimes we have performance bottlenecks in reading Json files, especially when the files are too large.

Read More »Using Python package "ujson" to increase Json processing speed

Use Python PyInstaller to make an executable file with picture

Last Updated on 2020-11-04 by Clay

python
Display Python code on the screen

Introduction

When we used PyInstaller to create a Python program as an executable file, we usually need to display a picture in our program.

But if we used PyInstaller to make an executable file directly, we found we can't show the picture. How does we solve this problem?

Read More »Use Python PyInstaller to make an executable file with picture