Skip to content
Snippets Groups Projects
Commit 7bc1305b authored by Boman Romain's avatar Boman Romain
Browse files

improve GUI

parent e6bdff9e
No related branches found
No related tags found
No related merge requests found
Pipeline #7112 passed
......@@ -27,6 +27,9 @@ class Window(QWidget, Ui_Form):
self.runPushButton.setIcon(QIcon(':/media-seek-forward.png'))
self.viewPushButton.setIcon(QIcon(':/video-display.png'))
self.inpFileResetPushButton.setIcon(QIcon(':/edit-undo.png'))
self.wrkspResetPushButton.setIcon(QIcon(':/edit-undo.png'))
# read Qt settings for the application
settings = QSettings()
# self.restoreGeometry(settings.value("Geometry", self.saveGeometry()))
......@@ -40,6 +43,12 @@ class Window(QWidget, Ui_Form):
def on_runPushButton_pressed(self):
# print("runPushButton...")
if not os.path.isfile(self.inpFileLineEdit.text()):
QMessageBox.critical(self, "Error", "Input file does not exist!")
return
if not os.path.isdir(self.wrkspLineEdit.text()):
QMessageBox.critical(self, "Error", "Workspace does not exist!")
return
self.action = 'run'
self.close()
......@@ -49,13 +58,21 @@ class Window(QWidget, Ui_Form):
self.close()
def on_inpFilePushButton_pressed(self):
# print("inpFilePushButton...")
# try to set a relevant starting folder
default = os.path.join(os.path.dirname(__file__), 'models')
curfile = self.inpFileLineEdit.text()
if curfile:
curfolder = os.path.dirname(curfile)
if os.path.isdir(curfolder):
default = curfolder
fname = QFileDialog.getOpenFileName(
None, 'Select input file', '', filter='Python File (*.py)')
self, 'Select input file', default, filter='Python File (*.py)')
pyfile = fname[0]
if pyfile:
self.inpFileLineEdit.setText(QDir.toNativeSeparators(pyfile))
def on_inpFileEditPushButton_pressed(self):
"""Open input file with a text editor
"""
......@@ -69,6 +86,9 @@ class Window(QWidget, Ui_Form):
subprocess.Popen([ editor, self.inpFileLineEdit.text() ])
break
def on_inpFileResetPushButton_pressed(self):
self.inpFileLineEdit.setText("")
def on_wrkspExplorePushButton_pressed(self):
"""Browse workspace folder with system explorer
"""
......@@ -80,6 +100,10 @@ class Window(QWidget, Ui_Form):
if dir:
self.wrkspLineEdit.setText(QDir.toNativeSeparators(dir))
def on_wrkspResetPushButton_pressed(self):
self.wrkspLineEdit.setText("")
def closeEvent(self, event):
"""save settings to registry and quit
"""
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>708</width>
<width>745</width>
<height>154</height>
</rect>
</property>
......@@ -18,6 +18,12 @@
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="inpFilelabel">
<property name="toolTip">
<string>name of the python file</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="text">
<string>input file</string>
</property>
......@@ -28,6 +34,12 @@
</item>
<item row="0" column="2">
<widget class="QToolButton" name="inpFilePushButton">
<property name="toolTip">
<string>select a python file</string>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="text">
<string>...</string>
</property>
......@@ -35,13 +47,38 @@
</item>
<item row="0" column="3">
<widget class="QToolButton" name="inpFileEditPushButton">
<property name="toolTip">
<string>open a text editor</string>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="inpFileResetPushButton">
<property name="toolTip">
<string>reset to default</string>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="wrksplabel">
<property name="toolTip">
<string>folder where the results are stored</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="text">
<string>workspace</string>
</property>
......@@ -52,6 +89,12 @@
</item>
<item row="1" column="2">
<widget class="QToolButton" name="wrkspPushButton">
<property name="toolTip">
<string>select a folder</string>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="text">
<string>...</string>
</property>
......@@ -59,11 +102,30 @@
</item>
<item row="1" column="3">
<widget class="QToolButton" name="wrkspExplorePushButton">
<property name="toolTip">
<string>open the folder in the explorer</string>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="text">
<string>Explore</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QToolButton" name="wrkspResetPushButton">
<property name="toolTip">
<string>reset to default</string>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
......@@ -83,6 +145,12 @@
</item>
<item>
<widget class="QPushButton" name="runPushButton">
<property name="toolTip">
<string>start the simulation!</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="text">
<string>Run</string>
</property>
......@@ -90,6 +158,12 @@
</item>
<item>
<widget class="QPushButton" name="viewPushButton">
<property name="toolTip">
<string>read/display the results stored in the folder of the workspace</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="text">
<string>View</string>
</property>
......
pics/edit-undo.png

1.56 KiB

