from PySide2.QtWidgets import QApplication, QMainWindow, QPushButton, QPlainTextEdit, QMessageBox


def handleCalc():
    info = textEdit.toPlainText()
    #薪资20 000以上和以下的人员名单
    salary_above_20000 = ''
    salary_below_20000 = ''
    for line in info.splitlines():
        if not line.strip():
            continue
        parts = line.split(' ')
        #去掉列表中的空字符串
        parts = [p for p in parts if p]
        name,salary,age = parts
        if int(salary)>20000:
            salary_above_20000 += name + '\n'
        else:
            salary_below_20000 += name + '\n'

    QMessageBox.about(
        window,
        '统计结果',
        f'''薪资20000以上的有：\n{salary_above_20000}
        \n薪资20000以下的有：\n{salary_below_20000}'''
        )

app = QApplication([])

window = QMainWindow()
window.resize(500, 400)
window.move(350, 150)
window.setWindowTitle("薪资统计")

textEdit = QPlainTextEdit(window)
textEdit.setPlaceholderText("请输入薪资表")
textEdit.move(10, 25)
textEdit.resize(300, 350)

button = QPushButton('统计', window)
button.move(380, 80)
button.clicked.connect(handleCalc)



window.show()

app.exec_()
