diff --git a/MetaDataEditor/app.py b/MetaDataEditor/app.py index d0a855b..d56f468 100644 --- a/MetaDataEditor/app.py +++ b/MetaDataEditor/app.py @@ -59,7 +59,7 @@ def init_ui(self): """Setup the UI""" # Create a label for the image self.image_label = QLabel(self) - self.image_label.setAlignment(Qt.AlignCenter) + self.image_label.setAlignment(Qt.AlignTop) # Create Buttons self.mode_switch = QPushButton("Switch Mode", self) @@ -213,6 +213,19 @@ def display_image(self, image_path): self.image_label.width(), self.height(), Qt.KeepAspectRatio ) self.image_label.setPixmap(pixmap) + self.image_path = image_path + + def resizeEvent(self, event): + """Resizes the image when the window is resized""" + if ( + hasattr(self, "image_path") and self.image_path + ): # Check if an image has been loaded + pixmap = QPixmap(self.image_path) + pixmap = pixmap.scaled( + self.scroll_area.width(), self.scroll_area.height(), Qt.KeepAspectRatio + ) + self.image_label.setPixmap(pixmap) + super().resizeEvent(event) # Call the parent class's resizeEvent method if __name__ == "__main__": diff --git a/MetaDataEditor/custom_widgets.py b/MetaDataEditor/custom_widgets.py index 908862c..963b6a2 100644 --- a/MetaDataEditor/custom_widgets.py +++ b/MetaDataEditor/custom_widgets.py @@ -49,21 +49,21 @@ class TagWidget(QWidget): def __init__(self, tag_name="", tag_value="", text_field_height=50, parent=None): super(TagWidget, self).__init__(parent) - self.TEXT_FIELD_HEIGHT = text_field_height + self.text_field_height = text_field_height self.tag_name_edit = TagTextEdit(self) if tag_name.strip() != "": self.tag_name_edit.setPlainText(tag_name) else: self.tag_name_edit.setPlaceholderText("Tag Name") - self.tag_name_edit.setFixedHeight(self.TEXT_FIELD_HEIGHT) + self.tag_name_edit.setFixedHeight(self.text_field_height) self.tag_value_edit = TagTextEdit(self) if tag_value.strip() != "": self.tag_value_edit.setPlainText(tag_value) else: self.tag_value_edit.setPlaceholderText("Tag Value") - self.tag_value_edit.setFixedHeight(self.TEXT_FIELD_HEIGHT) + self.tag_value_edit.setFixedHeight(self.text_field_height) self.remove_button = QPushButton("Remove", self) self.remove_button.setObjectName("removeButton")