Skip to content

Commit 84593ca

Browse files
committed
I04_1-396: use qt5 instead of qt4 layout update
1 parent deb8b54 commit 84593ca

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

dls_barcode/gui/image_frame.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
from __future__ import division
22

3-
from PyQt5.QtCore import Qt
3+
4+
5+
from PyQt5.QtCore import Qt, QSize
46
from PyQt5.QtWidgets import QLabel, QGroupBox, QVBoxLayout
57

8+
from dls_barcode.gui.image_widget import ImageWidget
9+
610

711
class ImageFrame(QGroupBox):
812
""" GUI component. Displays an image of the currently selected barcode.
913
"""
1014
def __init__(self, title):
1115
super(ImageFrame, self).__init__()
12-
1316
self.setTitle(title)
14-
self.setMaximumWidth(750)
1517
self._init_ui()
1618

1719
def _init_ui(self):
1820
# Image frame - displays image of the currently selected scan record
19-
self._frame = QLabel()
21+
self._frame = ImageWidget()
2022
self._frame.setStyleSheet("background-color: white; color: red; font-size: 30pt; text-align: center")
2123
self._frame.setMinimumWidth(700)
2224
self._frame.setAlignment(Qt.AlignCenter)
23-
2425
vbox = QVBoxLayout()
2526
vbox.addWidget(self._frame)
2627

dls_barcode/gui/image_widget.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from PyQt5 import QtCore, QtWidgets
2+
from PyQt5.QtWidgets import QLabel
3+
4+
# Resize button in the right corner didn't work correctly for the image
5+
# I had to add a event filter to the class so that the pixmap is scaled when resizing happens.
6+
7+
8+
class ImageWidget(QLabel):
9+
10+
def __init__(self, parent=None):
11+
super(ImageWidget, self).__init__(parent)
12+
self.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
13+
self.installEventFilter(self)
14+
15+
def eventFilter(self, source, event):
16+
if source is self and event.type() == QtCore.QEvent.Resize:
17+
ma = self.pixmap()
18+
self.setPixmap(ma.scaled(self.size(), QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation))
19+
return QtWidgets.QWidget.eventFilter(self, source, event)

dls_barcode/gui/main_window.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def _init_ui(self):
4040
"""
4141
self._window_icon = QtGui.QIcon("..\\resources\\icons\\qr_code_32.png")
4242

43-
self.setGeometry(10, 50, 1650, 950)
43+
self.setGeometry(10, 50, 1900, 950)
4444
self.setWindowTitle('Diamond Puck Barcode Scanner')
4545
self.setWindowIcon(self._window_icon)
4646

dls_barcode/gui/record_table.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self, barcode_table, image_frame, options):
2929
self._imageFrame = image_frame
3030

3131
self.setTitle("Scan Records")
32-
self.setMaximumWidth(900)
32+
self.setMaximumWidth(1200)
3333

3434
self._init_ui()
3535

@@ -38,7 +38,7 @@ def __init__(self, barcode_table, image_frame, options):
3838
def _init_ui(self):
3939
# Create record table - lists all the records in the store
4040
self._table = QTableWidget()
41-
self._table.setMinimumWidth(750)
41+
self._table.setMinimumWidth(900)
4242
self._table.setMinimumHeight(600)
4343
self._table.setColumnCount(len(self.COLUMNS))
4444
self._table.setHorizontalHeaderLabels(self.COLUMNS)

0 commit comments

Comments
 (0)