|
1 | 1 | """Main RIMSEval graphical user interface.""" |
2 | 2 |
|
| 3 | +from importlib import metadata |
3 | 4 | import itertools |
4 | 5 | import json |
5 | 6 | from pathlib import Path |
@@ -72,7 +73,7 @@ def __init__(self, appctxt, is_windows: bool = False): |
72 | 73 | self.init_config_manager() |
73 | 74 |
|
74 | 75 | # window titles and geometry |
75 | | - self.version = f"v{rimseval.__version__}" |
| 76 | + self.version = f"v{metadata.version('rimseval')}" |
76 | 77 | self.setWindowTitle(f"RIMS Evaluation {self.version}") |
77 | 78 | self.setGeometry(QtCore.QRect(310, 100, 700, 100)) |
78 | 79 |
|
@@ -193,7 +194,7 @@ def __init__(self, appctxt, is_windows: bool = False): |
193 | 194 |
|
194 | 195 | # welcome the user |
195 | 196 | self.status_bar.showMessage( |
196 | | - f"Welcome to RIMSEval v{rimseval.__version__}", msecs=self.status_bar_time |
| 197 | + f"Welcome to RIMSEval v{self.version}", msecs=self.status_bar_time |
197 | 198 | ) |
198 | 199 |
|
199 | 200 | # update actions |
@@ -770,6 +771,18 @@ def init_menu_toolbar(self): |
770 | 771 |
|
771 | 772 | # LST FILE ACTIONS # |
772 | 773 |
|
| 774 | + kore_convert_action = QtGui.QAction( |
| 775 | + QtGui.QIcon(self.appctxt.get_resource("icons/blue-folder-import.png")), |
| 776 | + "Convert KORE to CRD", |
| 777 | + self, |
| 778 | + ) |
| 779 | + kore_convert_action.setStatusTip("Convert KORE to CRD file(s)") |
| 780 | + kore_convert_action.setShortcut(QtGui.QKeySequence("Ctrl+k")) |
| 781 | + kore_convert_action.triggered.connect(self.convert_kore_to_crd) |
| 782 | + self.lst_menu.addAction(kore_convert_action) |
| 783 | + tool_bar.addSeparator() |
| 784 | + tool_bar.addAction(kore_convert_action) |
| 785 | + |
773 | 786 | lst_convert_action = QtGui.QAction( |
774 | 787 | QtGui.QIcon(self.appctxt.get_resource("icons/blue-folder-import.png")), |
775 | 788 | "Convert LST to CRD", |
@@ -1637,6 +1650,36 @@ def calculate_batch(self): |
1637 | 1650 |
|
1638 | 1651 | # LST FILE FUNCTIONS # |
1639 | 1652 |
|
| 1653 | + def convert_kore_to_crd(self): |
| 1654 | + """Convert a KORE LST file to CRD File(s).""" |
| 1655 | + query = QtWidgets.QFileDialog.getOpenFileNames( |
| 1656 | + self, |
| 1657 | + "Open LST File(s)", |
| 1658 | + directory=str(self.user_folder), |
| 1659 | + filter="KORE LST Files (*.lst)", |
| 1660 | + )[0] |
| 1661 | + |
| 1662 | + if len(query) > 0: |
| 1663 | + fnames = [Path(it) for it in query] |
| 1664 | + for it, fname in enumerate(fnames): |
| 1665 | + try: |
| 1666 | + lst = rimseval.data_io.kore_to_crd.KORE2CRD(file_name=fname) |
| 1667 | + lst.write_crd() |
| 1668 | + |
| 1669 | + self.status_bar.showMessage( |
| 1670 | + f"{fname.name} converted, {it + 1}/{len(fnames)} done.", |
| 1671 | + msecs=self.status_bar_time, |
| 1672 | + ) |
| 1673 | + QtWidgets.QApplication.processEvents() |
| 1674 | + |
| 1675 | + except OSError as err: |
| 1676 | + QtWidgets.QMessageBox.warning( |
| 1677 | + self, "KORE LST File error", err.args[0] |
| 1678 | + ) |
| 1679 | + |
| 1680 | + # set user path to this folder |
| 1681 | + self.user_folder = fname.parent |
| 1682 | + |
1640 | 1683 | def convert_lst_to_crd(self, tagged=False): |
1641 | 1684 | """Convert LST to CRD File(s). |
1642 | 1685 |
|
@@ -1665,7 +1708,7 @@ def convert_lst_to_crd(self, tagged=False): |
1665 | 1708 | lst.write_crd() |
1666 | 1709 |
|
1667 | 1710 | self.status_bar.showMessage( |
1668 | | - f"{fname.name} converted, {it+1}/{len(fnames)} done.", |
| 1711 | + f"{fname.name} converted, {it + 1}/{len(fnames)} done.", |
1669 | 1712 | msecs=self.status_bar_time, |
1670 | 1713 | ) |
1671 | 1714 | QtWidgets.QApplication.processEvents() |
|
0 commit comments