Qt设计师生成代码更改
f = open('', 'r',encoding='utf-8')
content = f.read()
f.close()
text3 = content.strip("\n").split("\n")
print(text3)
txt_file = open("", "a", encoding="utf-8") # 以写的格式打开先打开文件
min = "setMinimumSize"
max = "setMaximumSize"
for temp in text3:
mi = temp.find(min)
mx = temp.find(max)
if mi>= 0 or mx>=0:
Proportion = temp[temp.find("QSize(")+6 : temp.find("))")]
X_i = int(Proportion[:Proportion.find(",")])
Y_i = int(Proportion[Proportion.find(",")+1:])
if X_i >20000 and Y_i >20000 :
temp = temp
elif X_i > 20000:
temp = temp[:temp.find("QSize(") + 6] + str(X_i) + ", " + str(int(Y_i * 2160 / 1080)) + "))"
elif Y_i >20000:
temp = temp[:temp.find("QSize(") + 6] + str(int(X_i * 4096 / 1920)) + ", " + str(Y_i) + "))"
else:
temp = temp[:temp.find("QSize(")+6] + str(int(X_i*4096/1920))+", "+str(int(Y_i*2160/1080))+"))"
txt_file.write(temp)
txt_file.write("\n")
else:
txt_file.write(temp)
txt_file.write("\n")
txt_file.close()
Comments NOTHING