프로젝트

일반

사용자정보

개정판 a307208a

IDa307208ab0ff0d97c9279f5a118d9b189a15b510
상위 db64b691
하위 73865c58

백흠경이(가) 약 5년 전에 추가함

issue #1251: upload SystemInformation dialog

Change-Id: I5e5eb52386397d15a6ecf15954bcdd1292109f13

차이점 보기:

HYTOS/HYTOS/App.py
96 96
    def mainWnd():
97 97
        return QtWidgets.qApp._mainWnd
98 98

  
99
'''
100
    @history    18.04.23    Jeongwoo    Change method to execute ProjectDialog(dlg.exec_()→dlg.showDialog())
101
'''
102 99
if __name__ == '__main__':
103 100
    from AppDocData import AppDocData
104 101
    from MainWindow import MainWindow
105 102
    from ExceptionHandler import QExceptionHandler
103
    from SystemInformation import QSystemInformationDialog
106 104

  
107 105
    app = App(sys.argv)
108 106

  
......
111 109
    sys._excepthook = sys.excepthook
112 110
    sys.excepthook = exceptionHandler.handler
113 111

  
114
    if True:
115
        AppDocData.instance().ex = exceptionHandler
112
    app_doc_data = AppDocData.instance()
113
    configs = app_doc_data.getAppConfigs('app', 'UserName')
114
    if not (configs and configs[0].value):
115
        dlg = QSystemInformationDialog()
116
        dlg.exec_()
117

  
118
    configs = app_doc_data.getAppConfigs('app', 'UserName')
119
    if configs and configs[0].value:
120
        app_doc_data.ex = exceptionHandler
116 121
        app._mainWnd = MainWindow.instance()
117
        if len(sys.argv) == 2: app._mainWnd.open_drawing(sys.argv[1])
122
        if len(sys.argv) == 2:
123
            app._mainWnd.open_drawing(sys.argv[1])
118 124
        app._mainWnd.show()
119 125
        sys.exit(app.exec_())
HYTOS/HYTOS/MainWindow.py
9 9
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
10 10
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\Commands')
11 11
import CreateCommand
12
import CropCommand
13 12
import AreaZoomCommand
14
import FenceCommand
15 13
import PlaceStreamlineCommand
16 14

  
17 15
import numpy as np
......
1557 1555

  
1558 1556

  
1559 1557
if __name__ == '__main__':
1560
    import locale
1561
    from PyQt5.QtCore import QTranslator
1562
    from App import App
1563

  
1564
    app = App(sys.argv)
1565
    try:
1566
        app._mainWnd = MainWindow.instance()
1567
        if len(sys.argv) == 2: app._mainWnd.open_drawing(sys.argv[1])
1568
        app._mainWnd.show()
1569
        sys.exit(app.exec_())
1570
    except Exception as ex:
1571
        print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1572
                                                   sys.exc_info()[-1].tb_lineno))
1573
    finally:
1574
        pass
1558
    pass
HYTOS/HYTOS/SystemInformation.py
1
# -*- coding: utf-8 -*-
2

  
3
# Form implementation generated from reading ui file 'ProjectDialog.ui'
4
#
5
# Created by: PyQt5 UI code generator 5.6
6
#
7
# WARNING! All changes made in this file will be lost!
8

  
9
from PyQt5 import QtCore, QtGui, QtWidgets
10
from PyQt5.QtWidgets import *
11
import os
12
import sys
13
import socket
14
import platform
15
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\UI')
16
from AppDocData import AppDocData, Config
17
import SystemInformation_UI
18
import math
19

  
20

  
21
class QSystemInformationDialog(QDialog):
22
    def __init__(self):
23
        QDialog.__init__(self)
24

  
25
        self.ui = SystemInformation_UI.Ui_SystemInfoDialog()
26
        self.ui.setupUi(self)
27

  
28
        self.ui.lineEditUserName.setFocus()
29
        self.ui.lineEditComputerName.setText(f"{os.environ['COMPUTERNAME']}")
30
        ip = self.get_my_ip_address()
31
        self.ui.lineEditIP.setText(f"{ip}")
32
        self.ui.textEditComputerInformation.setText(f"{platform.uname()}")
33

  
34
    def get_my_ip_address(self, remote_server="google.com"):
35
        """ Return the/a network-facing IP number for this system. """
36
        with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
37
            s.connect((remote_server, 80))
38
            return s.getsockname()[0]
39

  
40
    def accept(self):
41
        """ set tag no and nozzle data """
42

  
43
        if self.ui.lineEditUserName.text():
44
            app_doc_data = AppDocData.instance()
