chore: import original project baseline
Import the pre-repair source tree as the history baseline. Runtime data (data/), virtualenvs, bytecode caches and logs are gitignored so local secrets and user state stay out of the repo.
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""问题 3 取证:右侧栏 bash 层「参数/输出」框的滚动条 QSS 现状(离屏截图 + 几何/样式打印)"""
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
||||
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
||||
os.environ["QTWEBENGINE_CHROMIUM_FLAGS"] = "--disable-gpu"
|
||||
os.environ.setdefault("PYTHONIOENCODING", "utf-8")
|
||||
|
||||
import core.db_manager as _dbm # noqa: E402
|
||||
_dbm._DEFAULT_DB = os.path.join(tempfile.gettempdir(), f"haocode_q3_{os.getpid()}.db")
|
||||
_cfg = os.path.join(tempfile.gettempdir(), f"haocode_q3_{os.getpid()}.json")
|
||||
open(_cfg, "w", encoding="utf-8").write('{"providers": {}}')
|
||||
os.environ["HAOCODE_CONFIG_FILE"] = _cfg
|
||||
|
||||
from PyQt6.QtWidgets import QApplication # noqa: E402
|
||||
from PyQt6.QtTest import QTest # noqa: E402
|
||||
from ui.views.main_window import MainWindow # noqa: E402
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
w = MainWindow()
|
||||
w.resize(1400, 950)
|
||||
w.show()
|
||||
for _ in range(40):
|
||||
app.processEvents()
|
||||
QTest.qWait(20)
|
||||
|
||||
p = w.bash_panel
|
||||
p.expand_btn.click()
|
||||
for _ in range(30):
|
||||
app.processEvents()
|
||||
QTest.qWait(20)
|
||||
|
||||
# 造一个「已完成 + 长输出」的层(长输出会把垂直/水平滚动条都逼出来)
|
||||
long_cmd = "python train.py --epochs 300 --batch-size 64 --lr 0.0001 --data /data/detr/annotations.json"
|
||||
long_out = "\n".join(
|
||||
f"[{i:04d}] epoch loss=0.{i % 9}{i % 7} lr=0.0001 mAP=0.{40 + i % 20} "
|
||||
f"very_long_tail_to_force_horizontal_scrollbar_{i}"
|
||||
for i in range(120))
|
||||
p.on_started("q3_lay", "bash", {"command": long_cmd})
|
||||
p.on_finished("q3_lay", "bash", True, long_out)
|
||||
for _ in range(20):
|
||||
app.processEvents()
|
||||
QTest.qWait(20)
|
||||
|
||||
lay = p._layers["q3_lay"]
|
||||
lay.toggle() # 展开层 → 显示「参数」「输出」两块
|
||||
for _ in range(20):
|
||||
app.processEvents()
|
||||
QTest.qWait(20)
|
||||
|
||||
for nm, box in (("参数 arg_box", lay.arg_box), ("输出 out_box", lay.out_box)):
|
||||
vb = box.verticalScrollBar()
|
||||
hb = box.horizontalScrollBar()
|
||||
print(f"--- {nm}")
|
||||
print(f" objectName={box.objectName()} 尺寸={box.width()}x{box.height()}")
|
||||
print(f" 垂直滚动条: 可见={vb.isVisible()} 宽={vb.width()} 需要={vb.maximum() > 0}")
|
||||
print(f" 水平滚动条: 可见={hb.isVisible()} 高={hb.height()} 需要={hb.maximum() > 0}")
|
||||
print(f" box 自身 stylesheet = {box.styleSheet()!r}")
|
||||
print(f" box 背景角色 = {box.palette().base().color().name()}")
|
||||
|
||||
img = lay.grab().toImage()
|
||||
out = os.path.join(os.path.dirname(os.path.abspath(__file__)), "_tmp_q3_layer.png")
|
||||
img.save(out)
|
||||
print("\n层截图 ->", out, img.width(), "x", img.height())
|
||||
|
||||
# 再抓取面板整块(看滚动条在面板里的观感)
|
||||
img2 = p.grab().toImage()
|
||||
out2 = os.path.join(os.path.dirname(os.path.abspath(__file__)), "_tmp_q3_panel.png")
|
||||
img2.save(out2)
|
||||
print("面板截图 ->", out2, img2.width(), "x", img2.height())
|
||||
|
||||
os.remove(_cfg)
|
||||
Reference in New Issue
Block a user