支持选择目录

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.QtCore import Signal, QThread, QObject, QEventLoop, QTimer
from PySide6.QtWidgets import QApplication
from PySide6.QtWidgets import QApplication,QFileDialog
from PySide6.QtGui import QTextCursor
# 声明全局变量
@ -62,6 +62,7 @@ class Window:
self.ui.startButton.clicked.connect(self.start)
self.ui.stopButton.clicked.connect(self.stop)
self.ui.conn_Button.clicked.connect(self.conntest)
self.ui.choosedir_Button.clicked.connect(self.choosedir)
self.setup_thread()
@ -131,6 +132,13 @@ class Window:
# TODO(MH):校验连接信息
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):
self.thread = FileThread()
global_var.set_value('start_flag', True)

View File

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

View File

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