some script.

This commit is contained in:
luming 2023-09-18 18:07:01 +08:00
parent 5c771c6025
commit b885c4e022

22
dm.py
View File

@ -104,6 +104,7 @@ class TableWidgetExample(QMainWindow):
bottom_layout.addLayout(action_layout)
center_layout.addWidget(bottom_widget)
def initLogger(self):
logging.basicConfig(level=logging.DEBUG)
self.logger = logging.getLogger("dmuk")
@ -164,17 +165,16 @@ class TableWidgetExample(QMainWindow):
def add_data_to_table(self):
self.logger.debug("Add button clicked")
# data = [["数据1", "数据2"],
# ["数据4", "数据5"]]
# self.table.setRowCount(len(data))
#
# for row, row_data in enumerate(data):
# for col, cell_data in enumerate(row_data):
# item = QTableWidgetItem(cell_data)
# self.table.setItem(row, col, item)
# 从
# 从input_text中获取数据添加到表格中
text = self.input_text.toPlainText()
if not text.strip():
self.logger.debug("Content is empty")
return # 如果文本为空,则不添加任何行
lines = text.split('\n')
self.table.setRowCount(len(lines))
for row, line in enumerate(lines):
item = QTableWidgetItem(line)
self.table.setItem(row, 0, item)
if __name__ == "__main__":