当前位置:网站首页>Pyqt based grouping tool
Pyqt based grouping tool
2022-07-28 04:26:00 【Ran Ran Ran_】
be based on PyQt Grouping tool
Function description : Group the existing student list , As a result, groups appear .
( It is similar to drawing lots and grouping
Why should I do this :
A friend needs to organize a competition , Need to put 16 People are divided into 4 Group , But the organizer doesn't want the results of the four groups to come out at the same time . It needs to be displayed in groups .( Why ?
However, geese's current small program is crisp, and directly displays the results of grouping .
So I simply wrote this grouping tool . Follow up optimization of custom grouping .
One 、 Group core code writing
1、 Code
import random
# Member list
list_stu = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16"]
# Sort the list by random number function
random.shuffle(list_stu)
n = 4 # Divide into n Group
m = int(len(list_stu) / n) # Number of members per group
list_fz = [] # Create a group list
for i in range(0, len(list_stu), m):
list_fz.append(list_stu[i:i + m])
# Loop through the nested list
for i in range(len(list_fz)):
print(" The first %d Group list :" % (i + 1), end=" ")
for stu in list_fz[i]:
print(stu, end=" ")
print()
print()
2、 Running results

Two 、GUI Interface grouping code writing
1、 Code
import sys
import random
from PyQt5.QtWidgets import QMainWindow, QPushButton, QApplication, QLabel, QMessageBox
from PyQt5.QtWidgets import QDesktopWidget
from PyQt5.QtCore import Qt
class Example(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.resize(1000, 500)
# Set title
self.setWindowTitle(' Grouping tool ')
# Set center
self.center()
# Create button
btn1 = QPushButton(" grouping ", self)
btn1.move(450, 400)
# establish label
self.label_1 = QLabel(self)
self.label_1.move(100, 50)
self.label_1.resize(800, 50)
fz = "<p style='line-height:50px; width:100% ; white-space: pre-wrap; font-size: 35px; '> Grouping </p>";
self.label_1.setText(fz)
self.label_1.setAlignment(Qt.AlignCenter)
self.label_2 = QLabel(self)
self.label_2.move(100, 100)
self.label_2.resize(800, 250)
# Define global variables
global count
global list_fz
global members
global n
# grouping
# Student list
list_stu = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16"]
# Sort the list by random number function
random.shuffle(list_stu)
n = 4 # Divide into n Group
m = int(len(list_stu) / n) # Number of members per group
list_fz = [] # Create a group list
for i in range(0, len(list_stu), m):
list_fz.append(list_stu[i:i + m])
# Loop through the nested list
for i in range(len(list_fz)):
print(" The first %d Group list : " % (i + 1), end=" ")
for stu in list_fz[i]:
print(stu, end=" ")
print()
print()
count = 0
members = ""
btn1.clicked.connect(self.buttonClicked)
self.statusBar()
self.show()
def center(self):
qr = self.frameGeometry()
# Get the size of the main window
cp = QDesktopWidget().availableGeometry().center()
# Get the resolution of the display , Then get the position of the middle point
qr.moveCenter(cp)
# Then put the center point of your window on qr The center of
self.move(qr.topLeft())
def buttonClicked(self):
global count
global list_fz
global members
global n
count += 1
if (count > n):
msg_box = QMessageBox(QMessageBox.Information, ' error ', ' You have finished grouping !!')
msg_box.exec_()
else:
members += ' The first ' + str(count) + ' Group list :'
for stu in list_fz[count - 1]:
members += stu
members += ' '
members += '\n'
membersShow = "<p style='line-height:50px; width:100% ; white-space: pre-wrap; font-size: 25px;'>" + members + "</p>";
self.label_2.setText(membersShow)
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
2、 Running results
- Click group to start grouping , When the grouping is over, click Yes to pop up “ Group complete ” Prompt box for .

- Click to group into a list .

3、 ... and 、 take .py The file is packaged as .exe Executable file
Can be in pycharm Medium terminal Input in , You can also enter cmd Go to the command line
1、 download pyinstaller
pip install pyinstaller -i https://pypi.tuna.tsinghua.edu.cn/simple/
2、 pack
-F It is used to package all supporting files , Do not display other dependent files
-w Hide the black window of background control during the process of program operation
-n Appoint Executable file name
-i icon.ico Yes, it will be under the same directory icon.ico The file is set to the execute file icon
pyinstaller -w -F python file name .py -i Icon name .ico
Four 、 summary
I haven't touched before PyQt, Yes python The basic knowledge is not very reliable . The content is also very simple , No special thinking . Hope to make more progress in the future .
边栏推荐
- 重要的 SQL Server 函数 - 日期函数
- Slice slice
- 金仓数据库KingbaseES安全指南--5.1. 数据库的传输安全
- Security exception handling mechanism
- Kingbasees security guide of Jincang database -- 6.2. Configuration files related to authentication
- Null security and exception
- Kotlin——函数
- H. 265 web player easyplayer realizes webrtc video real-time recording function
- The unsatisfied analysis of setup and hold timing is the solution
- Kingbasees Security Guide for Jincang database -- 4 data access protection
猜你喜欢
![[untitled]](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)
[untitled]

glusterfs 文件未挂载,权限: r-s

H265/hevc noun explanation -- CTU, CTB, Cu, CB, Tu, PU, TB, Pb, LCU, slice, tile, chroma, luma, I frame, B frame, P frame

功耗:Leakage Power

ftp服务器、nfs服务器的搭建和使用

Full resolution of the use of go native plug-ins

Cookies and session

【实战】使用 Web Animations API 实现一个精确计时的时钟

Study of the Intel aria 10 Avalon mm DMA interface for PCI Express solutions User Guide

Fearless of side impact damage, Chery arize 8 fully protects the safety of passengers
随机推荐
H. 265 web player easyplayer realizes webrtc video real-time recording function
[Niuke] find 1+2+3+... +n
【day03】流程控制语句
openpose的一些个人理解
Cloud native Devops status survey questionnaire solicitation: kodelurover launched jointly with oschina
Study of the Intel aria 10 Avalon mm DMA interface for PCI Express solutions User Guide
Cyber Nuwa, how to make digital people?
ftp服务器、nfs服务器的搭建和使用
[Luogu p4590] garden party (DP set DP)
Kingbasees security guide of Jincang database -- 6.2. Configuration files related to authentication
setup和hold timing分析不满足是解决方法
重要的 SQL Server 函数 - 日期函数
将数据库拿到的数据渲染到elementUI 中的table中去
MySQL:数据类型和运算符
The unsatisfied analysis of setup and hold timing is the solution
7/27 (board) dyeing method to determine bipartite graph + find combination number (recursive formula)
"Three no's and five requirements" principle of enterprise Digitalization Construction
XML file usage and parsing
What to do when encountering slow SQL? (next)
[mathematical modeling] Based on MATLAB seismic exploration Marmousi model [including Matlab source code, 1977]