Skip to content

Commit 355239b

Browse files
committed
Fix paths in mlc_gui to be able to run the app in any location
1 parent ccfd670 commit 355239b

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# You should have received a copy of the GNU General Public License
2020
# along with this program. If not, see <http://www.gnu.org/licenses/>
2121

22+
import os
2223
from PyQt5.QtWidgets import QDialog
2324
from MLC.GUI.Autogenerated.autogenerated import Ui_MLCAboutDialog
2425

@@ -46,13 +47,17 @@ class MLCAboutDialog(QDialog):
4647
</div>
4748
<br>
4849
<br>
49-
""" % "2.0"
50+
""" % "3.0"
5051

5152
def __init__(self, board_path, parent=None):
5253
super(MLCAboutDialog, self).__init__(parent)
54+
icon_path = os.path.join(*[os.path.dirname(os.path.abspath(__file__)),
55+
"images",
56+
"mlc_icon.png"])
57+
5358
self.ui = Ui_MLCAboutDialog()
5459
self.ui.setupUi(self)
55-
self.ui.mlcimage.setStyleSheet("image: url(images/mlc_icon.png);")
60+
self.ui.mlcimage.setStyleSheet("image: url({0});".format(icon_path))
5661
self.ui.labelabout.setText(self.MLC_ABOUT)
5762
self.resize(600, 500)
5863
self.setFixedSize(600, 500)

MLC/GUI/mlc_gui.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121

2222
import os
2323
import sys
24-
sys.path.append(os.path.abspath(".") + "/../..")
24+
mlc_gui_dir = os.path.dirname(os.path.abspath(__file__))
25+
root_dir = os.path.join(*[mlc_gui_dir, "..", ".."])
26+
sys.path.append(root_dir)
27+
2528

2629
import ConfigParser
2730
import tarfile
@@ -30,11 +33,11 @@
3033

3134
from MLC.api.MLCLocal import MLCLocal
3235
from MLC.api.MLCLocal import DuplicatedExperimentError
33-
from MLC.GUI.ExperimentsManager import ExperimentsManager
3436
from MLC.GUI.Autogenerated.autogenerated import Ui_MLCManager
3537
from MLC.GUI.Autogenerated.autogenerated import Ui_PropertiesDialog
36-
from MLC.GUI.Experiment.MLCAboutDialog import MLCAboutDialog
38+
from MLC.GUI.ExperimentsManager import ExperimentsManager
3739
from MLC.GUI.Experiment.ExperimentWindow import ExperimentWindow
40+
from MLC.GUI.MLCAboutDialog import MLCAboutDialog
3841
from MLC.GUI.Tables.ConfigParserTableModel import ConfigParserTableModel
3942
from MLC.Log.log import get_gui_logger
4043

@@ -56,8 +59,8 @@
5659

5760

5861
class MLC_GUI(QMainWindow):
59-
MLC_ICON_FILE = "./images/mlc_icon.png"
60-
GUI_CONFIG_FILE = "./.mlc_gui.conf"
62+
MLC_ICON_FILE = os.path.join(*[mlc_gui_dir, "images", "mlc_icon.png"])
63+
GUI_CONFIG_FILE = os.path.join(mlc_gui_dir, ".mlc_gui.conf")
6164
WEBSERVICE_PORT = 5000
6265
experiment_closed = pyqtSignal(['QString'])
6366

0 commit comments

Comments
 (0)