dm/dm.py
2023-09-09 20:31:45 +08:00

78 lines
2.3 KiB
Python

import sys
from PySide6 import QtWidgets
from PySide6.QtWidgets import QApplication, QMainWindow, QTableWidget, QTableWidgetItem, QVBoxLayout, QWidget, \
QTextEdit
class TableWidgetExample(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setWindowTitle("弹幕采集")
self.setGeometry(100, 100, 800, 600)
central_widget = QWidget()
center_layout = QVBoxLayout(central_widget)
# central_widget.setLayout(center_layout)
self.setCentralWidget(central_widget)
top_widget = QWidget()
top_layout = QVBoxLayout(top_widget)
table = QTableWidget()
table.setColumnCount(2)
table.setHorizontalHeaderLabels(["URL", "状态"])
header = table.horizontalHeader()
header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
header.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
data = [
["https://baidu.com", "队列中"],
["https://google.com", "队列中"],
["https://rainss.cn", "队列中"],
["https://baidu.com", "队列中"],
["https://google.com", "队列中"],
["https://rainss.cn", "队列中"],
["https://baidu.com", "队列中"],
["https://google.com", "队列中"],
["https://rainss.cn", "队列中"],
["https://baidu.com", "队列中"],
["https://google.com", "队列中"],
["https://rainss.cn", "队列中"]
]
table.setRowCount(len(data))
for row, rowData in enumerate(data):
for col, value in enumerate(rowData):
item = QTableWidgetItem(value)
table.setItem(row, col, item)
top_layout.addWidget(table)
center_layout.addWidget(top_widget)
# 下部分布局
bottom_widget = QWidget()
bottom_widget.setFixedHeight(200)
bottom_layout = QVBoxLayout(bottom_widget)
input_text = QTextEdit()
bottom_layout.addWidget(input_text)
center_layout.addWidget(bottom_widget)
# 按钮部分
if __name__ == "__main__":
app = QApplication(sys.argv)
window = TableWidgetExample()
window.show()
sys.exit(app.exec())