Fundamentals 5 min read

Python Parking Lot Management Application – Project Structure and Core Code

This article documents a Python parking lot management application, detailing its project directory layout, describing each module such as button handling, OCR, and time utilities, and presenting key pygame-based code that renders parking statistics and vehicle information from an Excel file.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Python Parking Lot Management Application – Project Structure and Core Code

Project Structure

The project consists of several folders and files:

datefile : stores the Excel file with vehicle information.

file : contains image assets. ic_launcher.jpg is the window’s top‑right icon, income.png is a bar chart for revenue statistics, key.txt holds the API key for Baidu image‑recognition, and test.jpg stores pictures captured from the camera.

venv : the virtual environment with required Python modules.

btn.py : button module.

main.py : main program file.

ocrutil.py : license‑plate recognition module.

timeutil.py : time‑handling utilities.

Main Code

<code># 车位文字
def text1(screen):
    # 剩余车位
    k = Total - carn
    if k < 10:
        # 剩余车位
        sk = '0' + str(k)
    else:
        sk = str(k)
    # 使用系统字体
    xtfont = pygame.font.SysFont('SimHei', 20)
    # 重新开始按钮
    textstart = xtfont.render('共有车位:' + str(Total) + '  剩余车位:' + sk, True, WHITE)
    # 获取文字图像位置
    text_rect = textstart.get_rect()
    # 设置文字图像中心点
    text_rect.centerx = 820
    text_rect.centery = 30
    # 绘制内容
    screen.blit(textstart, text_rect)

# 停车场信息表头
def text2(screen):
    # 使用系统字体
    xtfont = pygame.font.SysFont('SimHei', 15)
    # 重新开始按钮
    textstart = xtfont.render('  车号       时间    ', True, WHITE)
    # 获取文字图像位置
    text_rect = textstart.get_rect()
    # 设置文字图像中心点
    text_rect.centerx = 820
    text_rect.centery = 70
    # 绘制内容
    screen.blit(textstart, text_rect)
    pass

# 停车场车辆信息
def text3(screen):
    # 使用系统字体
    xtfont = pygame.font.SysFont('SimHei', 12)
    # 获取文档表信息
    cars = pi_table[['carnumber', 'date', 'state']].values
    # 页面就绘制10辆车信息
    if len(cars) > 10:
        cars = pd.read_excel(path + '停车场车辆表.xlsx', skiprows=len(cars) - 10, sheet_name='data').values
    # 动态绘制y点变量
    n = 0
    # 循环文档信息
    for car in cars:
        n += 1
        # 车辆车号 车辆进入时间
        textstart = xtfont.render(str(car[0]) + '   ' + str(car[1]), True, WHITE)
        # 获取文字图像位置
        text_rect = textstart.get_rect()
        # 设置文字图像中心点
        text_rect.centerx = 820
        text_rect.centery = 70 + 20 * n
        # 绘制内容
        screen.blit(textstart, text_rect)
    pass</code>

Implementation Effect

The application displays the total number of parking spaces, remaining spaces, and a list of vehicles with their entry times, as shown in the screenshots below.

Project Structure Image
Project Structure Image
Implementation Effect Image
Implementation Effect Image

*Disclaimer: This article is compiled from online sources; copyright belongs to the original author. If any information is incorrect or infringes rights, please contact us for removal or authorization.

GUIData ProcessingOCRexcelPygameparking
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.