Compare commits
3 Commits
fa7249eea2
...
fe6da9186a
| Author | SHA1 | Date |
|---|---|---|
|
|
fe6da9186a | |
|
|
35744f666f | |
|
|
6f9b7320e5 |
|
|
@ -104,6 +104,9 @@ class Pair(Struct, frozen=True, kw_only=True):
|
||||||
# https://developers.binance.com/docs/binance-spot-api-docs#future-changes
|
# https://developers.binance.com/docs/binance-spot-api-docs#future-changes
|
||||||
pegInstructionsAllowed: bool = False
|
pegInstructionsAllowed: bool = False
|
||||||
|
|
||||||
|
# https://developers.binance.com/docs/binance-spot-api-docs#2025-12-02
|
||||||
|
opoAllowed: bool = False
|
||||||
|
|
||||||
filters: dict[
|
filters: dict[
|
||||||
str,
|
str,
|
||||||
str | int | float,
|
str | int | float,
|
||||||
|
|
|
||||||
|
|
@ -184,22 +184,25 @@ class DpiAwareFont:
|
||||||
self._font_inches = inches
|
self._font_inches = inches
|
||||||
font_size = math.floor(inches * pdpi)
|
font_size = math.floor(inches * pdpi)
|
||||||
|
|
||||||
log.debug(
|
ftype: str = f'{type(self)!r}'
|
||||||
f"screen:{screen.name()}\n"
|
log.info(
|
||||||
f"pDPI: {pdpi}, lDPI: {ldpi}, scale: {scale}\n"
|
f'screen: {screen.name()}\n'
|
||||||
f"\nOur best guess font size is {font_size}\n"
|
f'pDPI: {pdpi!r}\n'
|
||||||
|
f'lDPI: {ldpi!r}\n'
|
||||||
|
f'scale: {scale!r}\n'
|
||||||
|
f'{ftype}._font_inches={self._font_inches!r}\n'
|
||||||
|
f'\n'
|
||||||
|
f"Our best guess for an auto-font-size is,\n"
|
||||||
|
f'font_size: {font_size!r}\n'
|
||||||
)
|
)
|
||||||
# apply the size
|
# apply the size
|
||||||
self._set_qfont_px_size(font_size)
|
self._set_qfont_px_size(font_size)
|
||||||
|
|
||||||
def boundingRect(self, value: str) -> QtCore.QRectF:
|
def boundingRect(self, value: str) -> QtCore.QRectF:
|
||||||
|
if (screen := self.screen) is None:
|
||||||
screen = self.screen
|
|
||||||
if screen is None:
|
|
||||||
raise RuntimeError("You must call .configure_to_dpi() first!")
|
raise RuntimeError("You must call .configure_to_dpi() first!")
|
||||||
|
|
||||||
unscaled_br = self._qfm.boundingRect(value)
|
unscaled_br: QtCore.QRectF = self._qfm.boundingRect(value)
|
||||||
|
|
||||||
return QtCore.QRectF(
|
return QtCore.QRectF(
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ Resource list for mucking with DPIs on multiple screens:
|
||||||
- https://doc.qt.io/qt-5/qguiapplication.html#screenAt
|
- https://doc.qt.io/qt-5/qguiapplication.html#screenAt
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
import os
|
||||||
|
|
||||||
from pyqtgraph import QtGui
|
from pyqtgraph import QtGui
|
||||||
from PyQt6 import (
|
from PyQt6 import (
|
||||||
|
|
@ -44,6 +45,10 @@ from PyQt6.QtCore import (
|
||||||
QRect,
|
QRect,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# https://doc.qt.io/qt-6/highdpi.html#environment-variable-reference
|
||||||
|
os.environ['QT_USE_PHYSICAL_DPI'] = '1'
|
||||||
|
|
||||||
# Proper high DPI scaling is available in Qt >= 5.6.0. This attibute
|
# Proper high DPI scaling is available in Qt >= 5.6.0. This attibute
|
||||||
# must be set before creating the application
|
# must be set before creating the application
|
||||||
if hasattr(Qt, 'AA_EnableHighDpiScaling'):
|
if hasattr(Qt, 'AA_EnableHighDpiScaling'):
|
||||||
|
|
@ -58,13 +63,22 @@ if hasattr(Qt, 'AA_UseHighDpiPixmaps'):
|
||||||
True,
|
True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# NOTE, inherits `QGuiApplication`
|
||||||
|
# https://doc.qt.io/qt-6/qapplication.html
|
||||||
|
# https://doc.qt.io/qt-6/qguiapplication.html
|
||||||
app = QtWidgets.QApplication([])
|
app = QtWidgets.QApplication([])
|
||||||
|
#
|
||||||
|
# ^TODO? various global DPI settings?
|
||||||
|
# [ ] DPI rounding policy,
|
||||||
|
# - https://doc.qt.io/qt-6/qt.html#HighDpiScaleFactorRoundingPolicy-enum
|
||||||
|
# - https://doc.qt.io/qt-6/qguiapplication.html#setHighDpiScaleFactorRoundingPolicy
|
||||||
|
|
||||||
window = QtWidgets.QMainWindow()
|
window = QtWidgets.QMainWindow()
|
||||||
main_widget = QtWidgets.QWidget()
|
main_widget = QtWidgets.QWidget()
|
||||||
window.setCentralWidget(main_widget)
|
window.setCentralWidget(main_widget)
|
||||||
window.show()
|
window.show()
|
||||||
|
|
||||||
pxr: float = main_widget.devicePixelRatioF()
|
_main_pxr: float = main_widget.devicePixelRatioF()
|
||||||
|
|
||||||
# explicitly get main widget and primary displays
|
# explicitly get main widget and primary displays
|
||||||
current_screen: QtGui.QScreen = app.screenAt(
|
current_screen: QtGui.QScreen = app.screenAt(
|
||||||
|
|
@ -77,7 +91,13 @@ for screen in app.screens():
|
||||||
name: str = screen.name()
|
name: str = screen.name()
|
||||||
model: str = screen.model().rstrip()
|
model: str = screen.model().rstrip()
|
||||||
size: QSize = screen.size()
|
size: QSize = screen.size()
|
||||||
geo: QRect = screen.availableGeometry()
|
geo: QRect = screen.geometry()
|
||||||
|
|
||||||
|
# device-pixel-ratio
|
||||||
|
# https://doc.qt.io/qt-6/highdpi.html
|
||||||
|
pxr: float = screen.devicePixelRatio()
|
||||||
|
|
||||||
|
unscaled_size: QSize = pxr * size
|
||||||
phydpi: float = screen.physicalDotsPerInch()
|
phydpi: float = screen.physicalDotsPerInch()
|
||||||
logdpi: float = screen.logicalDotsPerInch()
|
logdpi: float = screen.logicalDotsPerInch()
|
||||||
is_primary: bool = screen is primary_screen
|
is_primary: bool = screen is primary_screen
|
||||||
|
|
@ -88,11 +108,12 @@ for screen in app.screens():
|
||||||
f'|_primary: {is_primary}\n'
|
f'|_primary: {is_primary}\n'
|
||||||
f' _current: {is_current}\n'
|
f' _current: {is_current}\n'
|
||||||
f' _model: {model}\n'
|
f' _model: {model}\n'
|
||||||
f' _screen size: {size}\n'
|
f' _size: {size}\n'
|
||||||
f' _screen geometry: {geo}\n'
|
f' _geometry: {geo}\n'
|
||||||
f' _devicePixelRationF(): {pxr}\n'
|
f' _devicePixelRatio(): {pxr}\n'
|
||||||
f' _physical dpi: {phydpi}\n'
|
f' _unscaled-size: {unscaled_size!r}\n'
|
||||||
f' _logical dpi: {logdpi}\n'
|
f' _physical-dpi: {phydpi}\n'
|
||||||
|
f' _logical-dpi: {logdpi}\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
# app-wide font info
|
# app-wide font info
|
||||||
|
|
@ -110,8 +131,8 @@ str_w: int = str_br.width()
|
||||||
|
|
||||||
print(
|
print(
|
||||||
f'------ global font settings ------\n'
|
f'------ global font settings ------\n'
|
||||||
f'font dpi: {fontdpi}\n'
|
f'font dpi: {fontdpi!r}\n'
|
||||||
f'font height: {font_h}\n'
|
f'font height: {font_h!r}\n'
|
||||||
f'string bounding rect: {str_br}\n'
|
f'string bounding rect: {str_br!r}\n'
|
||||||
f'string width : {str_w}\n'
|
f'string width : {str_w!r}\n'
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue