32
32
from PySide6 .QtGui import QStandardItem , QStandardItemModel
33
33
from PySide6 .QtWidgets import QComboBox
34
34
35
- from ansys .tools .installer .common import get_pkg_versions
35
+ from ansys .tools .installer .common import get_pkg_versions , get_targets
36
36
from ansys .tools .installer .configure_json import ConfigureJson
37
37
from ansys .tools .installer .constants import PYANSYS_LIBS , SELECT_VENV_MANAGE_TAB
38
38
from ansys .tools .installer .find_python import (
@@ -300,23 +300,45 @@ def __init__(self, parent=None):
300
300
hbox_install_pyansys = QtWidgets .QHBoxLayout ()
301
301
pyansys_pkg_manage_box_layout .addLayout (hbox_install_pyansys )
302
302
303
+ package_layout = QtWidgets .QVBoxLayout ()
304
+ package_label = QtWidgets .QLabel ("Package" )
303
305
self .model = QStandardItemModel ()
304
306
self .packages_combo = QComboBox ()
305
307
self .packages_combo .setModel (self .model )
308
+ package_layout .addWidget (package_label )
309
+ package_layout .addWidget (self .packages_combo )
306
310
311
+ version_layout = QtWidgets .QVBoxLayout ()
312
+ version_label = QtWidgets .QLabel ("Version" )
307
313
self .versions_combo = QComboBox ()
314
+ version_layout .addWidget (version_label )
315
+ version_layout .addWidget (self .versions_combo )
316
+
317
+ target_layout = QtWidgets .QVBoxLayout ()
318
+ target_label = QtWidgets .QLabel ("Target (optional)" )
319
+ self .version_target_combo = QComboBox ()
320
+ target_layout .addWidget (target_label )
321
+ target_layout .addWidget (self .version_target_combo )
322
+
323
+ install_button_layout = QtWidgets .QVBoxLayout ()
324
+ install_button_label = QtWidgets .QLabel (" " )
308
325
self .button_launch_cmd = QtWidgets .QPushButton ("Install" )
309
- self .button_launch_cmd .clicked .connect (self .install_pyansys_packages )
326
+ install_button_layout .addWidget (install_button_label )
327
+ install_button_layout .addWidget (self .button_launch_cmd )
310
328
329
+ self .button_launch_cmd .clicked .connect (self .install_pyansys_packages )
311
330
for library in PYANSYS_LIBS :
312
331
self .model .appendRow (QStandardItem (library ))
313
-
314
332
self .packages_combo .currentIndexChanged .connect (self .update_package_combo )
333
+ self .versions_combo .currentIndexChanged .connect (
334
+ self .update_package_target_combo
335
+ )
315
336
self .update_package_combo (0 )
316
337
317
- hbox_install_pyansys .addWidget (self .packages_combo )
318
- hbox_install_pyansys .addWidget (self .versions_combo )
319
- hbox_install_pyansys .addWidget (self .button_launch_cmd )
338
+ hbox_install_pyansys .addLayout (package_layout )
339
+ hbox_install_pyansys .addLayout (version_layout )
340
+ hbox_install_pyansys .addLayout (target_layout )
341
+ hbox_install_pyansys .addLayout (install_button_layout )
320
342
layout .addWidget (pyansys_pkg_manage_box )
321
343
322
344
# ensure the table is always in focus
@@ -391,8 +413,10 @@ def install_pyansys_packages(self):
391
413
"""Install PyAnsys - chosen packages."""
392
414
chosen_pkg = self .packages_combo .currentText ()
393
415
chosen_ver = self .versions_combo .currentText ()
416
+ chosen_target = self .version_target_combo .currentText ()
417
+ fmt_target = "" if not chosen_target else f"[{ chosen_target } ]"
394
418
pck_ver = (
395
- f"{ PYANSYS_LIBS [chosen_pkg ]} =={ chosen_ver } "
419
+ f"{ PYANSYS_LIBS [chosen_pkg ]} { fmt_target } =={ chosen_ver } "
396
420
if chosen_ver
397
421
else f"{ PYANSYS_LIBS [chosen_pkg ]} "
398
422
)
@@ -415,6 +439,24 @@ def update_package_combo(self, index):
415
439
self .versions_combo .setModel (versions_model )
416
440
self .versions_combo .setCurrentIndex (0 )
417
441
442
+ def update_package_target_combo (self , index ):
443
+ """Depending on the version chosen for a package, update the available list of targets."""
444
+ package_name = PYANSYS_LIBS [self .packages_combo .currentText ()]
445
+ version = self .versions_combo .currentText ()
446
+
447
+ # Clear the previous targets
448
+ self .version_target_combo .clear ()
449
+
450
+ # Get the available targets for the selected package version
451
+ targets = get_targets (package_name , version )
452
+
453
+ # Populate the target combo box with the available targets
454
+ for target in targets :
455
+ self .version_target_combo .addItem (target )
456
+
457
+ # Set the first target as the current selection
458
+ self .version_target_combo .setCurrentIndex (0 )
459
+
418
460
def list_packages (self ):
419
461
"""List installed Python packages."""
420
462
self .launch_cmd ("uv pip list" )
0 commit comments