From f9a9cdf12414fbe2b12bdda053fd85a47e15dac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20M=C3=BCller?= Date: Tue, 16 Feb 2021 23:01:58 +0100 Subject: [PATCH] enh: set R executable and display R version in preferences (#55) --- shapeout2/gui/preferences.py | 28 ++++++++++++++++-------- shapeout2/gui/preferences.ui | 41 +++++++++++++++++++++--------------- 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/shapeout2/gui/preferences.py b/shapeout2/gui/preferences.py index e38a361..0ed1f7d 100644 --- a/shapeout2/gui/preferences.py +++ b/shapeout2/gui/preferences.py @@ -1,3 +1,4 @@ +import pathlib import pkg_resources import platform @@ -47,8 +48,8 @@ def __init__(self, parent, *args, **kwargs): QtWidgets.QDialogButtonBox.RestoreDefaults) btn_restore.clicked.connect(self.on_restore) # lme4 buttons - self.toolButton_lme4_install.clicked.connect(self.on_lme4_install) - self.toolButton_lme4_search.clicked.connect(self.on_lme4_search_r) + self.pushButton_lme4_install.clicked.connect(self.on_lme4_install) + self.pushButton_lme4_search.clicked.connect(self.on_lme4_search_r) def reload(self): """Read configuration or set default parameters""" @@ -74,14 +75,22 @@ def reload(self): @show_wait_cursor def reload_lme4(self, install=False): """Reload information about lme4, optionally installing it""" + # set the binary + binary = self.lme4_rpath.text() + if pathlib.Path(binary).is_file(): + rsetup.set_r_path(binary) + # check lme4 package status if not rsetup.has_r(): - status = "unknown" - elif rsetup.has_lme4(): - status = "installed" + r_version = "unknown" + lme4_st = "unknown" else: - status = "not installed" + r_version = rsetup.get_r_version() + if rsetup.has_lme4(): + lme4_st = "installed" + else: + lme4_st = "not installed" - if install and status == "not installed": + if install and lme4_st == "not installed": self.setEnabled(False) rsetup.install_lme4() self.setEnabled(True) @@ -89,8 +98,9 @@ def reload_lme4(self, install=False): self.reload_lme4(install=False) else: # update user interface - self.toolButton_lme4_install.setVisible(status == "not installed") - self.label_lme4_installed.setText(status) + self.pushButton_lme4_install.setVisible(lme4_st == "not installed") + self.label_r_version.setText(r_version) + self.label_lme4_installed.setText(lme4_st) @QtCore.pyqtSlot() def on_apply(self): diff --git a/shapeout2/gui/preferences.ui b/shapeout2/gui/preferences.ui index 7f71805..0cd0921 100644 --- a/shapeout2/gui/preferences.ui +++ b/shapeout2/gui/preferences.ui @@ -130,41 +130,48 @@ - - + + + + + - R executable + lme4 package - - + + - Search manually... + Install... - - + + + + installed / not installed + + - - + + - lme4 package + Search manually... - - + + - installed / not installed + R executable - - + + - Install... + R version