質問編集履歴

2

無意味な情報の削除

2020/07/12 15:26

投稿

isc
isc

スコア2

test CHANGED
File without changes
test CHANGED
@@ -213,281 +213,3 @@
213
213
 
214
214
 
215
215
  python 3.6
216
-
217
-
218
-
219
- ###現在のソースコード
220
-
221
- メイン
222
-
223
- ``` python
224
-
225
- ##ファイル名draw_Done.py##
226
-
227
- import sys,cv2,os,threading,time
228
-
229
- from PyQt5 import QtCore, QtGui, QtWidgets
230
-
231
- #from test_ilust import Widget
232
-
233
-
234
-
235
- from draw_main2 import Ui_MainWindow
236
-
237
-
238
-
239
-
240
-
241
- import sys,re
242
-
243
- from PyQt5.QtCore import Qt
244
-
245
- from PyQt5.QtGui import QPainter
246
-
247
- from PyQt5.QtWidgets import QApplication,QWidget
248
-
249
- ##############スタートGUI##################################
250
-
251
- class main_window(QtWidgets.QMainWindow):
252
-
253
- def __init__(self, parent=None):
254
-
255
- super(main_window, self).__init__(parent)
256
-
257
-
258
-
259
- self.main=Ui_MainWindow()
260
-
261
- self.main.setupUi(self)
262
-
263
- self.main.retranslateUi(self)
264
-
265
-
266
-
267
-
268
-
269
- scene =GraphicsScene(self)
270
-
271
- view = QtWidgets.QGraphicsView(scene)
272
-
273
-
274
-
275
- pixmap = QtGui.QPixmap()
276
-
277
- pixmap.load("sample.jpg")
278
-
279
-
280
-
281
- item = QtWidgets.QGraphicsPixmapItem(pixmap)
282
-
283
- scene.addItem(item)
284
-
285
- self.main.graphicsView.setScene(scene)
286
-
287
-
288
-
289
-
290
-
291
-
292
-
293
- def save(self):
294
-
295
- print("save")
296
-
297
- def ok(self):
298
-
299
- print("ok")
300
-
301
-
302
-
303
- def back(self):
304
-
305
- print("back")
306
-
307
- def next(self):
308
-
309
- print("next")
310
-
311
-
312
-
313
- ######################################################
314
-
315
- class GraphicsScene(QtWidgets.QGraphicsScene):
316
-
317
- def __init__(self, parent=None):
318
-
319
- super(GraphicsScene, self).__init__( parent)
320
-
321
- #super(GraphicsScene, self).__init__(parent)
322
-
323
- self._start = QtCore.QPointF()
324
-
325
- self._current_rect_item = None
326
-
327
-
328
-
329
-
330
-
331
- def mousePressEvent(self, event):
332
-
333
- if self._current_rect_item:
334
-
335
- self.removeItem(self._current_rect_item)
336
-
337
- print("press")
338
-
339
- self._current_rect_item = QtWidgets.QGraphicsRectItem()
340
-
341
- self.addItem(self._current_rect_item)
342
-
343
- self._start = event.scenePos()
344
-
345
- r = QtCore.QRectF(self._start, self._start)
346
-
347
- self._current_rect_item.setRect(r)
348
-
349
- super(GraphicsScene, self).mousePressEvent(event)
350
-
351
-
352
-
353
- def mouseMoveEvent(self, event):
354
-
355
- if self._current_rect_item is not None:
356
-
357
- r = QtCore.QRectF(self._start, event.scenePos()).normalized()
358
-
359
- self._current_rect_item.setRect(r)
360
-
361
- super(GraphicsScene, self).mouseMoveEvent(event)
362
-
363
-
364
-
365
- def mouseReleaseEvent(self, event):
366
-
367
- # self._current_rect_item = None
368
-
369
- super(GraphicsScene, self).mouseReleaseEvent(event)
370
-
371
-
372
-
373
- ################メイン##################################
374
-
375
- if __name__ == '__main__':
376
-
377
-
378
-
379
- app = QtWidgets.QApplication(sys.argv)
380
-
381
- window = main_window()
382
-
383
- window.show()
384
-
385
-
386
-
387
- sys.exit(app.exec_())
388
-
389
-
390
-
391
- ```
392
-
393
- qtDesignerで描いたGUI
394
-
395
- draw_main2.py
396
-
397
- ```python
398
-
399
- ##ファイル名draw_main2.py##
400
-
401
- from PyQt5 import QtCore, QtGui, QtWidgets
402
-
403
-
404
-
405
- class Ui_MainWindow(object):
406
-
407
- def setupUi(self, MainWindow):
408
-
409
- MainWindow.setObjectName("MainWindow")
410
-
411
- MainWindow.resize(722, 556)
412
-
413
- self.centralwidget = QtWidgets.QWidget(MainWindow)
414
-
415
- self.centralwidget.setObjectName("centralwidget")
416
-
417
- self.Save_Button = QtWidgets.QPushButton(self.centralwidget)
418
-
419
- self.Save_Button.setGeometry(QtCore.QRect(530, 390, 171, 51))
420
-
421
- self.Save_Button.setObjectName("Save_Button")
422
-
423
- self.OK_Button = QtWidgets.QPushButton(self.centralwidget)
424
-
425
- self.OK_Button.setGeometry(QtCore.QRect(530, 450, 171, 51))
426
-
427
- self.OK_Button.setObjectName("OK_Button")
428
-
429
- self.image_name = QtWidgets.QLabel(self.centralwidget)
430
-
431
- self.image_name.setGeometry(QtCore.QRect(550, 150, 141, 31))
432
-
433
- self.image_name.setObjectName("image_name")
434
-
435
- self.back_Button = QtWidgets.QPushButton(self.centralwidget)
436
-
437
- self.back_Button.setGeometry(QtCore.QRect(550, 190, 61, 61))
438
-
439
- self.back_Button.setObjectName("back_Button")
440
-
441
- self.next_Button_ = QtWidgets.QPushButton(self.centralwidget)
442
-
443
- self.next_Button_.setGeometry(QtCore.QRect(620, 190, 61, 61))
444
-
445
- self.next_Button_.setObjectName("next_Button_")
446
-
447
- self.graphicsView = QtWidgets.QGraphicsView(self.centralwidget)
448
-
449
- self.graphicsView.setGeometry(QtCore.QRect(10, 70, 501, 421))
450
-
451
- self.graphicsView.setObjectName("graphicsView")
452
-
453
- self.graphicsView.setMaximumSize(501,421)
454
-
455
- MainWindow.setCentralWidget(self.centralwidget)
456
-
457
-
458
-
459
- self.retranslateUi(MainWindow)
460
-
461
- self.Save_Button.clicked.connect(MainWindow.save)
462
-
463
- self.OK_Button.clicked.connect(MainWindow.ok)
464
-
465
- self.back_Button.clicked.connect(MainWindow.back)
466
-
467
- self.next_Button_.clicked.connect(MainWindow.next)
468
-
469
- QtCore.QMetaObject.connectSlotsByName(MainWindow)
470
-
471
-
472
-
473
- def retranslateUi(self, MainWindow):
474
-
475
- _translate = QtCore.QCoreApplication.translate
476
-
477
- MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
478
-
479
- self.Save_Button.setText(_translate("MainWindow", "保存"))
480
-
481
- self.OK_Button.setText(_translate("MainWindow", "完了"))
482
-
483
- self.image_name.setText(_translate("MainWindow", "TextLabel"))
484
-
485
- self.back_Button.setText(_translate("MainWindow", "<"))
486
-
487
- self.next_Button_.setText(_translate("MainWindow", ">"))
488
-
489
-
490
-
491
-
492
-
493
- ```

