支持选择目录

This commit is contained in:
halliday2023 2024-02-15 00:51:43 +08:00
parent 2e5622e4d5
commit 7bc70b6984
3 changed files with 221 additions and 112 deletions

View File

@ -9,7 +9,7 @@ from pathlib import Path
from PySide6.QtUiTools import QUiLoader from PySide6.QtUiTools import QUiLoader
from PySide6.QtCore import Signal, QThread, QObject, QEventLoop, QTimer from PySide6.QtCore import Signal, QThread, QObject, QEventLoop, QTimer
from PySide6.QtWidgets import QApplication from PySide6.QtWidgets import QApplication,QFileDialog
from PySide6.QtGui import QTextCursor from PySide6.QtGui import QTextCursor
# 声明全局变量 # 声明全局变量
@ -62,6 +62,7 @@ class Window:
self.ui.startButton.clicked.connect(self.start) self.ui.startButton.clicked.connect(self.start)
self.ui.stopButton.clicked.connect(self.stop) self.ui.stopButton.clicked.connect(self.stop)
self.ui.conn_Button.clicked.connect(self.conntest) self.ui.conn_Button.clicked.connect(self.conntest)
self.ui.choosedir_Button.clicked.connect(self.choosedir)
self.setup_thread() self.setup_thread()
@ -131,6 +132,13 @@ class Window:
# TODO(MH):校验连接信息 # TODO(MH):校验连接信息
self.logger.info("数据库连接成功") self.logger.info("数据库连接成功")
def choosedir(self):
self.logger.info("点击了选择目录按钮")
dir_path = QFileDialog.getExistingDirectory(self.ui, "选择目录", "", QFileDialog.ShowDirsOnly)
self.ui.fileOutputText.setText(dir_path)
self.logger.info("已经选择文件夹:{}".format(dir_path))
def setup_thread(self): def setup_thread(self):
self.thread = FileThread() self.thread = FileThread()
global_var.set_value('start_flag', True) global_var.set_value('start_flag', True)

View File

@ -2,6 +2,10 @@
font-family: 宋体; font-family: 宋体;
font-size: 15px; font-size: 15px;
} }
QLineEdit{
border:1px solid;
}
#Log_Output{ #Log_Output{
margin: 10px 5px 5px 2px; margin: 10px 5px 5px 2px;
} }

View File

