some script.
This commit is contained in:
parent
5c771c6025
commit
b885c4e022
22
dm.py
22
dm.py
@ -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__":
|
||||
|
||||
Loading…
Reference in New Issue
Block a user