45

  
46
            configs = [Config('app', 'UserName', self.ui.lineEditUserName.text()),
47
                       Config('app', 'ComputerName', self.ui.lineEditComputerName.text()),
48
                       Config('app', 'IP', self.ui.lineEditIP.text())]
49
            app_doc_data.saveAppConfigs(configs)
50

  
51
            QDialog.accept(self)
52
        else:
53
            QMessageBox.warning(self, self.tr('warinig'), self.tr('Please input user name'))
54

  
55
    def reject(self):
56
        QDialog.reject(self)
HYTOS/HYTOS/UI/SystemInformation.ui
1
<?xml version="1.0" encoding="UTF-8"?>
2
<ui version="4.0">
3
 <class>SystemInfoDialog</class>
4
 <widget class="QDialog" name="SystemInfoDialog">
5
  <property name="geometry">
6
   <rect>
7
    <x>0</x>
8
    <y>0</y>
9
    <width>444</width>
10
    <height>280</height>
11
   </rect>
12
  </property>
13
  <property name="windowTitle">
14
   <string>System Information</string>
15
  </property>
16
  <layout class="QGridLayout" name="gridLayout">
17
   <item row="0" column="0">
18
    <widget class="QGroupBox" name="groupBox">
19
     <property name="title">
20
      <string>System Information</string>
21
     </property>
22
     <layout class="QGridLayout" name="gridLayout_3">
23
      <item row="0" column="0">
24
       <layout class="QGridLayout" name="gridLayout_2">
25
        <item row="1" column="1">
26
         <widget class="QLineEdit" name="lineEditComputerName">
27
          <property name="readOnly">
28
           <bool>true</bool>
29
          </property>
30
         </widget>
31
        </item>
32
        <item row="2" column="1">
33
         <widget class="QLineEdit" name="lineEditIP">
34
          <property name="readOnly">
35
           <bool>true</bool>
36
          </property>
37
         </widget>
38
        </item>
39
        <item row="1" column="0">
40
         <widget class="QLabel" name="label_3">
41
          <property name="text">
42
           <string>Computer Name : </string>
43
          </property>
44
         </widget>
45
        </item>
46
        <item row="0" column="0">
47
         <widget class="QLabel" name="label">
48
          <property name="text">
49
           <string>User Name : </string>
50
          </property>
51
         </widget>
52
        </item>
53
        <item row="2" column="0">
54
         <widget class="QLabel" name="label_2">
55
          <property name="text">
56
           <string>IP : </string>
57
          </property>
58
         </widget>
59
        </item>
60
        <item row="0" column="1">
61
         <widget class="QLineEdit" name="lineEditUserName"/>
62
        </item>
63
        <item row="3" column="0">
64
         <widget class="QLabel" name="label_4">
65
          <property name="text">
66
           <string>Computer Information : </string>
67
          </property>
68
         </widget>
69
        </item>
70
        <item row="3" column="1">
71
         <widget class="QTextEdit" name="textEditComputerInformation">
72
          <property name="readOnly">
73
           <bool>true</bool>
74
          </property>
75
         </widget>
76
        </item>
77
       </layout>
78
      </item>
79
     </layout>
80
    </widget>
81
   </item>
82
   <item row="1" column="0">
83
    <widget class="QDialogButtonBox" name="buttonBox">
84
     <property name="orientation">
85
      <enum>Qt::Horizontal</enum>
86
     </property>
87
     <property name="standardButtons">
88
      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
89
     </property>
90
    </widget>
91
   </item>
92
  </layout>
93
 </widget>
94
 <resources/>
95
 <connections>
96
  <connection>
97
   <sender>buttonBox</sender>
98
   <signal>accepted()</signal>
99
   <receiver>SystemInfoDialog</receiver>
100
   <slot>accept()</slot>
101
   <hints>
102
    <hint type="sourcelabel">
103
     <x>248</x>
104
     <y>254</y>
105
    </hint>
106
    <hint type="destinationlabel">
107
     <x>157</x>
108
     <y>274</y>
109
    </hint>
110
   </hints>
111
  </connection>
112
  <connection>
113
   <sender>buttonBox</sender>
114
   <signal>rejected()</signal>
115
   <receiver>SystemInfoDialog</receiver>
116
   <slot>reject()</slot>
117
   <hints>
118
    <hint type="sourcelabel">
119
     <x>316</x>
120
     <y>260</y>
121
    </hint>
122
    <hint type="destinationlabel">
123
     <x>286</x>
124
     <y>274</y>
125
    </hint>
126
   </hints>
127
  </connection>
128
 </connections>
