From f63a7c497d3f59464f2f7ef9bae1c4882880e993 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 6 Feb 2022 16:17:32 -0500 Subject: [PATCH 1/5] Latest `PyQt5` expects `ints` for widget sizings --- piker/ui/_forms.py | 16 ++++++++-------- piker/ui/_l1.py | 9 ++++++++- piker/ui/order_mode.py | 4 +++- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/piker/ui/_forms.py b/piker/ui/_forms.py index 6406a199..1ee37bea 100644 --- a/piker/ui/_forms.py +++ b/piker/ui/_forms.py @@ -218,7 +218,7 @@ class Selection(QComboBox): ) -> None: br = _font.boundingRect(str(char)) - _, h = br.width(), br.height() + _, h = br.width(), int(br.height()) # TODO: something better then this monkey patch view = self.view() @@ -330,7 +330,7 @@ class FieldsForm(QWidget): self.form.setSpacing(0) self.form.setHorizontalSpacing(0) - self.vbox.addLayout(self.form, stretch=1/3) + self.vbox.addLayout(self.form, stretch=3) self.labels: dict[str, QLabel] = {} self.fields: dict[str, QWidget] = {} @@ -557,8 +557,8 @@ class FillStatusBar(QProgressBar): self.font_size = font_size self.setFormat('') # label format - self.setMinimumWidth(width_px) - self.setMaximumWidth(width_px) + self.setMinimumWidth(int(width_px)) + self.setMaximumWidth(int(width_px)) def set_slots( self, @@ -573,7 +573,7 @@ class FillStatusBar(QProgressBar): approx_h, slots, ) - clipped = slots * tot_slot_h + 2*self.border_px + clipped = int(slots * tot_slot_h + 2*self.border_px) self.setMaximumHeight(clipped) slot_height_px = tot_slot_h - 2*self.slot_margin_px @@ -657,14 +657,14 @@ def mk_fill_status_bar( ) # size according to dpi scaled fonted contents to avoid # resizes on magnitude changes (eg. 9 -> 10 %) - min_w = _font.boundingRect('1000.0M% pnl').width() + min_w = int(_font.boundingRect('1000.0M% pnl').width()) left_label.setMinimumWidth(min_w) left_label.resize( min_w, left_label.size().height(), ) - bar_labels_lhs.addSpacing(5/8 * bar_h) + bar_labels_lhs.addSpacing(int(5/8 * bar_h)) bar_labels_lhs.addWidget( left_label, @@ -796,7 +796,7 @@ def mk_order_pane_layout( form.top_label = top_label # add pp fill bar + spacing - vbox.addLayout(hbox, stretch=1/3) + vbox.addLayout(hbox, stretch=3) # TODO: handle resize events and appropriately scale this # to the sidepane height? diff --git a/piker/ui/_l1.py b/piker/ui/_l1.py index 0ff264bc..bfa0551e 100644 --- a/piker/ui/_l1.py +++ b/piker/ui/_l1.py @@ -199,7 +199,14 @@ class LevelLabel(YAxisLabel): elif self._orient_v == 'top': lp, rp = rect.bottomLeft(), rect.bottomRight() - p.drawLine(lp.x(), lp.y(), rp.x(), rp.y()) + p.drawLine( + *map(int, [ + lp.x(), + lp.y(), + rp.x(), + rp.y(), + ]) + ) def highlight(self, pen) -> None: self._pen = pen diff --git a/piker/ui/order_mode.py b/piker/ui/order_mode.py index 48be0384..6795f384 100644 --- a/piker/ui/order_mode.py +++ b/piker/ui/order_mode.py @@ -671,7 +671,9 @@ async def open_order_mode( form.fill_bar.height() # feed_label.height() ) - vbox.setSpacing((1 + 5/8)*_font.px_size) + vbox.setSpacing( + int((1 + 5/8)*_font.px_size) + ) # fill in brokerd feed info host, port = feed.portal.channel.raddr From 999d3efdd7b9af0b3f751d603663d47580fdd413 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 7 Feb 2022 08:46:38 -0500 Subject: [PATCH 2/5] Another `int` required --- piker/ui/_forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/piker/ui/_forms.py b/piker/ui/_forms.py index 1ee37bea..1f1a7cd5 100644 --- a/piker/ui/_forms.py +++ b/piker/ui/_forms.py @@ -105,7 +105,7 @@ class Edit(QLineEdit): # TODO: somehow this math ain't right? chars_w_pxs = dpi_font.boundingRect('0'*self._chars).width() scale = round(dpi_font.scale()) - psh.setWidth(chars_w_pxs * scale) + psh.setWidth(int(chars_w_pxs * scale)) return psh def set_width_in_chars( From 1aaa38203650307a0dca98b954e36e04526728e8 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 7 Feb 2022 08:47:03 -0500 Subject: [PATCH 3/5] Avoid null index race-error during startup --- piker/ui/_cursor.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/piker/ui/_cursor.py b/piker/ui/_cursor.py index d0f642e4..f6f8edde 100644 --- a/piker/ui/_cursor.py +++ b/piker/ui/_cursor.py @@ -109,11 +109,12 @@ class LineDot(pg.CurvePoint): # first = self._plot._arrays['ohlc'][0]['index'] # first = x[0] # i = index - first - i = index - x[0] - if i > 0 and i < len(y): - newPos = (index, y[i]) - QtWidgets.QGraphicsItem.setPos(self, *newPos) - return True + if index: + i = index - x[0] + if i > 0 and i < len(y): + newPos = (index, y[i]) + QtWidgets.QGraphicsItem.setPos(self, *newPos) + return True return False From 00a90e7390d87fc66dcb8614aebb5c716ba99076 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 7 Feb 2022 08:47:20 -0500 Subject: [PATCH 4/5] Change dpi log msg back to debug --- piker/ui/_style.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/piker/ui/_style.py b/piker/ui/_style.py index 1b63e08f..42cadba9 100644 --- a/piker/ui/_style.py +++ b/piker/ui/_style.py @@ -141,8 +141,8 @@ class DpiAwareFont: self._font_inches = inches font_size = math.floor(inches * dpi) - log.info( - f"screen:{screen.name()}]\n" + log.debug( + f"screen:{screen.name()}\n" f"pDPI: {pdpi}, lDPI: {ldpi}, scale: {scale}\n" f"\nOur best guess font size is {font_size}\n" ) From 174590ee88923f0493eda6b3e384a743a56d512a Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 7 Feb 2022 09:41:13 -0500 Subject: [PATCH 5/5] Note 3.10 support and add msgspec as dep --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index ebd034fa..6f8fd898 100755 --- a/setup.py +++ b/setup.py @@ -52,6 +52,7 @@ setup( 'trio', 'trio-websocket', # 'tractor', # from github currently + 'msgspec', # performant IPC messaging 'async_generator', # brokers @@ -87,6 +88,7 @@ setup( "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", 'Intended Audience :: Financial and Insurance Industry', 'Intended Audience :: Science/Research', 'Intended Audience :: Developers',