@ -13,9 +13,6 @@
<property name="windowTitle"> <property name="windowTitle">
<string>DataCreating</string> <string>DataCreating</string>
</property> </property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout_7"> <layout class="QHBoxLayout" name="horizontalLayout_7">
<item> <item>
@ -39,107 +36,158 @@
<property name="title"> <property name="title">
<string>基本信息:</string> <string>基本信息:</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <widget class="QWidget" name="layoutWidget">
<item> <property name="geometry">
<layout class="QHBoxLayout" name="horizontalLayout_5" stretch="0,0,1"> <rect>
<item> <x>11</x>
<layout class="QVBoxLayout" name="verticalLayout_6" stretch="0,0,0,1"> <y>20</y>
<item> <width>378</width>
<widget class="QLabel" name="filename_label"> <height>132</height>
<property name="text"> </rect>
<string>文件名</string> </property>
</property> <layout class="QHBoxLayout" name="horizontalLayout_11">
</widget> <item>
</item> <layout class="QVBoxLayout" name="verticalLayout_6" stretch="0,0,0,1">
<item> <item>
<widget class="QLabel" name="output_label"> <widget class="QLabel" name="filename_label">
<property name="text"> <property name="text">
<string>输出路径</string> <string>文件名</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="fileinit_label"> <widget class="QLabel" name="output_label">
<property name="text"> <property name="text">
<string>初始数据量</string> <string>输出路径</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer_2"> <widget class="QLabel" name="fileinit_label">
<property name="orientation"> <property name="text">
<enum>Qt::Vertical</enum> <string>初始数据量</string>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size> </item>
<width>20</width> <item>
<height>40</height> <spacer name="verticalSpacer_2">
</size> <property name="orientation">
</property> <enum>Qt::Vertical</enum>
</spacer> </property>
</item> <property name="sizeHint" stdset="0">
</layout> <size>
</item> <width>20</width>
<item> <height>40</height>
<layout class="QVBoxLayout" name="verticalLayout_7"> </size>
<item> </property>
<widget class="QLineEdit" name="fileNameText"> </spacer>
<property name="text"> </item>
<string>filetest</string> </layout>
</property> </item>
<property name="placeholderText"> <item>
<string>文件名</string> <layout class="QVBoxLayout" name="verticalLayout_4">
</property> <item>
</widget> <layout class="QHBoxLayout" name="horizontalLayout_5" stretch="0,0">
</item> <item>
<item> <widget class="QLineEdit" name="fileNameText">
<widget class="QLineEdit" name="fileOutputText"> <property name="text">
<property name="placeholderText"> <string>filetest</string>
<string>默认:./data</string> </property>
</property> <property name="placeholderText">
</widget> <string>文件名</string>
</item> </property>
<item> </widget>
<widget class="QLineEdit" name="fileInitRowsText"> </item>
<property name="text"> <item>
<string>10</string> <spacer name="horizontalSpacer_7">
</property> <property name="orientation">
<property name="placeholderText"> <enum>Qt::Horizontal</enum>
<string/> </property>
</property> <property name="sizeHint" stdset="0">
</widget> <size>
</item> <width>24</width>
<item> <height>20</height>
<spacer name="verticalSpacer"> </size>
<property name="orientation"> </property>
<enum>Qt::Vertical</enum> </spacer>
</property> </item>
<property name="sizeHint" stdset="0"> </layout>
<size> </item>
<width>20</width> <item>
<height>40</height> <layout class="QHBoxLayout" name="horizontalLayout_9" stretch="5,0">
</size> <item>
</property> <widget class="QLineEdit" name="fileOutputText">
</spacer> <property name="placeholderText">
</item> <string>默认:./data</string>
</layout> </property>
</item> </widget>
<item> </item>
<spacer name="horizontalSpacer_4"> <item>
<property name="orientation"> <widget class="QPushButton" name="choosedir_Button">
<enum>Qt::Horizontal</enum> <property name="text">
</property> <string>选择目录</string>
<property name="sizeHint" stdset="0"> </property>
<size> </widget>
<width>40</width> </item>
<height>20</height> </layout>
</size> </item>
</property> <item>
</spacer> <layout class="QHBoxLayout" name="horizontalLayout_10">
</item> <item>
</layout> <widget class="QLineEdit" name="fileInitRowsText">
</item> <property name="text">
</layout> <string>10</string>
</property>
<property name="placeholderText">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
<item> <item>
@ -235,7 +283,7 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name=""> <widget class="QWidget" name="layoutWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>12</x> <x>12</x>
@ -680,8 +728,8 @@
<y>301</y> <y>301</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>167</x> <x>181</x>
<y>331</y> <y>403</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -692,8 +740,8 @@
<slot>start()</slot> <slot>start()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>98</x> <x>150</x>
<y>526</y> <y>601</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>153</x> <x>153</x>
@ -708,8 +756,8 @@
<slot>stop()</slot> <slot>stop()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>431</x> <x>356</x>
<y>531</y> <y>601</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>492</x> <x>492</x>
@ -733,10 +781,59 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>tabWidget</sender>
<signal>tabBarClicked(int)</signal>
<receiver>db_servername_label</receiver>
<slot>hide()</slot>
<hints>
<hint type="sourcelabel">
<x>88</x>
<y>45</y>
</hint>
<hint type="destinationlabel">
<x>66</x>
<y>156</y>
</hint>
</hints>
</connection>
<connection>
<sender>db_type_Box</sender>
<signal>currentTextChanged(QString)</signal>
<receiver>db_servername_label</receiver>
<slot>show()</slot>
<hints>
<hint type="sourcelabel">
<x>151</x>
<y>104</y>
</hint>
<hint type="destinationlabel">
<x>78</x>
<y>154</y>
</hint>
</hints>
</connection>
<connection>
<sender>choosedir_Button</sender>
<signal>clicked(bool)</signal>
<receiver>MainWindow</receiver>
<slot>choosedir()</slot>
<hints>
<hint type="sourcelabel">
<x>302</x>
<y>137</y>
</hint>
<hint type="destinationlabel">
<x>428</x>
<y>31</y>
</hint>
</hints>
</connection>
</connections> </connections>
<slots> <slots>
<slot>start()</slot> <slot>start()</slot>
<slot>stop()</slot> <slot>stop()</slot>
<slot>conntest()</slot> <slot>conntest()</slot>
<slot>choosedir()</slot>
</slots> </slots>
</ui> </ui>