From b56ecb12c23269b93e54210b7ea66313d3300081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Mon, 6 May 2024 18:30:54 +0800 Subject: [PATCH] fix --- .../LunaTranslator/gui/specialwidget.py | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/specialwidget.py b/LunaTranslator/LunaTranslator/gui/specialwidget.py index 3cf6c026..7ccbe000 100644 --- a/LunaTranslator/LunaTranslator/gui/specialwidget.py +++ b/LunaTranslator/LunaTranslator/gui/specialwidget.py @@ -116,14 +116,22 @@ class chartwidget(QWidget): painter.drawText( x2 - self.fmetrics.width(text) // 2, y2 - 10, text ) # value - + lastx2 = -999 for i, (x, y) in enumerate(points): painter.drawLine(x, ymargin + height, x, ymargin + height + 5) # 刻度线 - painter.drawText( - x - self.fmetrics.width(x_labels[i]) // 2, - ymargin + height + 20, - x_labels[i], - ) # 标签 + + thisw = self.fmetrics.width(x_labels[i]) + thisx = x - thisw // 2 + + if thisx > lastx2: + + painter.drawText( + thisx, + ymargin + height + 20, + x_labels[i], + ) # 标签 + lastx2 = thisx + thisw + except: print_exc() @@ -352,7 +360,7 @@ class lazyscrollflow(QWidget): widfunc.setGeometry(self.fakegeos[i]) self.widgets[i] = widfunc if procevent: - QApplication.processEvents() #会在最大化时死锁 + QApplication.processEvents() # 会在最大化时死锁 except: pass