From 74f44dd246863523b99e152e6ecba42c97c93ead Mon Sep 17 00:00:00 2001 From: HinGwenWoong Date: Fri, 25 Feb 2022 20:50:09 +0800 Subject: [PATCH] the height of key list set to a quarter of the windows height --- PPOCRLabel/PPOCRLabel.py | 11 +++++++---- PPOCRLabel/libs/unique_label_qlist_widget.py | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/PPOCRLabel/PPOCRLabel.py b/PPOCRLabel/PPOCRLabel.py index 11eda1a9..a2906e71 100644 --- a/PPOCRLabel/PPOCRLabel.py +++ b/PPOCRLabel/PPOCRLabel.py @@ -162,11 +162,14 @@ class MainWindow(QMainWindow): # ================== Key List ================== if self.kie_mode: - # self.keyList = QListWidget() self.keyList = UniqueLabelQListWidget() - # self.keyList.itemSelectionChanged.connect(self.keyListSelectionChanged) - # self.keyList.itemDoubleClicked.connect(self.editBox) - # self.keyList.itemChanged.connect(self.keyListItemChanged) + + # set key list height + key_list_height = int(QApplication.desktop().height() // 4) + if key_list_height < 50: + key_list_height = 50 + self.keyList.setMaximumHeight(key_list_height) + self.keyListDockName = getStr('keyListTitle') self.keyListDock = QDockWidget(self.keyListDockName, self) self.keyListDock.setWidget(self.keyList) diff --git a/PPOCRLabel/libs/unique_label_qlist_widget.py b/PPOCRLabel/libs/unique_label_qlist_widget.py index f1eff7a1..07ae05fe 100644 --- a/PPOCRLabel/libs/unique_label_qlist_widget.py +++ b/PPOCRLabel/libs/unique_label_qlist_widget.py @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- -from PyQt5.QtCore import Qt +from PyQt5.QtCore import Qt, QSize from PyQt5 import QtWidgets @@ -40,6 +40,7 @@ class UniqueLabelQListWidget(EscapableQListWidget): qlabel.setText(' {} '.format(*color, label)) qlabel.setAlignment(Qt.AlignBottom) - item.setSizeHint(qlabel.sizeHint()) + # item.setSizeHint(qlabel.sizeHint()) + item.setSizeHint(QSize(25, 25)) self.setItemWidget(item, qlabel) -- GitLab