更新数据导入工具(continue)

This commit is contained in:
fasiondog 2020-10-23 00:01:25 +08:00
parent 4e17244f18
commit 92a4b176d6
3 changed files with 164 additions and 60 deletions

View File

@ -146,12 +146,33 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
#初始化hdf5设置
hdf5_enable = import_config.getboolean('hdf5', 'enable', fallback=True)
self.enable_hdf55_radioButton.setChecked(hdf5_enable)
hdf5_dir = import_config.get(
'hdf5',
'dir',
fallback="c:\stock" if sys.platform == "win32" else os.path.expanduser('~') + "/stock"
)
self.hdf5_dir_lineEdit.setText(hdf5_dir)
self.hdf5_dir_lineEdit.setEnabled(hdf5_enable)
#初始化MYSQL设置
mysql_enable = import_config.getboolean('mysql', 'enable', fallback=False)
if hdf5_enable:
mysql_enable = False
self.enable_mysql_radioButton.setChecked(mysql_enable)
mysql_ip = import_config.get('mysql', 'ip', fallback='127.0.0.1')
self.mysql_ip_lineEdit.setText(mysql_ip)
self.mysql_ip_lineEdit.setEnabled(mysql_enable)
mysql_port = import_config.get('mysql', 'port', fallback='3306')
self.mysql_port_lineEdit.setText(mysql_port)
self.mysql_port_lineEdit.setEnabled(mysql_enable)
mysql_usr = import_config.get('mysql', 'usr', fallback='root')
self.mysql_usr_lineEdit.setText(mysql_usr)
self.mysql_usr_lineEdit.setEnabled(mysql_enable)
mysql_pwd = import_config.get('mysql', 'pwd', fallback='')
self.mysql_pwd_lineEdit.setText(mysql_pwd)
self.mysql_pwd_lineEdit.setEnabled(mysql_enable)
self.mysql_test_pushButton.setEnabled(mysql_enable)
self.on_tdx_or_pytdx_toggled()
@ -185,7 +206,17 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
'enable': self.pytdx_radioButton.isChecked(),
'use_tdx_number': self.use_tdx_number_spinBox.value()
}
import_config['hdf5'] = {'enable': True, 'dir': self.hdf5_dir_lineEdit.text()}
import_config['hdf5'] = {
'enable': self.enable_hdf55_radioButton.isChecked(),
'dir': self.hdf5_dir_lineEdit.text()
}
import_config['mysql'] = {
'enable': self.enable_mysql_radioButton.isChecked(),
'ip': self.mysql_ip_lineEdit.text(),
'port': self.mysql_port_lineEdit.text(),
'usr': self.mysql_usr_lineEdit.text(),
'pwd': self.mysql_pwd_lineEdit.text()
}
return import_config
def initThreads(self):
@ -242,6 +273,28 @@ class MyMainWindow(QMainWindow, Ui_MainWindow):
dirname = dlg.selectedFiles()
self.hdf5_dir_lineEdit.setText(dirname[0])
@pyqtSlot()
def on_enable_hdf55_radioButton_clicked(self):
if self.enable_hdf55_radioButton.isChecked():
self.enable_mysql_radioButton.setChecked(False)
self.on_enable_hdf5_or_mysql_toggled()
@pyqtSlot()
def on_enable_mysql_radioButton_clicked(self):
if self.enable_mysql_radioButton.isChecked():
self.enable_hdf55_radioButton.setChecked(False)
self.on_enable_hdf5_or_mysql_toggled()
def on_enable_hdf5_or_mysql_toggled(self):
hdf5_enable = self.enable_hdf55_radioButton.isChecked()
mysql_enable = not hdf5_enable
self.hdf5_dir_lineEdit.setEnabled(hdf5_enable)
self.mysql_ip_lineEdit.setEnabled(mysql_enable)
self.mysql_port_lineEdit.setEnabled(mysql_enable)
self.mysql_usr_lineEdit.setEnabled(mysql_enable)
self.mysql_pwd_lineEdit.setEnabled(mysql_enable)
self.mysql_test_pushButton.setEnabled(mysql_enable)
def reset_progress_bar(self):
self.hdf5_weight_label.setText('')
self.hdf5_day_progressBar.setValue(0)

