From 863d216d4a8c30c2cb8692e42a53f650369a3273 Mon Sep 17 00:00:00 2001 From: Mai Ao Date: Tue, 26 Nov 2024 14:12:37 -0500 Subject: [PATCH 1/2] [UPDATE] **EDU Toolset** - Fixed UI on the EDU Tools updater + added a tool to pick and add background images in the networks. --- scripts/python/edu_utils.py | 55 +++++++++++++++++++++++++++++++++++++ scripts/python/sidefxedu.py | 12 ++++---- toolbar/edu_toolset.shelf | 12 ++++++++ 3 files changed, 73 insertions(+), 6 deletions(-) diff --git a/scripts/python/edu_utils.py b/scripts/python/edu_utils.py index 5b73fc722..fe3089bff 100644 --- a/scripts/python/edu_utils.py +++ b/scripts/python/edu_utils.py @@ -7,6 +7,12 @@ import hou import importlib +from hutil.Qt.QtCore import * +from hutil.Qt.QtGui import * +from hutil.Qt.QtWidgets import * + +import labutils + from past.utils import old_div import nodegraphutils @@ -91,6 +97,53 @@ def createNotes(kwargs, stickytype="info"): sticky.setTextColor(hou.Color(normalize_color(COLOR_TXT[stickytype]))) +# add a background image to the current network editor with the option to embbed it +def addBackgroundImage(): + dialog = BackgroundImages(hou.qt.mainWindow()) + dialog.show() + +class BackgroundImages(QDialog): + def __init__(self, parent): + super(BackgroundImages, self).__init__(parent) + self.setWindowTitle("Add Background Image") + self.build_ui() + + def build_ui(self): + self.cbx_embbed = QCheckBox("Embbed image") + self.btn_choose = QPushButton("Choose Image") + self.btn_cancel = QPushButton("Cancel") + self.btn_choose.clicked.connect(self.on_choosebtn_press) + self.btn_cancel.clicked.connect(self.on_cancelbtn_press) + + button_layout = QHBoxLayout() + button_layout.addWidget(self.cbx_embbed) + button_layout.addWidget(self.btn_choose) + button_layout.addWidget(self.btn_cancel) + + layout = QVBoxLayout() + layout.addLayout(button_layout) + + self.setLayout(layout) + + def on_choosebtn_press(self): + home_folder = os.path.expanduser("~") + + for ptab in hou.ui.currentPaneTabs(): + if ptab.type() == hou.paneTabType.NetworkEditor: + network_editor = ptab + fileName, selectedFilter = QFileDialog.getOpenFileName(self, str("Open Image"), home_folder, str("Image Files (*.png *.jpg *.bmp)")) + scale = 1 + embedded = self.cbx_embbed.isChecked() + relativeto_path = None + bounds = None + + labutils.add_network_image(network_editor, fileName, scale, embedded, relativeto_path=None, bounds=None) + self.close() + + def on_cancelbtn_press(self): + self.close() + + class Quickmarks(object): def __init__(self): @@ -239,3 +292,5 @@ def jumpTo(self, value): nodegraphview.createUndoQuickMark(self._pane) if quickmark is not None: quickmark.jump(self._pane) + + diff --git a/scripts/python/sidefxedu.py b/scripts/python/sidefxedu.py index dcab3ae7c..120bd5441 100644 --- a/scripts/python/sidefxedu.py +++ b/scripts/python/sidefxedu.py @@ -177,11 +177,11 @@ def build_ui(self): changedgroup_layout.addLayout(version_layout) self.button = QPushButton("Update") self.uninstallButton = QPushButton("Uninstall") - self.launcherButton = QPushButton("Start Launcher") + # self.launcherButton = QPushButton("Start Launcher") self.button.clicked.connect(self.on_updatebtn_press) self.uninstallButton.clicked.connect(self.on_uninstallbtn_press) - self.launcherButton.clicked.connect(self.on_launcherbtn_press) + # self.launcherButton.clicked.connect(self.on_launcherbtn_press) layout = QVBoxLayout() layout.addWidget(installed_group) @@ -201,8 +201,8 @@ def build_ui(self): self.uninstallButton.setEnabled(False) button_layout = QHBoxLayout() - button_layout.addWidget(self.launcherButton) - button_layout.addWidget(spacer) + # button_layout.addWidget(self.launcherButton) + # button_layout.addWidget(spacer) button_layout.addWidget(self.button) button_layout.addWidget(self.uninstallButton) @@ -401,7 +401,7 @@ def unzip_file(self, zip_file, destination_path): def get_current_version(self): package_info = json.loads(hou.ui.packageInfo()) for package, info in package_info.items(): - if package.startswith('SideFXEDU'): + if package.startswith('sidefxedu'): if 'Version' in info: return info['Version'] elif 'sidefxedu_current_version' in info: @@ -411,7 +411,7 @@ def get_current_version(self): def get_current_file_path(self): package_info = json.loads(hou.ui.packageInfo()) for package, info in package_info.items(): - if package.startswith('SideFXEDU'): + if package.startswith('sidefxedu'): if 'File path' in info: return info['File path'] return None diff --git a/toolbar/edu_toolset.shelf b/toolbar/edu_toolset.shelf index cb8ba1c1a..cd440e27c 100644 --- a/toolbar/edu_toolset.shelf +++ b/toolbar/edu_toolset.shelf @@ -8,6 +8,7 @@ + @@ -120,4 +121,15 @@ archive_top.setPosition(scheduler.position() + hou.Vector2(0, -1))]]> + + + + From e0fc36358828a6ab27d2d915f47f4880ffa5af7d Mon Sep 17 00:00:00 2001 From: Mai Ao Date: Wed, 27 Nov 2024 09:56:23 -0500 Subject: [PATCH 2/2] [UPDATE] **EDU Toolset** - Updated sidefxedu.py: removed call to self.clean_old_installs which was deleting all installs when loading the UI + removed completely the Launcher button code + added a call to self.on_production_check() to update correctly the version combobox on creation. --- scripts/python/sidefxedu.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/scripts/python/sidefxedu.py b/scripts/python/sidefxedu.py index 120bd5441..b230966ab 100644 --- a/scripts/python/sidefxedu.py +++ b/scripts/python/sidefxedu.py @@ -161,14 +161,13 @@ def build_ui(self): version_layout = QHBoxLayout() update_version_label = QLabel("Release:") - self.version_combo = QComboBox(self) - for release in self.updater_object.production_releases[:10]: - self.version_combo.addItem(release) - self.production_builds_check = QCheckBox("Production Builds Only") - self.production_builds_check.setChecked(True) + self.production_builds_check.setChecked(False) self.production_builds_check.stateChanged.connect(self.on_production_check) + self.version_combo = QComboBox(self) + self.on_production_check() + version_layout.addWidget(update_version_label) version_layout.addWidget(self.version_combo) version_layout.addWidget(self.production_builds_check) @@ -177,11 +176,9 @@ def build_ui(self): changedgroup_layout.addLayout(version_layout) self.button = QPushButton("Update") self.uninstallButton = QPushButton("Uninstall") - # self.launcherButton = QPushButton("Start Launcher") self.button.clicked.connect(self.on_updatebtn_press) self.uninstallButton.clicked.connect(self.on_uninstallbtn_press) - # self.launcherButton.clicked.connect(self.on_launcherbtn_press) layout = QVBoxLayout() layout.addWidget(installed_group) @@ -201,8 +198,6 @@ def build_ui(self): self.uninstallButton.setEnabled(False) button_layout = QHBoxLayout() - # button_layout.addWidget(self.launcherButton) - # button_layout.addWidget(spacer) button_layout.addWidget(self.button) button_layout.addWidget(self.uninstallButton) @@ -311,7 +306,7 @@ def __init__(self, updater_dialog=False): if updater_dialog: self.show_updater_dialog() - self.clean_old_installs() + # self.clean_old_installs() def clean_old_installs(self): @@ -401,7 +396,7 @@ def unzip_file(self, zip_file, destination_path): def get_current_version(self): package_info = json.loads(hou.ui.packageInfo()) for package, info in package_info.items(): - if package.startswith('sidefxedu'): + if package.startswith('SideFXEDU'): if 'Version' in info: return info['Version'] elif 'sidefxedu_current_version' in info: @@ -411,7 +406,7 @@ def get_current_version(self): def get_current_file_path(self): package_info = json.loads(hou.ui.packageInfo()) for package, info in package_info.items(): - if package.startswith('sidefxedu'): + if package.startswith('SideFXEDU'): if 'File path' in info: return info['File path'] return None