1

自身のソースコードの追加

2020/07/12 15:26

投稿

isc
isc

スコア2

test CHANGED
File without changes
test CHANGED
@@ -213,3 +213,281 @@
213
213
 
214
214
 
215
215
  python 3.6
216
+
217
+
218
+
219
+ ###現在のソースコード
220
+
221
+ メイン
222
+
223
+ ``` python
224
+
225
+ ##ファイル名draw_Done.py##
226
+
227
+ import sys,cv2,os,threading,time
228
+
229
+ from PyQt5 import QtCore, QtGui, QtWidgets
230
+
231
+ #from test_ilust import Widget
232
+
233
+
234
+
235
+ from draw_main2 import Ui_MainWindow
236
+
237
+
238
+
239
+
240
+
241
+ import sys,re
242
+
243
+ from PyQt5.QtCore import Qt
244
+
245
+ from PyQt5.QtGui import QPainter
246
+
247
+ from PyQt5.QtWidgets import QApplication,QWidget
248
+
249
+ ##############スタートGUI##################################
250
+
251
+ class main_window(QtWidgets.QMainWindow):
252
+
253
+ def __init__(self, parent=None):
254
+
255
+ super(main_window, self).__init__(parent)
256
+
257
+
258
+
259
+ self.main=Ui_MainWindow()
260
+
261
+ self.main.setupUi(self)
262
+
263
+ self.main.retranslateUi(self)
264
+
265
+
266
+
267
+
268
+
269
+ scene =GraphicsScene(self)
270
+
271
+ view = QtWidgets.QGraphicsView(scene)
272
+
273
+
274
+
275
+ pixmap = QtGui.QPixmap()
276
+
277
+ pixmap.load("sample.jpg")
278
+
279
+
280
+
281
+ item = QtWidgets.QGraphicsPixmapItem(pixmap)
282
+
283
+ scene.addItem(item)
284
+
285
+ self.main.graphicsView.setScene(scene)
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+ def save(self):
294
+
295
+ print("save")
296
+
297
+ def ok(self):
298
+
299
+ print("ok")
300
+
301
+
302
+
303
+ def back(self):
304
+
305
+ print("back")
306
+
307
+ def next(self):
308
+
309
+ print("next")
310
+
311
+
312
+
313
+ ######################################################
314
+
315
+ class GraphicsScene(QtWidgets.QGraphicsScene):
316
+
317
+ def __init__(self, parent=None):
318
+
319
+ super(GraphicsScene, self).__init__( parent)
320
+
321
+ #super(GraphicsScene, self).__init__(parent)
322
+
323
+ self._start = QtCore.QPointF()
324
+
325
+ self._current_rect_item = None
326
+
327
+
328
+
329
+
330
+
331
+ def mousePressEvent(self, event):
332
+
333
+ if self._current_rect_item:
334
+
335
+ self.removeItem(self._current_rect_item)
336
+
337
+ print("press")
338
+
339
+ self._current_rect_item = QtWidgets.QGraphicsRectItem()
340
+
341
+ self.addItem(self._current_rect_item)
342
+
343
+ self._start = event.scenePos()
344
+
345
+ r = QtCore.QRectF(self._start, self._start)
346
+
347
+ self._current_rect_item.setRect(r)
348
+
349
+ super(GraphicsScene, self).mousePressEvent(event)
350
+
351
+
352
+
353
+ def mouseMoveEvent(self, event):
354
+
355
+ if self._current_rect_item is not None:
356
+
357
+ r = QtCore.QRectF(self._start, event.scenePos()).normalized()
358
+
359
+ self._current_rect_item.setRect(r)
360
+
361
+ super(GraphicsScene, self).mouseMoveEvent(event)
362
+
363
+
364
+
365
+ def mouseReleaseEvent(self, event):
366
+
367
+ # self._current_rect_item = None
368
+
369
+ super(GraphicsScene, self).mouseReleaseEvent(event)
370
+
371
+
372
+
373
+ ################メイン##################################
374
+
375
+ if __name__ == '__main__':
376
+
377
+
378
+
379
+ app = QtWidgets.QApplication(sys.argv)
380
+
381
+ window = main_window()
382
+
383
+ window.show()
384
+
385
+
386
+
387
+ sys.exit(app.exec_())
388
+
389
+
390
+
391
+ ```
392
+
393
+ qtDesignerで描いたGUI
394
+
395
+ draw_main2.py
396
+
397
+ ```python
398
+
399
+ ##ファイル名draw_main2.py##
400
+
401
+ from PyQt5 import QtCore, QtGui, QtWidgets
402
+
403
+
404
+
405
+ class Ui_MainWindow(object):
406
+
407
+ def setupUi(self, MainWindow):
408
+
409
+ MainWindow.setObjectName("MainWindow")
410
+
411
+ MainWindow.resize(722, 556)
412
+
413
+ self.centralwidget = QtWidgets.QWidget(MainWindow)
414
+
415
+ self.centralwidget.setObjectName("centralwidget")
416
+
417
+ self.Save_Button = QtWidgets.QPushButton(self.centralwidget)
418
+
419
+ self.Save_Button.setGeometry(QtCore.QRect(530, 390, 171, 51))
420
+
421
+ self.Save_Button.setObjectName("Save_Button")
422
+
423
+ self.OK_Button = QtWidgets.QPushButton(self.centralwidget)
424
+
425
+ self.OK_Button.setGeometry(QtCore.QRect(530, 450, 171, 51))
426
+
427
+ self.OK_Button.setObjectName("OK_Button")
428
+
429
+ self.image_name = QtWidgets.QLabel(self.centralwidget)
430
+
431
+ self.image_name.setGeometry(QtCore.QRect(550, 150, 141, 31))
432
+
433
+ self.image_name.setObjectName("image_name")
434
+
435
+ self.back_Button = QtWidgets.QPushButton(self.centralwidget)
436
+
437
+ self.back_Button.setGeometry(QtCore.QRect(550, 190, 61, 61))
438
+
439
+ self.back_Button.setObjectName("back_Button")
440
+
441
+ self.next_Button_ = QtWidgets.QPushButton(self.centralwidget)
442
+
443
+ self.next_Button_.setGeometry(QtCore.QRect(620, 190, 61, 61))
444
+
445
+ self.next_Button_.setObjectName("next_Button_")
446
+
447
+ self.graphicsView = QtWidgets.QGraphicsView(self.centralwidget)
448
+
449
+ self.graphicsView.setGeometry(QtCore.QRect(10, 70, 501, 421))
450
+
451
+ self.graphicsView.setObjectName("graphicsView")
452
+
453
+ self.graphicsView.setMaximumSize(501,421)
454
+
455
+ MainWindow.setCentralWidget(self.centralwidget)
456
+
457
+
458
+
459
+ self.retranslateUi(MainWindow)
460
+
461
+ self.Save_Button.clicked.connect(MainWindow.save)
462
+
463
+ self.OK_Button.clicked.connect(MainWindow.ok)
464
+
465
+ self.back_Button.clicked.connect(MainWindow.back)
466
+
467
+ self.next_Button_.clicked.connect(MainWindow.next)
468
+
469
+ QtCore.QMetaObject.connectSlotsByName(MainWindow)
470
+
471
+
472
+
473
+ def retranslateUi(self, MainWindow):
474
+
475
+ _translate = QtCore.QCoreApplication.translate
476
+
477
+ MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
478
+
479
+ self.Save_Button.setText(_translate("MainWindow", "保存"))
480
+
481
+ self.OK_Button.setText(_translate("MainWindow", "完了"))
482
+
483
+ self.image_name.setText(_translate("MainWindow", "TextLabel"))
484
+
485
+ self.back_Button.setText(_translate("MainWindow", "<"))
486
+
487
+ self.next_Button_.setText(_translate("MainWindow", ">"))
488
+
489
+
490
+
491
+
492
+
493
+ ```