Why Python GUIs Look Ugly and How to Make Them Beautiful
Although many developers criticize Tkinter and PyQt5 for producing unattractive interfaces, this article explains that functionality is prioritized over aesthetics, draws parallels between PyQt5 widgets and web HTML/CSS/JS components, and offers practical tips—design prototypes, leveraging QSS, and using widget properties—to dramatically improve Python desktop GUI appearance.
Functional Priority in GUI Development
Many developers complain that applications built with Tkinter or PyQt5 look ugly. The primary reason is that library authors focus on providing functional components—list boxes, drag‑and‑drop, hover widgets, custom controls, webview, etc.—rather than visual polish.
Native Components vs. Web Counterparts
To illustrate the similarity with web development, PyQt5 widgets can be loosely mapped to HTML elements:
QPushButton, QLineEdit, QCheckBox correspond to <a>, <p>, <h> tags for basic structure.
Qt Style Sheets (QSS) play the role of CSS for styling.
Signals and slots are analogous to JavaScript for interaction.
Without any CSS or JavaScript, HTML tags render in their default, unattractive form, just as a raw PyQt5 window does.
Key Points for Beautifying the Interface
A Good Design Prototype
Before coding, create a clear layout prototype—grid positions, spacing, and overall visual style. Reference popular desktop applications or UI design platforms for inspiration.
Leverage QSS
Qt provides QSS, a powerful stylesheet system that can customize widget appearance, covering 80‑90% of visual requirements. Official documentation and examples are available at:
https://doc.qt.io/qt-5/stylesheet-reference.html
https://doc.qt.io/qtforpython/overviews/stylesheet-examples.html
Use Widget‑Specific Properties
For scenarios where QSS falls short (e.g., window borders, title bar buttons), use the widget’s own methods. Example with QProgressBar: setAlignment() – set alignment. setFormat() – set text format. setInvertedAppearance() – reverse growth direction. setMaximum() – set maximum value. setMinimum() – set minimum value. setOrientation() – set horizontal or vertical layout.
These methods allow fine‑grained styling that QSS cannot achieve.
HTML Example Without Styling
<html>
<h1>州的先生</h1>
<a href="https://zmister.com"></a>
<input type="text" placeholder="表单输入框"/>
<button>一个按钮</button>
<select>
<option>一个选项</option>
<option>两个选项</option>
</select>
</html>Rendered without CSS, these elements appear plain and unattractive, mirroring the default look of Python GUI widgets.
Final Example
A fully styled PyQt5 music player demonstrates how combining a solid prototype, QSS, and widget properties can produce a polished, professional desktop application.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Python Crawling & Data Mining
Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
