2025年11月30日星期日

Tech Art - Week15 - PyQt

 

Result

Screen Shot

Task Review

Before doing any analysis, I first restated the assignment requirements.
In short, based on the NameGenerator we implemented in HW12, we now need to build a GUI on top of it to make it much easier to use.

Requirements Overview

Analysis

Because this homework involves PyQt GUI development, the natural tool to think of is Qt Designer.
However, since the goal of this assignment is to get used to writing PyQt code by hand, I only used Qt Designer at the beginning as a layout sketching tool to clarify the UI structure. I did not use its auto-generated UI code.

Qt Designer Interface

In HW12 we already finished almost all of the core naming logic.
For better UI support, I only added a small helper function to check whether a category has a Default rule.
So the main focus of this homework is how to design and implement the GUI. PyQt itself is already quite straightforward to use, so instead of explaining every low-level detail, I will just briefly summarize my GUI design.

Overall, I divided the window into three main vertical regions (left / center / right), plus a menu bar and a status bar, so that each part of the workflow is clearly separated:

  1. Left: Rules & Settings Panel

    • Shows the path of the currently loaded JSON rules file

    • Provides a “Load Rules…” button

    • Provides a Verbose checkbox and a status label, used to switch between simple history and verbose history display modes

  2. Center: Input Panel

    • A Category combo box for choosing the main asset category

    • An Asset Type combo box for choosing a specific subtype, or selecting [Default] to use the category’s default rule

    • A Base Name line edit for entering the base asset name

    • A “Generate Name” button which calls NameGenerator.generate_name() to generate the final asset name

  3. Right: Result & History Panel

    • At the top, a read-only field that displays the last generated name, making it easy to copy

    • In the middle, a history list. Depending on whether Verbose is checked, it shows either the simple history list or the verbose version (with full details)

    • At the bottom, a Quit button. Clicking it triggers the close event and pops up a confirmation dialog before exiting

  4. Menu Bar & Status Bar

    • The menu bar provides basic entries such as File (load rules / exit) and Help (About)

    • The status bar is used to give real-time feedback: for example, whether the rules file was loaded successfully or failed, and whether a name was generated successfully

The overall idea is: reuse all the naming logic from HW12’s NameGenerator, and only add a clean GUI layer on top.
The GUI breaks the pipeline “load rules → choose type → enter base name → show result/history” into clear visual sections, so that users can complete the same workflow without writing any code.

I also implemented a simple light-gray theme.
There is no complex visual design here—since this is a small tool, I think a clean and minimal look is the best choice.

Video Demo


P4V

P4V

没有评论:

发表评论