View File

@ -14,7 +14,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(638, 559)
MainWindow.resize(593, 559)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
@ -23,10 +23,10 @@ class Ui_MainWindow(object):
self.tab_4 = QtWidgets.QWidget()
self.tab_4.setObjectName("tab_4")
self.groupBox_2 = QtWidgets.QGroupBox(self.tab_4)
self.groupBox_2.setGeometry(QtCore.QRect(20, 20, 481, 131))
self.groupBox_2.setGeometry(QtCore.QRect(20, 20, 551, 131))
self.groupBox_2.setObjectName("groupBox_2")
self.layoutWidget_3 = QtWidgets.QWidget(self.groupBox_2)
self.layoutWidget_3.setGeometry(QtCore.QRect(20, 90, 451, 25))
self.layoutWidget_3.setGeometry(QtCore.QRect(20, 90, 521, 25))
self.layoutWidget_3.setObjectName("layoutWidget_3")
self.gridLayout_2 = QtWidgets.QGridLayout(self.layoutWidget_3)
self.gridLayout_2.setContentsMargins(0, 0, 0, 0)
@ -49,7 +49,7 @@ class Ui_MainWindow(object):
self.tdx_radioButton.setGeometry(QtCore.QRect(20, 70, 481, 16))
self.tdx_radioButton.setObjectName("tdx_radioButton")
self.layoutWidget_4 = QtWidgets.QWidget(self.groupBox_2)
self.layoutWidget_4.setGeometry(QtCore.QRect(20, 30, 371, 22))
self.layoutWidget_4.setGeometry(QtCore.QRect(20, 30, 411, 22))
self.layoutWidget_4.setObjectName("layoutWidget_4")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.layoutWidget_4)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
@ -71,7 +71,7 @@ class Ui_MainWindow(object):
self.label_17.setObjectName("label_17")
self.horizontalLayout.addWidget(self.label_17)
self.groupBox_7 = QtWidgets.QGroupBox(self.tab_4)
self.groupBox_7.setGeometry(QtCore.QRect(20, 170, 481, 261))
self.groupBox_7.setGeometry(QtCore.QRect(20, 170, 551, 261))
self.groupBox_7.setObjectName("groupBox_7")
self.layoutWidget_5 = QtWidgets.QWidget(self.groupBox_7)
self.layoutWidget_5.setGeometry(QtCore.QRect(20, 60, 155, 18))
@ -168,59 +168,68 @@ class Ui_MainWindow(object):
self.tab_3 = QtWidgets.QWidget()
self.tab_3.setObjectName("tab_3")
self.groupBox = QtWidgets.QGroupBox(self.tab_3)
self.groupBox.setGeometry(QtCore.QRect(20, 120, 551, 191))
self.groupBox.setGeometry(QtCore.QRect(20, 250, 551, 191))
self.groupBox.setObjectName("groupBox")
self.widget = QtWidgets.QWidget(self.groupBox)
self.widget.setGeometry(QtCore.QRect(20, 30, 371, 131))
self.widget.setObjectName("widget")
self.gridLayout_5 = QtWidgets.QGridLayout(self.widget)
self.layoutWidget = QtWidgets.QWidget(self.groupBox)
self.layoutWidget.setGeometry(QtCore.QRect(20, 30, 401, 131))
self.layoutWidget.setObjectName("layoutWidget")
self.gridLayout_5 = QtWidgets.QGridLayout(self.layoutWidget)
self.gridLayout_5.setContentsMargins(0, 0, 0, 0)
self.gridLayout_5.setObjectName("gridLayout_5")
self.label_18 = QtWidgets.QLabel(self.widget)
self.label_18 = QtWidgets.QLabel(self.layoutWidget)
self.label_18.setObjectName("label_18")
self.gridLayout_5.addWidget(self.label_18, 0, 0, 1, 1)
self.lineEdit = QtWidgets.QLineEdit(self.widget)
self.lineEdit.setObjectName("lineEdit")
self.gridLayout_5.addWidget(self.lineEdit, 0, 1, 1, 1)
self.label_19 = QtWidgets.QLabel(self.widget)
self.mysql_ip_lineEdit = QtWidgets.QLineEdit(self.layoutWidget)
self.mysql_ip_lineEdit.setObjectName("mysql_ip_lineEdit")
self.gridLayout_5.addWidget(self.mysql_ip_lineEdit, 0, 1, 1, 1)
self.label_19 = QtWidgets.QLabel(self.layoutWidget)
self.label_19.setObjectName("label_19")
self.gridLayout_5.addWidget(self.label_19, 1, 0, 1, 1)
self.lineEdit_2 = QtWidgets.QLineEdit(self.widget)
self.lineEdit_2.setObjectName("lineEdit_2")
self.gridLayout_5.addWidget(self.lineEdit_2, 1, 1, 1, 1)
self.label_11 = QtWidgets.QLabel(self.widget)
self.mysql_port_lineEdit = QtWidgets.QLineEdit(self.layoutWidget)
self.mysql_port_lineEdit.setObjectName("mysql_port_lineEdit")
self.gridLayout_5.addWidget(self.mysql_port_lineEdit, 1, 1, 1, 1)
self.label_11 = QtWidgets.QLabel(self.layoutWidget)
self.label_11.setObjectName("label_11")
self.gridLayout_5.addWidget(self.label_11, 2, 0, 1, 1)
self.lineEdit_3 = QtWidgets.QLineEdit(self.widget)
self.lineEdit_3.setObjectName("lineEdit_3")
self.gridLayout_5.addWidget(self.lineEdit_3, 2, 1, 1, 1)
self.label_13 = QtWidgets.QLabel(self.widget)
self.mysql_usr_lineEdit = QtWidgets.QLineEdit(self.layoutWidget)
self.mysql_usr_lineEdit.setObjectName("mysql_usr_lineEdit")
self.gridLayout_5.addWidget(self.mysql_usr_lineEdit, 2, 1, 1, 1)
self.label_13 = QtWidgets.QLabel(self.layoutWidget)
self.label_13.setObjectName("label_13")
self.gridLayout_5.addWidget(self.label_13, 3, 0, 1, 1)
self.lineEdit_4 = QtWidgets.QLineEdit(self.widget)
self.lineEdit_4.setObjectName("lineEdit_4")
self.gridLayout_5.addWidget(self.lineEdit_4, 3, 1, 1, 1)
self.pushButton = QtWidgets.QPushButton(self.groupBox)
self.pushButton.setGeometry(QtCore.QRect(420, 80, 75, 23))
self.pushButton.setObjectName("pushButton")
self.mysql_pwd_lineEdit = QtWidgets.QLineEdit(self.layoutWidget)
self.mysql_pwd_lineEdit.setObjectName("mysql_pwd_lineEdit")
self.gridLayout_5.addWidget(self.mysql_pwd_lineEdit, 3, 1, 1, 1)
self.mysql_test_pushButton = QtWidgets.QPushButton(self.groupBox)
self.mysql_test_pushButton.setGeometry(QtCore.QRect(450, 80, 75, 23))
self.mysql_test_pushButton.setObjectName("mysql_test_pushButton")
self.groupBox_3 = QtWidgets.QGroupBox(self.tab_3)
self.groupBox_3.setGeometry(QtCore.QRect(20, 20, 551, 71))
self.groupBox_3.setGeometry(QtCore.QRect(20, 130, 551, 71))
self.groupBox_3.setObjectName("groupBox_3")
self.layoutWidget = QtWidgets.QWidget(self.groupBox_3)
self.layoutWidget.setGeometry(QtCore.QRect(20, 30, 521, 25))
self.layoutWidget.setObjectName("layoutWidget")
self.gridLayout_3 = QtWidgets.QGridLayout(self.layoutWidget)
self.layoutWidget1 = QtWidgets.QWidget(self.groupBox_3)
self.layoutWidget1.setGeometry(QtCore.QRect(20, 30, 521, 25))
self.layoutWidget1.setObjectName("layoutWidget1")
self.gridLayout_3 = QtWidgets.QGridLayout(self.layoutWidget1)
self.gridLayout_3.setContentsMargins(0, 0, 0, 0)
self.gridLayout_3.setObjectName("gridLayout_3")
self.hdf5_dir_lineEdit = QtWidgets.QLineEdit(self.layoutWidget)
self.hdf5_dir_lineEdit = QtWidgets.QLineEdit(self.layoutWidget1)
self.hdf5_dir_lineEdit.setObjectName("hdf5_dir_lineEdit")
self.gridLayout_3.addWidget(self.hdf5_dir_lineEdit, 0, 1, 1, 1)
self.hdf5_dir_pushButton = QtWidgets.QPushButton(self.layoutWidget)
self.hdf5_dir_pushButton = QtWidgets.QPushButton(self.layoutWidget1)
self.hdf5_dir_pushButton.setObjectName("hdf5_dir_pushButton")
self.gridLayout_3.addWidget(self.hdf5_dir_pushButton, 0, 2, 1, 1)
self.label = QtWidgets.QLabel(self.layoutWidget)
self.label = QtWidgets.QLabel(self.layoutWidget1)
self.label.setObjectName("label")
self.gridLayout_3.addWidget(self.label, 0, 0, 1, 1)
self.groupBox_4 = QtWidgets.QGroupBox(self.tab_3)
self.groupBox_4.setGeometry(QtCore.QRect(20, 20, 551, 80))
self.groupBox_4.setObjectName("groupBox_4")
self.enable_hdf55_radioButton = QtWidgets.QRadioButton(self.groupBox_4)
self.enable_hdf55_radioButton.setGeometry(QtCore.QRect(30, 40, 89, 16))
self.enable_hdf55_radioButton.setObjectName("enable_hdf55_radioButton")
self.enable_mysql_radioButton = QtWidgets.QRadioButton(self.groupBox_4)
self.enable_mysql_radioButton.setGeometry(QtCore.QRect(130, 40, 89, 16))
self.enable_mysql_radioButton.setObjectName("enable_mysql_radioButton")
self.tabWidget.addTab(self.tab_3, "")
self.tab_2 = QtWidgets.QWidget()
self.tab_2.setObjectName("tab_2")
@ -228,10 +237,10 @@ class Ui_MainWindow(object):
self.start_import_pushButton.setGeometry(QtCore.QRect(30, 20, 75, 23))
self.start_import_pushButton.setObjectName("start_import_pushButton")
self.groupBox_5 = QtWidgets.QGroupBox(self.tab_2)
self.groupBox_5.setGeometry(QtCore.QRect(20, 70, 481, 451))
self.groupBox_5.setGeometry(QtCore.QRect(20, 70, 551, 451))
self.groupBox_5.setObjectName("groupBox_5")
self.layoutWidget_2 = QtWidgets.QWidget(self.groupBox_5)
self.layoutWidget_2.setGeometry(QtCore.QRect(10, 20, 461, 151))
self.layoutWidget_2.setGeometry(QtCore.QRect(10, 20, 531, 151))
self.layoutWidget_2.setObjectName("layoutWidget_2")
self.gridLayout = QtWidgets.QGridLayout(self.layoutWidget_2)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
@ -278,7 +287,7 @@ class Ui_MainWindow(object):
self.hdf5_weight_label.setObjectName("hdf5_weight_label")
self.gridLayout.addWidget(self.hdf5_weight_label, 5, 1, 1, 1)
self.import_detail_textEdit = QtWidgets.QTextEdit(self.groupBox_5)
self.import_detail_textEdit.setGeometry(QtCore.QRect(10, 180, 461, 261))
self.import_detail_textEdit.setGeometry(QtCore.QRect(10, 180, 531, 261))
self.import_detail_textEdit.setFrameShape(QtWidgets.QFrame.NoFrame)
self.import_detail_textEdit.setReadOnly(True)
self.import_detail_textEdit.setObjectName("import_detail_textEdit")
@ -323,10 +332,13 @@ class Ui_MainWindow(object):
self.label_19.setText(_translate("MainWindow", "端口号:"))
self.label_11.setText(_translate("MainWindow", "用户名:"))
self.label_13.setText(_translate("MainWindow", "密码"))
self.pushButton.setText(_translate("MainWindow", "测试连接"))
self.mysql_test_pushButton.setText(_translate("MainWindow", "测试连接"))
self.groupBox_3.setTitle(_translate("MainWindow", "HDF5存储设置"))
self.hdf5_dir_pushButton.setText(_translate("MainWindow", "选择"))
self.label.setText(_translate("MainWindow", "目标数据HDF5存放目录"))
self.groupBox_4.setTitle(_translate("MainWindow", "存储引擎设置"))
self.enable_hdf55_radioButton.setText(_translate("MainWindow", "使用HDF5"))
self.enable_mysql_radioButton.setText(_translate("MainWindow", "使用MYSQL"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), _translate("MainWindow", "存储设置"))
self.start_import_pushButton.setText(_translate("MainWindow", "执行导入"))
self.groupBox_5.setTitle(_translate("MainWindow", "导入进展"))

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>638</width>
<width>593</width>
<height>559</height>
</rect>
</property>
@ -35,7 +35,7 @@
<rect>
<x>20</x>
<y>20</y>
<width>481</width>
<width>551</width>
<height>131</height>
</rect>
</property>
@ -47,7 +47,7 @@
<rect>
<x>20</x>
<y>90</y>
<width>451</width>
<width>521</width>
<height>25</height>
</rect>
</property>
@ -95,7 +95,7 @@
<rect>
<x>20</x>
<y>30</y>
<width>371</width>
<width>411</width>
<height>22</height>
</rect>
</property>
@ -145,7 +145,7 @@
<rect>
<x>20</x>
<y>170</y>
<width>481</width>
<width>551</width>
<height>261</height>
</rect>
</property>
@ -372,7 +372,7 @@
<property name="geometry">
<rect>
<x>20</x>
<y>120</y>
<y>250</y>
<width>551</width>
<height>191</height>
</rect>
@ -380,12 +380,12 @@
<property name="title">
<string>MYSQL存储设置</string>
</property>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>371</width>
<width>401</width>
<height>131</height>
</rect>
</property>
@ -398,7 +398,7 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit"/>
<widget class="QLineEdit" name="mysql_ip_lineEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_19">
@ -408,7 +408,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_2"/>
<widget class="QLineEdit" name="mysql_port_lineEdit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_11">
@ -418,7 +418,7 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_3"/>
<widget class="QLineEdit" name="mysql_usr_lineEdit"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_13">
@ -428,14 +428,14 @@
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_4"/>
<widget class="QLineEdit" name="mysql_pwd_lineEdit"/>
</item>
</layout>
</widget>
<widget class="QPushButton" name="pushButton">
<widget class="QPushButton" name="mysql_test_pushButton">
<property name="geometry">
<rect>
<x>420</x>
<x>450</x>
<y>80</y>
<width>75</width>
<height>23</height>
@ -450,7 +450,7 @@
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<y>130</y>
<width>551</width>
<height>71</height>
</rect>
@ -488,6 +488,45 @@
</layout>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_4">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>551</width>
<height>80</height>
</rect>
</property>
<property name="title">
<string>存储引擎设置</string>
</property>
<widget class="QRadioButton" name="enable_hdf55_radioButton">
<property name="geometry">
<rect>
<x>30</x>
<y>40</y>
<width>89</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>使用HDF5</string>
</property>
</widget>
<widget class="QRadioButton" name="enable_mysql_radioButton">
<property name="geometry">
<rect>
<x>130</x>
<y>40</y>
<width>89</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>使用MYSQL</string>
</property>
</widget>
</widget>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
@ -511,7 +550,7 @@
<rect>
<x>20</x>
<y>70</y>
<width>481</width>
<width>551</width>
<height>451</height>
</rect>
</property>
@ -523,7 +562,7 @@
<rect>
<x>10</x>
<y>20</y>
<width>461</width>
<width>531</width>
<height>151</height>
</rect>
</property>
@ -619,7 +658,7 @@
<rect>
<x>10</x>
<y>180</y>
<width>461</width>
<width>531</width>
<height>261</height>
</rect>
</property>