Skip to content

Commit

Permalink
minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
Muddyblack committed Dec 30, 2023
1 parent d08c7ab commit 64f7a6a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
15 changes: 14 additions & 1 deletion MetaDataEditor/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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__":
Expand Down
6 changes: 3 additions & 3 deletions MetaDataEditor/custom_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 64f7a6a

Please sign in to comment.