개정판 039cdacb
issue #1118
1. NewDrawingDialog.py ==> QDrawingDialog.py 파일명 변경
2. UI\Drawing.ui 추가
Change-Id: I96b1a7452ea974831e6e6bedbca7c15405584b7d
HYTOS/HYTOS/Drawing_UI.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
|
|
3 |
# Form implementation generated from reading ui file '.\UI\Drawing.ui' |
|
4 |
# |
|
5 |
# Created by: PyQt5 UI code generator 5.11.3 |
|
6 |
# |
|
7 |
# WARNING! All changes made in this file will be lost! |
|
8 |
|
|
9 |
from PyQt5 import QtCore, QtGui, QtWidgets |
|
10 |
|
|
11 |
class Ui_DrawingDialog(object): |
|
12 |
def setupUi(self, DrawingDialog): |
|
13 |
DrawingDialog.setObjectName("DrawingDialog") |
|
14 |
DrawingDialog.resize(277, 97) |
|
15 |
font = QtGui.QFont() |
|
16 |
font.setFamily("맑은 고딕") |
|
17 |
DrawingDialog.setFont(font) |
|
18 |
DrawingDialog.setLocale(QtCore.QLocale(QtCore.QLocale.Korean, QtCore.QLocale.SouthKorea)) |
|
19 |
self.gridLayout = QtWidgets.QGridLayout(DrawingDialog) |
|
20 |
self.gridLayout.setObjectName("gridLayout") |
|
21 |
self.buttonBox = QtWidgets.QDialogButtonBox(DrawingDialog) |
|
22 |
font = QtGui.QFont() |
|
23 |
font.setFamily("맑은 고딕") |
|
24 |
font.setBold(True) |
|
25 |
font.setWeight(75) |
|
26 |
self.buttonBox.setFont(font) |
|
27 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
|
28 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) |
|
29 |
self.buttonBox.setObjectName("buttonBox") |
|
30 |
self.gridLayout.addWidget(self.buttonBox, 2, 1, 1, 1) |
|
31 |
self.horizontalLayout = QtWidgets.QHBoxLayout() |
|
32 |
self.horizontalLayout.setObjectName("horizontalLayout") |
|
33 |
self.labelName = QtWidgets.QLabel(DrawingDialog) |
|
34 |
font = QtGui.QFont() |
|
35 |
font.setFamily("맑은 고딕") |
|
36 |
font.setPointSize(10) |
|
37 |
self.labelName.setFont(font) |
|
38 |
self.labelName.setObjectName("labelName") |
|
39 |
self.horizontalLayout.addWidget(self.labelName) |
|
40 |
self.lineEditName = QtWidgets.QLineEdit(DrawingDialog) |
|
41 |
font = QtGui.QFont() |
|
42 |
font.setFamily("맑은 고딕") |
|
43 |
self.lineEditName.setFont(font) |
|
44 |
self.lineEditName.setObjectName("lineEditName") |
|
45 |
self.horizontalLayout.addWidget(self.lineEditName) |
|
46 |
self.gridLayout.addLayout(self.horizontalLayout, 1, 1, 1, 1) |
|
47 |
|
|
48 |
self.retranslateUi(DrawingDialog) |
|
49 |
self.buttonBox.accepted.connect(DrawingDialog.accept) |
|
50 |
self.buttonBox.rejected.connect(DrawingDialog.reject) |
|
51 |
QtCore.QMetaObject.connectSlotsByName(DrawingDialog) |
|
52 |
|
|
53 |
def retranslateUi(self, DrawingDialog): |
|
54 |
_translate = QtCore.QCoreApplication.translate |
|
55 |
DrawingDialog.setWindowTitle(_translate("DrawingDialog", "New Drawing")) |
|
56 |
self.labelName.setText(_translate("DrawingDialog", "Name")) |
|
57 |
|
HYTOS/HYTOS/MainWindow.py | ||
---|---|---|
1059 | 1059 |
@date 2019.07.03 |
1060 | 1060 |
''' |
1061 | 1061 |
def new_drawing(self): |
1062 |
from NewDrawingDialog import QNewDrawingDialog
|
|
1062 |
from QDrawingDialog import QDrawingDialog
|
|
1063 | 1063 |
|
1064 |
dlg = QNewDrawingDialog(self)
|
|
1064 |
dlg = QDrawingDialog(self) |
|
1065 | 1065 |
res = dlg.showDialog() |
1066 | 1066 |
if res: |
1067 | 1067 |
self.load_drawing_list() |
HYTOS/HYTOS/NewDrawingDialog.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
|
|
3 |
import os |
|
4 |
import sys |
|
5 |
import sqlite3 |
|
6 |
import NewDrawing_UI |
|
7 |
from PyQt5 import QtCore, QtGui, QtWidgets |
|
8 |
from PyQt5.QtWidgets import * |
|
9 |
from AppDocData import AppDocData, MessageType |
|
10 |
from datetime import datetime |
|
11 |
import uuid |
|
12 |
|
|
13 |
class QNewDrawingDialog(QDialog): |
|
14 |
def __init__(self, parent): |
|
15 |
QDialog.__init__(self, parent) |
|
16 |
_translate = QtCore.QCoreApplication.translate |
|
17 |
|
|
18 |
self.result = False |
|
19 |
self.ui = NewDrawing_UI.Ui_Dialog() |
|
20 |
self.ui.setupUi(self) |
|
21 |
self.setWindowTitle(_translate('New Drawing Dialog', 'New Drawing')) |
|
22 |
|
|
23 |
def showDialog(self): |
|
24 |
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowCloseButtonHint & ~QtCore.Qt.WindowContextHelpButtonHint) |
|
25 |
self.exec_() |
|
26 |
|
|
27 |
return self.result |
|
28 |
|
|
29 |
def accept(self): |
|
30 |
drawingName = self.ui.lineEditDrawingName.text().strip() |
|
31 |
|
|
32 |
if not self.validationCheck(drawingName): |
|
33 |
QMessageBox.warning(self, self.tr('Notice'), self.tr('Name is empty.')) |
|
34 |
return |
|
35 |
|
|
36 |
if self.exists_drawing(drawingName): |
|
37 |
QMessageBox.warning(self, self.tr('Notice'), self.tr('Name already exists.')) |
|
38 |
return |
|
39 |
|
|
40 |
self.saveDrawing(drawingName) |
|
41 |
|
|
42 |
self.result = True |
|
43 |
QDialog.accept(self) |
|
44 |
|
|
45 |
def reject(self): |
|
46 |
|
|
47 |
self.result = False |
|
48 |
QDialog.reject(self) |
|
49 |
|
|
50 |
def validationCheck(self, drawingName): |
|
51 |
if not drawingName: |
|
52 |
return False |
|
53 |
|
|
54 |
return True |
|
55 |
|
|
56 |
def exists_drawing(self, drawingName): |
|
57 |
return AppDocData.instance().exists_drawing(drawingName) |
|
58 |
|
|
59 |
def saveDrawing(self, drawingName): |
|
60 |
drawings = [] |
|
61 |
drawings.append([str(uuid.uuid4()), drawingName, str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))]) |
|
62 |
|
|
63 |
AppDocData.instance().saveDrawings(drawings) |
HYTOS/HYTOS/NewDrawing_UI.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
|
|
3 |
# Form implementation generated from reading ui file '.\UI\NewDrawing.ui' |
|
4 |
# |
|
5 |
# Created by: PyQt5 UI code generator 5.11.3 |
|
6 |
# |
|
7 |
# WARNING! All changes made in this file will be lost! |
|
8 |
|
|
9 |
from PyQt5 import QtCore, QtGui, QtWidgets |
|
10 |
|
|
11 |
class Ui_Dialog(object): |
|
12 |
def setupUi(self, Dialog): |
|
13 |
Dialog.setObjectName("Dialog") |
|
14 |
Dialog.resize(277, 97) |
|
15 |
font = QtGui.QFont() |
|
16 |
font.setFamily("맑은 고딕") |
|
17 |
Dialog.setFont(font) |
|
18 |
Dialog.setLocale(QtCore.QLocale(QtCore.QLocale.Korean, QtCore.QLocale.SouthKorea)) |
|
19 |
self.gridLayout = QtWidgets.QGridLayout(Dialog) |
|
20 |
self.gridLayout.setObjectName("gridLayout") |
|
21 |
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog) |
|
22 |
font = QtGui.QFont() |
|
23 |
font.setFamily("맑은 고딕") |
|
24 |
font.setBold(True) |
|
25 |
font.setWeight(75) |
|
26 |
self.buttonBox.setFont(font) |
|
27 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
|
28 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) |
|
29 |
self.buttonBox.setObjectName("buttonBox") |
|
30 |
self.gridLayout.addWidget(self.buttonBox, 2, 1, 1, 1) |
|
31 |
self.horizontalLayout = QtWidgets.QHBoxLayout() |
|
32 |
self.horizontalLayout.setObjectName("horizontalLayout") |
|
33 |
self.label = QtWidgets.QLabel(Dialog) |
|
34 |
font = QtGui.QFont() |
|
35 |
font.setFamily("맑은 고딕") |
|
36 |
self.label.setFont(font) |
|
37 |
self.label.setObjectName("label") |
|
38 |
self.horizontalLayout.addWidget(self.label) |
|
39 |
self.lineEditDrawingName = QtWidgets.QLineEdit(Dialog) |
|
40 |
font = QtGui.QFont() |
|
41 |
font.setFamily("맑은 고딕") |
|
42 |
self.lineEditDrawingName.setFont(font) |
|
43 |
self.lineEditDrawingName.setObjectName("lineEditDrawingName") |
|
44 |
self.horizontalLayout.addWidget(self.lineEditDrawingName) |
|
45 |
self.gridLayout.addLayout(self.horizontalLayout, 1, 1, 1, 1) |
|
46 |
|
|
47 |
self.retranslateUi(Dialog) |
|
48 |
self.buttonBox.accepted.connect(Dialog.accept) |
|
49 |
self.buttonBox.rejected.connect(Dialog.reject) |
|
50 |
QtCore.QMetaObject.connectSlotsByName(Dialog) |
|
51 |
|
|
52 |
def retranslateUi(self, Dialog): |
|
53 |
_translate = QtCore.QCoreApplication.translate |
|
54 |
Dialog.setWindowTitle(_translate("Dialog", "New Drawing")) |
|
55 |
self.label.setText(_translate("Dialog", "Name")) |
|
56 |
|
HYTOS/HYTOS/QDrawingDialog.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
|
|
3 |
import os |
|
4 |
import sys |
|
5 |
import sqlite3 |
|
6 |
from PyQt5 import QtCore, QtGui, QtWidgets |
|
7 |
from PyQt5.QtWidgets import * |
|
8 |
from AppDocData import AppDocData, MessageType |
|
9 |
from datetime import datetime |
|
10 |
import uuid |
|
11 |
import Drawing_UI |
|
12 |
|
|
13 |
class QDrawingDialog(QDialog): |
|
14 |
def __init__(self, parent): |
|
15 |
QDialog.__init__(self, parent) |
|
16 |
_translate = QtCore.QCoreApplication.translate |
|
17 |
|
|
18 |
self.result = False |
|
19 |
self.ui = Drawing_UI.Ui_DrawingDialog() |
|
20 |
self.ui.setupUi(self) |
|
21 |
self.setWindowTitle(_translate('New Drawing Dialog', 'New Drawing')) |
|
22 |
|
|
23 |
def showDialog(self): |
|
24 |
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowCloseButtonHint & ~QtCore.Qt.WindowContextHelpButtonHint) |
|
25 |
self.exec_() |
|
26 |
|
|
27 |
return self.result |
|
28 |
|
|
29 |
def accept(self): |
|
30 |
drawingName = self.ui.lineEditName.text().strip() |
|
31 |
|
|
32 |
if not self.validationCheck(drawingName): |
|
33 |
QMessageBox.warning(self, self.tr('Notice'), self.tr('Name is empty.')) |
|
34 |
return |
|
35 |
|
|
36 |
if self.exists_drawing(drawingName): |
|
37 |
QMessageBox.warning(self, self.tr('Notice'), self.tr('Name already exists.')) |
|
38 |
return |
|
39 |
|
|
40 |
self.saveDrawing(drawingName) |
|
41 |
|
|
42 |
self.result = True |
|
43 |
QDialog.accept(self) |
|
44 |
|
|
45 |
def reject(self): |
|
46 |
|
|
47 |
self.result = False |
|
48 |
QDialog.reject(self) |
|
49 |
|
|
50 |
def validationCheck(self, drawingName): |
|
51 |
if not drawingName: |
|
52 |
return False |
|
53 |
|
|
54 |
return True |
|
55 |
|
|
56 |
def exists_drawing(self, drawingName): |
|
57 |
return AppDocData.instance().exists_drawing(drawingName) |
|
58 |
|
|
59 |
def saveDrawing(self, drawingName): |
|
60 |
drawings = [] |
|
61 |
drawings.append([str(uuid.uuid4()), drawingName, str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))]) |
|
62 |
|
|
63 |
AppDocData.instance().saveDrawings(drawings) |
HYTOS/HYTOS/UI/Drawing.ui | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<ui version="4.0"> |
|
3 |
<class>DrawingDialog</class> |
|
4 |
<widget class="QDialog" name="DrawingDialog"> |
|
5 |
<property name="geometry"> |
|
6 |
<rect> |
|
7 |
<x>0</x> |
|
8 |
<y>0</y> |
|
9 |
<width>277</width> |
|
10 |
<height>97</height> |
|
11 |
</rect> |
|
12 |
</property> |
|
13 |
<property name="font"> |
|
14 |
<font> |
|
15 |
<family>맑은 고딕</family> |
|
16 |
</font> |
|
17 |
</property> |
|
18 |
<property name="windowTitle"> |
|
19 |
<string>New Drawing</string> |
|
20 |
</property> |
|
21 |
<property name="locale"> |
|
22 |
<locale language="Korean" country="SouthKorea"/> |
|
23 |
</property> |
|
24 |
<layout class="QGridLayout" name="gridLayout"> |
|
25 |
<item row="2" column="1"> |
|
26 |
<widget class="QDialogButtonBox" name="buttonBox"> |
|
27 |
<property name="font"> |
|
28 |
<font> |
|
29 |
<family>맑은 고딕</family> |
|
30 |
<weight>75</weight> |
|
31 |
<bold>true</bold> |
|
32 |
</font> |
|
33 |
</property> |
|
34 |
<property name="orientation"> |
|
35 |
<enum>Qt::Horizontal</enum> |
|
36 |
</property> |
|
37 |
<property name="standardButtons"> |
|
38 |
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
|
39 |
</property> |
|
40 |
</widget> |
|
41 |
</item> |
|
42 |
<item row="1" column="1"> |
|
43 |
<layout class="QHBoxLayout" name="horizontalLayout"> |
|
44 |
<item> |
|
45 |
<widget class="QLabel" name="labelName"> |
|
46 |
<property name="font"> |
|
47 |
<font> |
|
48 |
<family>맑은 고딕</family> |
|
49 |
<pointsize>10</pointsize> |
|
50 |
</font> |
|
51 |
</property> |
|
52 |
<property name="text"> |
|
53 |
<string>Name</string> |
|
54 |
</property> |
|
55 |
</widget> |
|
56 |
</item> |
|
57 |
<item> |
|
58 |
<widget class="QLineEdit" name="lineEditName"> |
|
59 |
<property name="font"> |
|
60 |
<font> |
|
61 |
<family>맑은 고딕</family> |
|
62 |
</font> |
|
63 |
</property> |
|
64 |
</widget> |
|
65 |
</item> |
|
66 |
</layout> |
|
67 |
</item> |
|
68 |
</layout> |
|
69 |
</widget> |
|
70 |
<resources/> |
|
71 |
<connections> |
|
72 |
<connection> |
|
73 |
<sender>buttonBox</sender> |
|
74 |
<signal>accepted()</signal> |
|
75 |
<receiver>DrawingDialog</receiver> |
|
76 |
<slot>accept()</slot> |
|
77 |
<hints> |
|
78 |
<hint type="sourcelabel"> |
|
79 |
<x>248</x> |
|
80 |
<y>254</y> |
|
81 |
</hint> |
|
82 |
<hint type="destinationlabel"> |
|
83 |
<x>157</x> |
|
84 |
<y>274</y> |
|
85 |
</hint> |
|
86 |
</hints> |
|
87 |
</connection> |
|
88 |
<connection> |
|
89 |
<sender>buttonBox</sender> |
|
90 |
<signal>rejected()</signal> |
|
91 |
<receiver>DrawingDialog</receiver> |
|
92 |
<slot>reject()</slot> |
|
93 |
<hints> |
|
94 |
<hint type="sourcelabel"> |
|
95 |
<x>316</x> |
|
96 |
<y>260</y> |
|
97 |
</hint> |
|
98 |
<hint type="destinationlabel"> |
|
99 |
<x>286</x> |
|
100 |
<y>274</y> |
|
101 |
</hint> |
|
102 |
</hints> |
|
103 |
</connection> |
|
104 |
</connections> |
|
105 |
</ui> |
HYTOS/HYTOS/UI/NewDrawing.ui | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<ui version="4.0"> |
|
3 |
<class>Dialog</class> |
|
4 |
<widget class="QDialog" name="Dialog"> |
|
5 |
<property name="geometry"> |
|
6 |
<rect> |
|
7 |
<x>0</x> |
|
8 |
<y>0</y> |
|
9 |
<width>277</width> |
|
10 |
<height>97</height> |
|
11 |
</rect> |
|
12 |
</property> |
|
13 |
<property name="font"> |
|
14 |
<font> |
|
15 |
<family>맑은 고딕</family> |
|
16 |
</font> |
|
17 |
</property> |
|
18 |
<property name="windowTitle"> |
|
19 |
<string>New Drawing</string> |
|
20 |
</property> |
|
21 |
<property name="locale"> |
|
22 |
<locale language="Korean" country="SouthKorea"/> |
|
23 |
</property> |
|
24 |
<layout class="QGridLayout" name="gridLayout"> |
|
25 |
<item row="2" column="1"> |
|
26 |
<widget class="QDialogButtonBox" name="buttonBox"> |
|
27 |
<property name="font"> |
|
28 |
<font> |
|
29 |
<family>맑은 고딕</family> |
|
30 |
<weight>75</weight> |
|
31 |
<bold>true</bold> |
|
32 |
</font> |
|
33 |
</property> |
|
34 |
<property name="orientation"> |
|
35 |
<enum>Qt::Horizontal</enum> |
|
36 |
</property> |
|
37 |
<property name="standardButtons"> |
|
38 |
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
|
39 |
</property> |
|
40 |
</widget> |
|
41 |
</item> |
|
42 |
<item row="1" column="1"> |
|
43 |
<layout class="QHBoxLayout" name="horizontalLayout"> |
|
44 |
<item> |
|
45 |
<widget class="QLabel" name="label"> |
|
46 |
<property name="font"> |
|
47 |
<font> |
|
48 |
<family>맑은 고딕</family> |
|
49 |
</font> |
|
50 |
</property> |
|
51 |
<property name="text"> |
|
52 |
<string>Name</string> |
|
53 |
</property> |
|
54 |
</widget> |
|
55 |
</item> |
|
56 |
<item> |
|
57 |
<widget class="QLineEdit" name="lineEditDrawingName"> |
|
58 |
<property name="font"> |
|
59 |
<font> |
|
60 |
<family>맑은 고딕</family> |
|
61 |
</font> |
|
62 |
</property> |
|
63 |
</widget> |
|
64 |
</item> |
|
65 |
</layout> |
|
66 |
</item> |
|
67 |
</layout> |
|
68 |
</widget> |
|
69 |
<resources/> |
|
70 |
<connections> |
|
71 |
<connection> |
|
72 |
<sender>buttonBox</sender> |
|
73 |
<signal>accepted()</signal> |
|
74 |
<receiver>Dialog</receiver> |
|
75 |
<slot>accept()</slot> |
|
76 |
<hints> |
|
77 |
<hint type="sourcelabel"> |
|
78 |
<x>248</x> |
|
79 |
<y>254</y> |
|
80 |
</hint> |
|
81 |
<hint type="destinationlabel"> |
|
82 |
<x>157</x> |
|
83 |
<y>274</y> |
|
84 |
</hint> |
|
85 |
</hints> |
|
86 |
</connection> |
|
87 |
<connection> |
|
88 |
<sender>buttonBox</sender> |
|
89 |
<signal>rejected()</signal> |
|
90 |
<receiver>Dialog</receiver> |
|
91 |
<slot>reject()</slot> |
|
92 |
<hints> |
|
93 |
<hint type="sourcelabel"> |
|
94 |
<x>316</x> |
|
95 |
<y>260</y> |
|
96 |
</hint> |
|
97 |
<hint type="destinationlabel"> |
|
98 |
<x>286</x> |
|
99 |
<y>274</y> |
|
100 |
</hint> |
|
101 |
</hints> |
|
102 |
</connection> |
|
103 |
</connections> |
|
104 |
</ui> |
내보내기 Unified diff