Skip to content

Commit

Permalink
added a welcome interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-ShiRui committed Nov 14, 2024
1 parent 83585ed commit dc8d031
Show file tree
Hide file tree
Showing 13 changed files with 393 additions and 69 deletions.
3 changes: 2 additions & 1 deletion config.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[Settings]
language = 0
version = 2.1.1
version = 2.1.2
never_show = 0

46 changes: 46 additions & 0 deletions debug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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([])

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()
47 changes: 2 additions & 45 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# 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
Expand Down Expand Up @@ -64,48 +65,4 @@
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()


app.exec()
17 changes: 1 addition & 16 deletions program.log
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
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'
2024-10-26 23:03:34,321 - ERROR - Failed to open the file: Guide_ENG.pdf

Binary file modified resources/qrc/__pycache__/res_rc.cpython-311.pyc
Binary file not shown.
Binary file modified resources/ui/__pycache__/mainwindow_ui.cpython-311.pyc
Binary file not shown.
Binary file not shown.
5 changes: 4 additions & 1 deletion resources/ui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -642,11 +642,14 @@
</property>
<item>
<widget class="QCheckBox" name="checkBox_03_organic_by_step">
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="text">
<string>Enable Stepwise Organic Growth</string>
</property>
<property name="checked">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>
Expand Down
3 changes: 2 additions & 1 deletion resources/ui/mainwindow_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ def setupUi(self, MainWindow):
self.horizontalLayout_12.setSizeConstraint(QLayout.SizeConstraint.SetFixedSize)
self.checkBox_03_organic_by_step = QCheckBox(self.box_03_model_parameters)
self.checkBox_03_organic_by_step.setObjectName(u"checkBox_03_organic_by_step")
self.checkBox_03_organic_by_step.setChecked(True)
self.checkBox_03_organic_by_step.setMouseTracking(True)
self.checkBox_03_organic_by_step.setChecked(False)

self.horizontalLayout_12.addWidget(self.checkBox_03_organic_by_step)

Expand Down
168 changes: 168 additions & 0 deletions resources/ui/welcome.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Welcome</class>
<widget class="QDialog" name="Welcome">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>711</width>
<height>191</height>
</rect>
</property>
<property name="windowTitle">
<string>Welcome - Version Info</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="lineWidth">
<number>1</number>
</property>
<property name="text">
<string>Welcome to MUSE Software - Version 1.0</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>To open the User Guide, go to Help &gt; User Guide.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>For the Chinese version, please set the Language to Simplified Chinese in Preferences then open the User Guide again.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Note: Test data can be found in the installation directory.</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Do not show this message again</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Got it</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Loading

0 comments on commit dc8d031

Please sign in to comment.