24 lines
1.5 KiB
Python
24 lines
1.5 KiB
Python
from pathlib import Path
|
|
import ast
|
|
folder=Path(__file__).resolve().parent
|
|
for root in [folder/'payload',Path('C:/wechat_rpa')]:
|
|
p=root/'wechat_gui_qt.py';s=p.read_text(encoding='utf-8')
|
|
s=s.replace(' _UI_ORIG["layoutSpacing"] = QLayout.setSpacing',
|
|
''' _UI_ORIG["layoutSpacing"] = QLayout.setSpacing
|
|
_UI_ORIG["boxSpacing"] = QBoxLayout.setSpacing
|
|
_UI_ORIG["gridSpacing"] = QGridLayout.setSpacing''')
|
|
s=s.replace(' QLayout.setSpacing = wrap_spacing(_UI_ORIG["layoutSpacing"], "uiSpace")',
|
|
''' QLayout.setSpacing = wrap_spacing(_UI_ORIG["layoutSpacing"], "uiSpace")
|
|
QBoxLayout.setSpacing = wrap_spacing(_UI_ORIG["boxSpacing"], "uiSpace")
|
|
QGridLayout.setSpacing = wrap_spacing(_UI_ORIG["gridSpacing"], "uiSpace")''')
|
|
old=' _UI_ORIG["layoutSpacing"](layout, ui_px(int(layout.property("uiSpace")), allow_zero=True))'
|
|
new=''' method = "gridSpacing" if isinstance(layout, QGridLayout) else ("boxSpacing" if isinstance(layout, QBoxLayout) else "layoutSpacing")
|
|
_UI_ORIG[method](layout, ui_px(int(layout.property("uiSpace")), allow_zero=True))'''
|
|
assert old in s;s=s.replace(old,new)
|
|
s=s.replace(' self._scale_timer.start()\n shell = getattr(self, "console_shell", None)',
|
|
''' if hasattr(self, "_scale_timer"):
|
|
self._scale_timer.start()
|
|
shell = getattr(self, "console_shell", None)''')
|
|
ast.parse(s);p.write_text(s,encoding='utf-8',newline='\n')
|
|
print('Fixed QBoxLayout/QGridLayout spacing and early screen events')
|