Skip to content

Commit

Permalink
20241026
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-ShiRui committed Oct 26, 2024
1 parent 3bc8de0 commit 2b23d51
Show file tree
Hide file tree
Showing 19 changed files with 980 additions and 353 deletions.
2 changes: 1 addition & 1 deletion config.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[Settings]
language = 0

version = 2.1.0
78 changes: 74 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,91 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import configparser
from PySide6.QtWidgets import QApplication, QSplashScreen
from PySide6.QtGui import QPixmap
from PySide6.QtCore import QCoreApplication, QDir, QTranslator, QLocale
from src.mainwindow import MainWindow # Import MainWindow from src

if __name__ == "__main__":
app = QApplication([])

# Set the current directory to the application's install directory
install_dir = QCoreApplication.applicationDirPath()
QDir.setCurrent(install_dir)

# Create and install the translator
translator = QTranslator()
translation_file = QDir(install_dir).filePath("translations/MUSE.zh_CN.qm")

config = configparser.ConfigParser()
try:
# Try to read the config.ini file
config.read('config.ini')
if 'Settings' in config and 'Language' in config['Settings']:
if config['Settings']['Language'] == '1':
# Create and install the translator
translator = QTranslator()
if translator.load("translations/MUSE.zh_CN.qm"):
app.installTranslator(translator)

except FileNotFoundError:
config['Settings'] = {'Language': '0'} # default language is '0'

# Show splash screen
splash_pix = QPixmap(":/png/loading.png")
splash = QSplashScreen(splash_pix)
splash.show()

window = MainWindow()

splash.finish(window)
# Create and show main window
window = MainWindow(config)

splash.finish(window)
window.show()

# Run the application
app.exec()


# if __name__ == "__main__":
# app = QApplication([])

# config = configparser.ConfigParser()

# try:
# # Try to read the config.ini file
# config.read('config.ini')

# # Check if 'Settings' section and 'Language' option exist
# if 'Settings' in config and 'Language' in config['Settings']:
# if config['Settings']['Language'] == '1':
# # Create and install the translator
# translator = QTranslator()
# if translator.load("translations/MUSE.zh_CN.qm"):
# app.installTranslator(translator)
# else:
# print("Warning: The configuration file is missing the 'Settings' section or 'Language' option. Using default settings.")

# except FileNotFoundError:
# print("Warning: config.ini file does not exist. Using default settings.")
# # Use default settings
# config['Settings'] = {'Language': '0'} # default language is '0'

# except Exception as e:
# print(f"An error occurred: {e}")

# # Show splash screen
# splash_pix = QPixmap(":/png/loading.png")
# splash = QSplashScreen(splash_pix)
# splash.show()

# # Create and show main window
# window = MainWindow(config)

# splash.finish(window)
# window.show()

# # Run the application
# app.exec()


