質問編集履歴
1
イメージ画像変更&コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
ログ機能っぽく過去のテキストを残した上で文字列を追加出力したい。
|
4
4
|
|
5
|
-
![イメージ説明](
|
5
|
+
![イメージ説明](31840b2765b11f619c232bb554c6381c.png)
|
6
6
|
|
7
7
|
|
8
8
|
|
@@ -16,8 +16,66 @@
|
|
16
16
|
|
17
17
|
```python
|
18
18
|
|
19
|
+
# -*- coding: utf-8 -*-
|
20
|
+
|
21
|
+
"""
|
22
|
+
|
23
|
+
Created on Tue Jun 16 19:37:35 2020
|
24
|
+
|
25
|
+
プログラムmemo
|
26
|
+
|
27
|
+
note : Qt desinerでMainWindowでguiを作成したのでUi_Formと異なる
|
28
|
+
|
29
|
+
note: importした.pyファイル上のオブジェクトを呼び出すときはクラス名を付けること
|
30
|
+
|
31
|
+
@author: asahi
|
32
|
+
|
33
|
+
"""
|
34
|
+
|
35
|
+
import os
|
36
|
+
|
37
|
+
import sys
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
from PyQt5 import QtWidgets,QtCore
|
42
|
+
|
43
|
+
from PyQt5.QtWidgets import QMainWindow
|
44
|
+
|
45
|
+
from AK003_V1001ui_debug import Ui_MainWindow
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
class AK003(QMainWindow, Ui_MainWindow):
|
52
|
+
|
53
|
+
def __init__(self,parent=None):
|
54
|
+
|
55
|
+
super(AK003, self).__init__(parent)
|
56
|
+
|
57
|
+
self.ui = Ui_MainWindow()
|
58
|
+
|
59
|
+
self.ui.setupUi(self)
|
60
|
+
|
61
|
+
#listviewのモデル作成
|
62
|
+
|
63
|
+
self.list_model = QtCore.QStringListModel()
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
19
75
|
def click_execute(self):
|
20
76
|
|
77
|
+
#code_text解析処理
|
78
|
+
|
21
79
|
#code textの文字列取得
|
22
80
|
|
23
81
|
code = self.ui.plainTextEdit_code_text.toPlainText()
|
@@ -26,10 +84,166 @@
|
|
26
84
|
|
27
85
|
self.ui.plainTextEdit_result.setPlainText(code+"\n")
|
28
86
|
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
pass
|
92
|
+
|
93
|
+
#メイン関数
|
94
|
+
|
95
|
+
if __name__ == '__main__':
|
96
|
+
|
97
|
+
app = QtWidgets.QApplication(sys.argv)
|
98
|
+
|
99
|
+
window = AK003()
|
100
|
+
|
101
|
+
window.show()
|
102
|
+
|
103
|
+
sys.exit(app.exec_())
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
29
109
|
```
|
30
110
|
|
31
111
|
|
32
112
|
|
113
|
+
|
114
|
+
|
115
|
+
importしたuiファイルのコードは以下です
|
116
|
+
|
117
|
+
```python
|
118
|
+
|
119
|
+
# -*- coding: utf-8 -*-
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
# Form implementation generated from reading ui file 'AK003_V1001ui_debug.ui'
|
124
|
+
|
125
|
+
#
|
126
|
+
|
127
|
+
# Created by: PyQt5 UI code generator 5.9.2
|
128
|
+
|
129
|
+
#
|
130
|
+
|
131
|
+
# WARNING! All changes made in this file will be lost!
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
from PyQt5 import QtCore, QtGui, QtWidgets
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
class Ui_MainWindow(object):
|
140
|
+
|
141
|
+
def setupUi(self, MainWindow):
|
142
|
+
|
143
|
+
MainWindow.setObjectName("MainWindow")
|
144
|
+
|
145
|
+
MainWindow.resize(490, 294)
|
146
|
+
|
147
|
+
self.centralwidget = QtWidgets.QWidget(MainWindow)
|
148
|
+
|
149
|
+
self.centralwidget.setObjectName("centralwidget")
|
150
|
+
|
151
|
+
self.plainTextEdit_code_text = QtWidgets.QPlainTextEdit(self.centralwidget)
|
152
|
+
|
153
|
+
self.plainTextEdit_code_text.setGeometry(QtCore.QRect(60, 50, 161, 141))
|
154
|
+
|
155
|
+
self.plainTextEdit_code_text.setObjectName("plainTextEdit_code_text")
|
156
|
+
|
157
|
+
self.pushButton__execute = QtWidgets.QPushButton(self.centralwidget)
|
158
|
+
|
159
|
+
self.pushButton__execute.setGeometry(QtCore.QRect(60, 210, 111, 23))
|
160
|
+
|
161
|
+
font = QtGui.QFont()
|
162
|
+
|
163
|
+
font.setFamily("Segoe UI")
|
164
|
+
|
165
|
+
self.pushButton__execute.setFont(font)
|
166
|
+
|
167
|
+
self.pushButton__execute.setObjectName("pushButton__execute")
|
168
|
+
|
169
|
+
self.plainTextEdit_result = QtWidgets.QPlainTextEdit(self.centralwidget)
|
170
|
+
|
171
|
+
self.plainTextEdit_result.setGeometry(QtCore.QRect(250, 50, 161, 141))
|
172
|
+
|
173
|
+
self.plainTextEdit_result.setObjectName("plainTextEdit_result")
|
174
|
+
|
175
|
+
self.label_3 = QtWidgets.QLabel(self.centralwidget)
|
176
|
+
|
177
|
+
self.label_3.setGeometry(QtCore.QRect(300, 30, 71, 16))
|
178
|
+
|
179
|
+
font = QtGui.QFont()
|
180
|
+
|
181
|
+
font.setFamily("Segoe UI")
|
182
|
+
|
183
|
+
self.label_3.setFont(font)
|
184
|
+
|
185
|
+
self.label_3.setObjectName("label_3")
|
186
|
+
|
187
|
+
self.label_4 = QtWidgets.QLabel(self.centralwidget)
|
188
|
+
|
189
|
+
self.label_4.setGeometry(QtCore.QRect(60, 30, 71, 16))
|
190
|
+
|
191
|
+
font = QtGui.QFont()
|
192
|
+
|
193
|
+
font.setFamily("Segoe UI")
|
194
|
+
|
195
|
+
self.label_4.setFont(font)
|
196
|
+
|
197
|
+
self.label_4.setObjectName("label_4")
|
198
|
+
|
199
|
+
MainWindow.setCentralWidget(self.centralwidget)
|
200
|
+
|
201
|
+
self.menubar = QtWidgets.QMenuBar(MainWindow)
|
202
|
+
|
203
|
+
self.menubar.setGeometry(QtCore.QRect(0, 0, 490, 21))
|
204
|
+
|
205
|
+
self.menubar.setObjectName("menubar")
|
206
|
+
|
207
|
+
MainWindow.setMenuBar(self.menubar)
|
208
|
+
|
209
|
+
self.statusbar = QtWidgets.QStatusBar(MainWindow)
|
210
|
+
|
211
|
+
self.statusbar.setObjectName("statusbar")
|
212
|
+
|
213
|
+
MainWindow.setStatusBar(self.statusbar)
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
self.retranslateUi(MainWindow)
|
218
|
+
|
219
|
+
self.pushButton__execute.clicked.connect(MainWindow.click_execute)
|
220
|
+
|
221
|
+
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
def retranslateUi(self, MainWindow):
|
226
|
+
|
227
|
+
_translate = QtCore.QCoreApplication.translate
|
228
|
+
|
229
|
+
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
|
230
|
+
|
231
|
+
self.pushButton__execute.setText(_translate("MainWindow", "Execute"))
|
232
|
+
|
233
|
+
self.label_3.setText(_translate("MainWindow", "Result"))
|
234
|
+
|
235
|
+
self.label_4.setText(_translate("MainWindow", "input"))
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
コード
|
244
|
+
|
245
|
+
```
|
246
|
+
|
33
247
|
#質問
|
34
248
|
|
35
249
|
過去のテキストを残した上で文字列を追加出力したい場合、良い方法があればご教示いただけますと幸いです。よろしくお願いいたします。
|