当前位置:网站首页>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 .
边栏推荐
- Camunda 1、Camunda工作流-介绍
- 水一篇图的拓扑排序
- 哈夫曼树以及哈夫曼编码在文件压缩上的应用
- C语言 N皇后问题
- redis的基本使用
- 京东云金秋上云特惠进行中!扫码参与活动
- 【赛事预告】云上开发,高效智能——第二届阿里云ECS CloudBuild开发者大赛即将启动
- 题解:在一个排序数组中查找元素第一个和最后一个的位置 (个人笔记)
- The road to success in R & D efficiency of 1000 person Internet companies
- Live broadcast Preview: integration of JD cloud Devops and jfrog product library
猜你喜欢

365 day challenge leetcode 1000 questions - day 039 full binary tree inserter + find peak II + snapshot array

【C语言系列】—三种方法模拟实现strlen库函数的方法

阿里云联合鼎捷软件发布云上数字工厂解决方案,实现云MES系统本地化部署

Live broadcast preview | how to improve enterprise immunity through "intelligent edge security"?

Cmu15-213 malloc lab experiment record

365天挑战LeetCode1000题——Day 036 二叉树剪枝 + 子数组和排序后的区间和 + 删除最短的子数组使剩余数组有序

平行云CEO 李岩:CloudXR ,开启通往元宇宙的通道

Thousands of databases, physical machines all over the country, JD logistics full volume cloud live record | interview with excellent technical team

重定向和文件

JD cloud golden autumn cloud special offer is in progress! Code scanning participation activities
随机推荐
整数溢出和打印
Custom QML control: imagebutton
B - 识别浮点常量问题
C language file operation
C语言文件操作
Introduction to array learning simple question sum of two numbers
C语言数组入门到精通(数组精讲)
【C语言系列】—深度解剖数据在内存中的存储(一) 暑假开篇
Cmu15-213 malloc lab experiment record
牛客网编程题—【WY22 Fibonacci数列】和【替换空格】详解
小程序中的DOM对象元素块动态排序
365天挑战LeetCode1000题——Day 036 二叉树剪枝 + 子数组和排序后的区间和 + 删除最短的子数组使剩余数组有序
阿里云架构师梁旭:MES on 云盒,助力客户快速构建数字工厂
Live broadcast preview | how to improve enterprise immunity through "intelligent edge security"?
EXIT中断详解
题解:在一个排序数组中查找元素第一个和最后一个的位置 (个人笔记)
R & D efficiency | analysis of kubernetes' core technology and Devops' landing experience
MySQL的详细安装使用教程(保姆式安装图文讲解)
【赛事预告】云上开发,高效智能——第二届阿里云ECS CloudBuild开发者大赛即将启动
Day 2