15 changes: 15 additions & 0 deletions program.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
2024-10-24 14:44:50,850 - ERROR - Error while setting language to English: 'MainWindow' object has no attribute 'config'
2024-10-24 14:44:53,865 - ERROR - Error while setting language to English: 'MainWindow' object has no attribute 'config'
2024-10-24 14:46:50,517 - ERROR - Error while setting language to English: 'MainWindow' object has no attribute 'config'
2024-10-24 14:46:55,778 - ERROR - Error while setting language to English: 'MainWindow' object has no attribute 'config'
2024-10-24 15:12:33,751 - ERROR - Error while setting language to English: 'MainWindow' object has no attribute 'config'
2024-10-24 15:12:36,567 - ERROR - Error while setting language to English: 'MainWindow' object has no attribute 'config'
2024-10-24 15:14:12,465 - ERROR - Error while setting language to English: 'MainWindow' object has no attribute 'config'
2024-10-24 15:14:33,851 - ERROR - Error while setting language to English: 'MainWindow' object has no attribute 'config'
2024-10-24 15:14:35,681 - ERROR - Error while setting language to English: 'MainWindow' object has no attribute 'config'
2024-10-24 15:16:24,032 - ERROR - Error while setting language to English: 'MainWindow' object has no attribute 'config'
2024-10-24 15:44:20,178 - ERROR - Error while setting language to English: 'MainWindow' object has no attribute 'config'
2024-10-24 16:22:35,303 - ERROR - Error while setting language to English: 'Settings'
2024-10-24 16:22:38,388 - ERROR - Error while setting language to English: 'Settings'
2024-10-24 16:22:42,977 - ERROR - Error while setting language to English: 'Settings'
2024-10-24 16:23:47,661 - ERROR - Error while setting language to English: 'Settings'
Binary file modified resources/qrc/__pycache__/res_rc.cpython-311.pyc
Binary file not shown.
72 changes: 65 additions & 7 deletions resources/ui/UDSA.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Urban Development Suitability Assessment (UDSA) module</string>
</property>
<property name="styleSheet">
<string notr="true"/>
Expand Down Expand Up @@ -266,20 +266,58 @@
<widget class="QComboBox" name="comboBox_03">
<property name="minimumSize">
<size>
<width>0</width>
<width>138</width>
<height>25</height>
</size>
</property>
<property name="currentText">
<string/>
<string>XGBoost</string>
</property>
<item>
<property name="text">
<string>XGBoost</string>
</property>
</item>
<item>
<property name="text">
<string>Random Forest</string>
</property>
</item>
<item>
<property name="text">
<string>SVM</string>
</property>
</item>
<item>
<property name="text">
<string>MLP</string>
</property>
</item>
<item>
<property name="text">
<string>Naive Bayes</string>
</property>
</item>
<item>
<property name="text">
<string>Logistic Regression</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_03_random_samples"/>
<widget class="QLineEdit" name="lineEdit_03_random_samples">
<property name="placeholderText">
<string>Number of random samples</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_03_sample_ratio"/>
<widget class="QLineEdit" name="lineEdit_03_sample_ratio">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
Expand Down Expand Up @@ -380,7 +418,11 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLineEdit" name="lineEdit_03_save"/>
<widget class="QLineEdit" name="lineEdit_03_save">
<property name="placeholderText">
<string>Enter save path for training data (csv or txt)</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_03_save">
Expand Down Expand Up @@ -557,7 +599,14 @@
<number>9</number>
</property>
<item>
<widget class="QLineEdit" name="lineEdit_05_save_path"/>
<widget class="QLineEdit" name="lineEdit_05_save_path">
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>Enter save path for prediction results (tif or tiff)</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="button_05_save">
Expand Down Expand Up @@ -591,6 +640,12 @@
</layout>
</widget>
<widget class="MyTextBrowser" name="textBrowser_06_output">
<property name="minimumSize">
<size>
<width>138</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
Expand All @@ -607,6 +662,9 @@ li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="placeholderText">
<string>Run Information Output...</string>
</property>
</widget>
</widget>
</item>
Expand Down
26 changes: 23 additions & 3 deletions resources/ui/UDSA_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,14 @@ def setupUi(self, UDSA):
self.verticalLayout_10 = QVBoxLayout(self.frame_7)
self.verticalLayout_10.setObjectName(u"verticalLayout_10")
self.comboBox_03 = QComboBox(self.frame_7)
self.comboBox_03.addItem("")
self.comboBox_03.addItem("")
self.comboBox_03.addItem("")
self.comboBox_03.addItem("")
self.comboBox_03.addItem("")
self.comboBox_03.addItem("")
self.comboBox_03.setObjectName(u"comboBox_03")
self.comboBox_03.setMinimumSize(QSize(0, 25))
self.comboBox_03.setMinimumSize(QSize(138, 25))

self.verticalLayout_10.addWidget(self.comboBox_03)

Expand Down Expand Up @@ -422,6 +428,7 @@ def setupUi(self, UDSA):
self.splitter.addWidget(self.frame_2)
self.textBrowser_06_output = MyTextBrowser(self.splitter)
self.textBrowser_06_output.setObjectName(u"textBrowser_06_output")
self.textBrowser_06_output.setMinimumSize(QSize(138, 0))
self.textBrowser_06_output.setMaximumSize(QSize(16777215, 16777215))
self.splitter.addWidget(self.textBrowser_06_output)