This diff is collapsed.
......@@ -5,5 +5,6 @@
<file alias="document-open.png">pics/document-open.png</file>
<file alias="video-display.png">pics/video-display.png</file>
<file alias="media-seek-forward.png">pics/media-seek-forward.png</file>
<file alias="edit-undo.png">pics/edit-undo.png</file>
</qresource>
</RCC>
\ No newline at end of file
......@@ -14,44 +14,60 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(708, 154)
Form.resize(745, 154)
self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setObjectName("verticalLayout")
self.gridLayout = QtWidgets.QGridLayout()
self.gridLayout.setObjectName("gridLayout")
self.inpFilelabel = QtWidgets.QLabel(Form)
self.inpFilelabel.setStatusTip("")
self.inpFilelabel.setObjectName("inpFilelabel")
self.gridLayout.addWidget(self.inpFilelabel, 0, 0, 1, 1)
self.inpFileLineEdit = QtWidgets.QLineEdit(Form)
self.inpFileLineEdit.setObjectName("inpFileLineEdit")
self.gridLayout.addWidget(self.inpFileLineEdit, 0, 1, 1, 1)
self.inpFilePushButton = QtWidgets.QToolButton(Form)
self.inpFilePushButton.setWhatsThis("")
self.inpFilePushButton.setObjectName("inpFilePushButton")
self.gridLayout.addWidget(self.inpFilePushButton, 0, 2, 1, 1)
self.inpFileEditPushButton = QtWidgets.QToolButton(Form)
self.inpFileEditPushButton.setWhatsThis("")
self.inpFileEditPushButton.setObjectName("inpFileEditPushButton")
self.gridLayout.addWidget(self.inpFileEditPushButton, 0, 3, 1, 1)
self.inpFileResetPushButton = QtWidgets.QToolButton(Form)
self.inpFileResetPushButton.setWhatsThis("")
self.inpFileResetPushButton.setObjectName("inpFileResetPushButton")
self.gridLayout.addWidget(self.inpFileResetPushButton, 0, 4, 1, 1)
self.wrksplabel = QtWidgets.QLabel(Form)
self.wrksplabel.setStatusTip("")
self.wrksplabel.setObjectName("wrksplabel")
self.gridLayout.addWidget(self.wrksplabel, 1, 0, 1, 1)
self.wrkspLineEdit = QtWidgets.QLineEdit(Form)
self.wrkspLineEdit.setObjectName("wrkspLineEdit")
self.gridLayout.addWidget(self.wrkspLineEdit, 1, 1, 1, 1)
self.wrkspPushButton = QtWidgets.QToolButton(Form)
self.wrkspPushButton.setWhatsThis("")
self.wrkspPushButton.setObjectName("wrkspPushButton")
self.gridLayout.addWidget(self.wrkspPushButton, 1, 2, 1, 1)
self.wrkspExplorePushButton = QtWidgets.QToolButton(Form)
self.wrkspExplorePushButton.setWhatsThis("")
self.wrkspExplorePushButton.setObjectName("wrkspExplorePushButton")
self.gridLayout.addWidget(self.wrkspExplorePushButton, 1, 3, 1, 1)
self.wrkspResetPushButton = QtWidgets.QToolButton(Form)
self.wrkspResetPushButton.setWhatsThis("")
self.wrkspResetPushButton.setObjectName("wrkspResetPushButton")
self.gridLayout.addWidget(self.wrkspResetPushButton, 1, 4, 1, 1)
self.verticalLayout.addLayout(self.gridLayout)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem)
self.runPushButton = QtWidgets.QPushButton(Form)
self.runPushButton.setStatusTip("")
self.runPushButton.setObjectName("runPushButton")
self.horizontalLayout_2.addWidget(self.runPushButton)
self.viewPushButton = QtWidgets.QPushButton(Form)
self.viewPushButton.setStatusTip("")
self.viewPushButton.setObjectName("viewPushButton")
self.horizontalLayout_2.addWidget(self.viewPushButton)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
......@@ -64,11 +80,23 @@ class Ui_Form(object):
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.inpFilelabel.setToolTip(_translate("Form", "name of the python file"))
self.inpFilelabel.setText(_translate("Form", "input file"))
self.inpFilePushButton.setToolTip(_translate("Form", "select a python file"))
self.inpFilePushButton.setText(_translate("Form", "..."))
self.inpFileEditPushButton.setToolTip(_translate("Form", "open a text editor"))
self.inpFileEditPushButton.setText(_translate("Form", "Edit"))
self.inpFileResetPushButton.setToolTip(_translate("Form", "reset to default"))
self.inpFileResetPushButton.setText(_translate("Form", "Reset"))
self.wrksplabel.setToolTip(_translate("Form", "folder where the results are stored"))
self.wrksplabel.setText(_translate("Form", "workspace"))
self.wrkspPushButton.setToolTip(_translate("Form", "select a folder"))
self.wrkspPushButton.setText(_translate("Form", "..."))
self.wrkspExplorePushButton.setToolTip(_translate("Form", "open the folder in the explorer"))
self.wrkspExplorePushButton.setText(_translate("Form", "Explore"))
self.wrkspResetPushButton.setToolTip(_translate("Form", "reset to default"))
self.wrkspResetPushButton.setText(_translate("Form", "Reset"))
self.runPushButton.setToolTip(_translate("Form", "start the simulation!"))
self.runPushButton.setText(_translate("Form", "Run"))
self.viewPushButton.setToolTip(_translate("Form", "read/display the results stored in the folder of the workspace"))
self.viewPushButton.setText(_translate("Form", "View"))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment