当前位置:网站首页>Pyqt5: Chapter 1, Section 1: creating a user interface using QT components - Introduction
Pyqt5: Chapter 1, Section 1: creating a user interface using QT components - Introduction
2022-07-29 05:31:00 【crystal lattices 】
Catalog
3、 ... and 、 Create a GUI The method of application
This chapter studies content :
- Show a greeting
- Use Radio Button Components
- Radio Button grouping
- Show checkbox Form options
- Show two groups checkbox Components
One 、 Introduce
Next , We will learn how to use Qt Toolbox to create a GUI Applications .Qt hold-all , abbreviation Qt, By Trolltech Developed a cross platform application UI frame , Used to develop GUI Applications . It can run on multiple platforms , Include :Windows、maxOS、Linux And other classes UNIX platform . It is sometimes often referred to as a component library , Because it refers to the design GUI Various components required , Such as :buttons、labels、textboxes、push buttons and list boxes. It includes a collection of cross platform classes , It integrates development tools and a cross platform IDE. To create a real-time application , We're going to use Python The binding of Qt hold-all , namely PyQt.
Two 、PyQt
PyQt It's a Python Bound cross platform framework , Combine all Qt and Python Characteristics of , So called PyQt, You can use Python Code calls Qt library , That is to say, it can be used Python Language writing Qt GUI Applications . let me put it another way ,PyQt You are allowed to pass Python Code access Qt All functions provided .PyQt Depend on Qt Library to run programs , So when you install PyQt when , It will also be automatically installed on your machine at the same time Qt Environmental Science .
One GUI The application may include a main window and some dialog boxes , Or just one dialog . A small GUI Applications typically include at least one dialog box . A dialog application also contains several button components . The menu bar cannot be used in the dialog box 、 The toolbar 、 status bar , Or a Central Central components , However, a main window application can contain all the above components .
There are two types of dialog boxes :
- Modal( Modality ): It is a dialog box that can prevent users from interacting with other parts of the application . Users can only operate in this dialog . Other parts cannot be operated until the dialog box is closed .
- Modeless( Modeless ): This dialog is the opposite of modal dialog . When an modeless dialog opens , Users can freely operate the dialog box and other contents in the application except this dialog box .
3、 ... and 、 Create a GUI The method of application
There are two ways to write GUI Applications :
- Start with the sketch , Use a simple text editor text editor
- Use Qt Designer, A visual design tool , It allows you to quickly create a user interface by dragging
You will be in PyQt Use in Qt Designer To develop a GUI Applications , Because it is a fast and simple way to design user interface , You don't need to write too much code . therefore , You can double-click on the desktop Qt Designer Icon open Qt Designer.
After opening ,Qt Designer You will be asked to choose a template to start your application , As shown in the figure below :

Qt Designer Some templates for different kinds of applications are provided . You can choose any template , And then click Create Button .
For new applications ,Qt Designer The following predefined templates are provided :
- Dialog with Buttons Bottom: This template will create a form , And a OK Button and a Cancel Button .
- Dialog with Buttons Right: This template will create a form , And a OK Button and a Cancel Button .
- Dialog without Buttons: This template will create an empty form , You can place components on the form . Its parent class is QDialog.
- Main Window: This template provides a main application form , It contains a menu bar and a toolbar , You can remove it if you don't need it .
- Widget: This template will create an inheritance from QWidget Class rather than QDialog Class .
every last GUI Applications have a top-level component , Other components are sub components of the top-level component . This top-level component can be QDialog、QWidget Or is it QMainWindow, You can select the corresponding template according to your needs . If you want to create an application based on dialog templates , Then the top-level component of the dialog box or its parent component needs to inherit QDialog class . Empathy , If you want to create an application based on the main form template , Then its top-level component is QMainWindow class , If you want to create one based on Widget The components of , You need to inherit from QWidget class . As mentioned above , Other components used in the user interface are subclasses of related components .
Qt Designer A menu bar and a toolbar are displayed at the top . The various components used to develop the application are grouped in the toolbox on the left . All you need to do is drag the component into the form , And put it wherever you want . You can also layout components , Set their styles , Provide the initial properties of the component , Signals and slots connecting them .
边栏推荐
猜你喜欢

Together with digital people, digital space and XR platform, Alibaba cloud and its partners jointly build a "new vision"

重定向和文件

京东云分布式链路追踪在金融场景的最佳实践

365天挑战LeetCode1000题——Day 035 每日一题 + 二分查找 13

研发效能|Kubernetes核心技术剖析和DevOps落地经验

刷题狂魔—LeetCode之剑指offer58 - II. 左旋转字符串 详解
![[event preview] cloud development, efficient and intelligent - the second Alibaba cloud ECS cloudbuild developer competition is about to start](/img/6e/6b4deeedbfd9d6baa651019f3dabfa.jpg)
[event preview] cloud development, efficient and intelligent - the second Alibaba cloud ECS cloudbuild developer competition is about to start

直播预告|如何节省30%人工成本,缩短80%商标办理周期?

【C语言系列】— 字符串+部分转义字符详解+注释小技巧

QML type: mousearea
随机推荐
C语言 N皇后问题
Best practices for elastic computing in the game industry
数组学习之入门简单题 两数之和
2022数学建模竞赛暑期培训讲座——最优化方法:目标规划
NVIDIA Zhou Xijian: the last mile from design to digital marketing
整数溢出和打印
The road to success in R & D efficiency of 1000 person Internet companies
来!看排名一年上升16位的ClickHouse,如何在京东落地实践
AiTalk创始人梁宇淇:镜像连接虚拟与现实的纽带
英伟达周锡健:设计到数字营销的最后一公里
C language first level pointer
【赛事预告】云上开发,高效智能——第二届阿里云ECS CloudBuild开发者大赛即将启动
如视技术副总裁杨永林:当传统产业遇到“数字空间”
关于局部变量
VIM editor use
Introduction to array learning simple question sum of two numbers
js深拷贝-笔记
redis的基本使用
JD cloud golden autumn cloud special offer is in progress! Code scanning participation activities
vim编辑器使用