1- import importlib .resources
21import json
32
43from pygments import highlight , lexers , formatters
5- from PyQt6 import uic , QtCore , QtWidgets
4+ from PyQt6 import QtCore , QtWidgets
5+
6+ from .ana_basins_ui import Ui_Form
67
78
89class BasinsPanel (QtWidgets .QWidget ):
@@ -17,18 +18,18 @@ class BasinsPanel(QtWidgets.QWidget):
1718
1819 def __init__ (self , * args , ** kwargs ):
1920 super (BasinsPanel , self ).__init__ (* args , ** kwargs )
20- ref = importlib . resources . files (
21- "dcscope.gui.analysis" ) / "ana_basins.ui"
22- with importlib . resources . as_file ( ref ) as path_ui :
23- uic . loadUi ( path_ui , self )
21+
22+ self . ui = Ui_Form ()
23+ self . ui . setupUi ( self )
24+
2425 # current DCscope pipeline
2526 self .pipeline = None
2627 self .data_role = QtCore .Qt .ItemDataRole .UserRole + 2
27- self .treeWidget_basin_name .setColumnCount (1 )
28+ self .ui . treeWidget_basin_name .setColumnCount (1 )
2829
29- self .listWidget_dataset .currentRowChanged .connect (
30+ self .ui . listWidget_dataset .currentRowChanged .connect (
3031 self .on_select_dataset )
31- self .treeWidget_basin_name .currentItemChanged .connect (
32+ self .ui . treeWidget_basin_name .currentItemChanged .connect (
3233 self .on_select_basin )
3334
3435 self .pp_mod_recv .connect (self .on_pp_mod_recv )
@@ -50,16 +51,16 @@ def on_pp_mod_recv(self, data):
5051 @QtCore .pyqtSlot (int )
5152 def on_select_dataset (self , ds_idx ):
5253 """Show the tables of the dataset in the right-hand list widget"""
53- self .treeWidget_basin_name .clear ()
54+ self .ui . treeWidget_basin_name .clear ()
5455 if ds_idx >= 0 :
5556 ds = self .pipeline .slots [ds_idx ].get_dataset ()
56- self .add_basin_nodes (parent_widget = self .treeWidget_basin_name ,
57+ self .add_basin_nodes (parent_widget = self .ui . treeWidget_basin_name ,
5758 ds = ds )
5859
5960 @QtCore .pyqtSlot (QtWidgets .QTreeWidgetItem , QtWidgets .QTreeWidgetItem )
6061 def on_select_basin (self , current , previous = None ):
6162 """Show the tables of the dataset in the right-hand list widget"""
62- ds_idx = self .listWidget_dataset .currentRow ()
63+ ds_idx = self .ui . listWidget_dataset .currentRow ()
6364 if current is not None and ds_idx >= 0 :
6465 # Get the correct basin
6566 ds , bd = current .data (0 , self .data_role )
@@ -76,9 +77,9 @@ def on_select_basin(self, current, previous=None):
7677 bn = None
7778
7879 # Display the basin information
79- self .label_status .setText (f"{ loaded = } , { available = } " )
80- self .label_id .setText (f"{ bd .get ('name' )} ({ bd ['key' ]} )" )
81- self .textEdit_def .setText (
80+ self .ui . label_status .setText (f"{ loaded = } , { available = } " )
81+ self .ui . label_id .setText (f"{ bd .get ('name' )} ({ bd ['key' ]} )" )
82+ self .ui . textEdit_def .setText (
8283 highlight (json .dumps (bd , sort_keys = True , indent = 2 ),
8384 lexers .JsonLexer (),
8485 formatters .HtmlFormatter (full = True ,
@@ -92,9 +93,9 @@ def on_select_basin(self, current, previous=None):
9293 ds = bn .ds )
9394 current .setExpanded (True )
9495 else :
95- self .textEdit_def .clear ()
96- self .label_status .setText ("" )
97- self .label_id .setText ("" )
96+ self .ui . textEdit_def .clear ()
97+ self .ui . label_status .setText ("" )
98+ self .ui . label_id .setText ("" )
9899
99100 def set_pipeline (self , pipeline ):
100101 if self .pipeline is not None :
@@ -105,16 +106,16 @@ def update_content(self, slot_index=None, **kwargs):
105106 if self .pipeline and self .pipeline .slots :
106107 self .setEnabled (True )
107108 self .setUpdatesEnabled (False )
108- self .listWidget_dataset .clear ()
109- self .treeWidget_basin_name .clear ()
109+ self .ui . listWidget_dataset .clear ()
110+ self .ui . treeWidget_basin_name .clear ()
110111 for name in self .pipeline .deduce_display_names ():
111- self .listWidget_dataset .addItem (name )
112+ self .ui . listWidget_dataset .addItem (name )
112113 self .setUpdatesEnabled (True )
113114 if slot_index is None or slot_index < 0 :
114- slot_index = max (0 , self .listWidget_dataset .currentRow ())
115+ slot_index = max (0 , self .ui . listWidget_dataset .currentRow ())
115116 slot_index = min (slot_index , self .pipeline .num_slots - 1 )
116- self .listWidget_dataset .setCurrentRow (slot_index )
117+ self .ui . listWidget_dataset .setCurrentRow (slot_index )
117118 else :
118119 self .setEnabled (False )
119- self .listWidget_dataset .clear ()
120- self .treeWidget_basin_name .clear ()
120+ self .ui . listWidget_dataset .clear ()
121+ self .ui . treeWidget_basin_name .clear ()
0 commit comments