129
</ui>
HYTOS/HYTOS/UI/SystemInformation_UI.py
1
# -*- coding: utf-8 -*-
2

  
3
# Form implementation generated from reading ui file '.\UI\SystemInformation.ui'
4
#
5
# Created by: PyQt5 UI code generator 5.13.0
6
#
7
# WARNING! All changes made in this file will be lost!
8

  
9

  
10
from PyQt5 import QtCore, QtGui, QtWidgets
11

  
12

  
13
class Ui_SystemInfoDialog(object):
14
    def setupUi(self, SystemInfoDialog):
15
        SystemInfoDialog.setObjectName("SystemInfoDialog")
16
        SystemInfoDialog.resize(444, 280)
17
        self.gridLayout = QtWidgets.QGridLayout(SystemInfoDialog)
18
        self.gridLayout.setObjectName("gridLayout")
19
        self.groupBox = QtWidgets.QGroupBox(SystemInfoDialog)
20
        self.groupBox.setObjectName("groupBox")
21
        self.gridLayout_3 = QtWidgets.QGridLayout(self.groupBox)
22
        self.gridLayout_3.setObjectName("gridLayout_3")
23
        self.gridLayout_2 = QtWidgets.QGridLayout()
24
        self.gridLayout_2.setObjectName("gridLayout_2")
25
        self.lineEditComputerName = QtWidgets.QLineEdit(self.groupBox)
26
        self.lineEditComputerName.setReadOnly(True)
27
        self.lineEditComputerName.setObjectName("lineEditComputerName")
28
        self.gridLayout_2.addWidget(self.lineEditComputerName, 1, 1, 1, 1)
29
        self.lineEditIP = QtWidgets.QLineEdit(self.groupBox)
30
        self.lineEditIP.setReadOnly(True)
31
        self.lineEditIP.setObjectName("lineEditIP")
32
        self.gridLayout_2.addWidget(self.lineEditIP, 2, 1, 1, 1)
33
        self.label_3 = QtWidgets.QLabel(self.groupBox)
34
        self.label_3.setObjectName("label_3")
35
        self.gridLayout_2.addWidget(self.label_3, 1, 0, 1, 1)
36
        self.label = QtWidgets.QLabel(self.groupBox)
37
        self.label.setObjectName("label")
38
        self.gridLayout_2.addWidget(self.label, 0, 0, 1, 1)
39
        self.label_2 = QtWidgets.QLabel(self.groupBox)
40
        self.label_2.setObjectName("label_2")
41
        self.gridLayout_2.addWidget(self.label_2, 2, 0, 1, 1)
42
        self.lineEditUserName = QtWidgets.QLineEdit(self.groupBox)
43
        self.lineEditUserName.setObjectName("lineEditUserName")
44
        self.gridLayout_2.addWidget(self.lineEditUserName, 0, 1, 1, 1)
45
        self.label_4 = QtWidgets.QLabel(self.groupBox)
46
        self.label_4.setObjectName("label_4")
47
        self.gridLayout_2.addWidget(self.label_4, 3, 0, 1, 1)
48
        self.textEditComputerInformation = QtWidgets.QTextEdit(self.groupBox)
49
        self.textEditComputerInformation.setReadOnly(True)
50
        self.textEditComputerInformation.setObjectName("textEditComputerInformation")
51
        self.gridLayout_2.addWidget(self.textEditComputerInformation, 3, 1, 1, 1)
52
        self.gridLayout_3.addLayout(self.gridLayout_2, 0, 0, 1, 1)
53
        self.gridLayout.addWidget(self.groupBox, 0, 0, 1, 1)
54
        self.buttonBox = QtWidgets.QDialogButtonBox(SystemInfoDialog)
55
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
56
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
57
        self.buttonBox.setObjectName("buttonBox")
58
        self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1)
59

  
60
        self.retranslateUi(SystemInfoDialog)
61
        self.buttonBox.accepted.connect(SystemInfoDialog.accept)
62
        self.buttonBox.rejected.connect(SystemInfoDialog.reject)
63
        QtCore.QMetaObject.connectSlotsByName(SystemInfoDialog)
64

  
65
    def retranslateUi(self, SystemInfoDialog):
66
        _translate = QtCore.QCoreApplication.translate
67
        SystemInfoDialog.setWindowTitle(_translate("SystemInfoDialog", "System Information"))
68
        self.groupBox.setTitle(_translate("SystemInfoDialog", "System Information"))
69
        self.label_3.setText(_translate("SystemInfoDialog", "Computer Name : "))
70
        self.label.setText(_translate("SystemInfoDialog", "User Name : "))
71
        self.label_2.setText(_translate("SystemInfoDialog", "IP : "))
72
        self.label_4.setText(_translate("SystemInfoDialog", "Computer Information : "))

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)