Expand All @@ -434,7 +441,7 @@ def setupUi(self, UDSA):
# setupUi

def retranslateUi(self, UDSA):
UDSA.setWindowTitle(QCoreApplication.translate("UDSA", u"Dialog", None))
UDSA.setWindowTitle(QCoreApplication.translate("UDSA", u"Urban Development Suitability Assessment (UDSA) module", None))
self.groupBox.setTitle(QCoreApplication.translate("UDSA", u"Driver Factors Input", None))
self.button_01_add.setText("")
self.button_01_del.setText("")
Expand All @@ -445,10 +452,20 @@ def retranslateUi(self, UDSA):
self.label.setText(QCoreApplication.translate("UDSA", u"Model Selection", None))
self.label_2.setText(QCoreApplication.translate("UDSA", u"Random Samples", None))
self.label_7.setText(QCoreApplication.translate("UDSA", u"Test Data Ratio", None))
self.comboBox_03.setCurrentText("")
self.comboBox_03.setItemText(0, QCoreApplication.translate("UDSA", u"XGBoost", None))
self.comboBox_03.setItemText(1, QCoreApplication.translate("UDSA", u"Random Forest", None))
self.comboBox_03.setItemText(2, QCoreApplication.translate("UDSA", u"SVM", None))
self.comboBox_03.setItemText(3, QCoreApplication.translate("UDSA", u"MLP", None))
self.comboBox_03.setItemText(4, QCoreApplication.translate("UDSA", u"Naive Bayes", None))
self.comboBox_03.setItemText(5, QCoreApplication.translate("UDSA", u"Logistic Regression", None))

self.comboBox_03.setCurrentText(QCoreApplication.translate("UDSA", u"XGBoost", None))
self.lineEdit_03_random_samples.setPlaceholderText(QCoreApplication.translate("UDSA", u"Number of random samples", None))
self.lineEdit_03_sample_ratio.setText("")
self.checkBox_03_cv.setText(QCoreApplication.translate("UDSA", u"Cross Validation", None))
self.checkBox_03_thread.setText(QCoreApplication.translate("UDSA", u"Multithreading", None))
self.checkBox_03_save.setText(QCoreApplication.translate("UDSA", u"Save Training Data", None))
self.lineEdit_03_save.setPlaceholderText(QCoreApplication.translate("UDSA", u"Enter save path for training data (csv or txt)", None))
self.toolButton_03_save.setText(QCoreApplication.translate("UDSA", u"...", None))
self.groupBox_4.setTitle(QCoreApplication.translate("UDSA", u"Model Parameters", None))
self.label_041.setText(QCoreApplication.translate("UDSA", u"TextLabel", None))
Expand All @@ -459,6 +476,8 @@ def retranslateUi(self, UDSA):
self.button_04_fetch.setText(QCoreApplication.translate("UDSA", u"Fetch and Train", None))
self.button_04_train.setText(QCoreApplication.translate("UDSA", u"Train", None))
self.groupBox_5.setTitle(QCoreApplication.translate("UDSA", u"Prediction", None))
self.lineEdit_05_save_path.setText("")
self.lineEdit_05_save_path.setPlaceholderText(QCoreApplication.translate("UDSA", u"Enter save path for prediction results (tif or tiff)", None))
self.button_05_save.setText(QCoreApplication.translate("UDSA", u"...", None))
self.button_05_predict.setText(QCoreApplication.translate("UDSA", u"Start Prediction", None))
self.textBrowser_06_output.setHtml(QCoreApplication.translate("UDSA", u"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
Expand All @@ -469,5 +488,6 @@ def retranslateUi(self, UDSA):
"li.checked::marker { content: \"\\2612\"; }\n"
"</style></head><body style=\" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>", None))
self.textBrowser_06_output.setPlaceholderText(QCoreApplication.translate("UDSA", u"Run Information Output...", None))
# retranslateUi

Binary file modified resources/ui/__pycache__/UDSA_ui.cpython-311.pyc
Binary file not shown.
Binary file modified resources/ui/__pycache__/mainwindow_ui.cpython-311.pyc
Binary file not shown.
Loading

0 comments on commit 2b23d51

Please sign in to comment.