【发布时间】:2014-09-28 11:13:52
【问题描述】:
我还没有找到一种方法来减少这些部分的长代码行。无论我从哪一点切线到下一点,它都会断线。 有没有办法以某种方式将它们切成更短的线?
self.setStyleSheet('ApplicationWindow { background-color: rgba(10, 10, 10, 10); } ButtonDefault { background-color: rgb(255, 10, 10); color: rgb(255, 255, 255); }')
我自己的解决方案是将样式表移动到单独的 .css 文件中,然后将整个内容从那里剥离为一个简单的字符串。这样开发也比较好,但是这个方法听起来合理吗?
stylesheet_string = ''
# Opens external stylesheet file
with open('stylesheet.css', 'r') as stylesheet:
for line in stylesheet:
line.replace('\n', ' ')
line.replace('\t', ' ')
stylesheet_string = stylesheet_string+line
self.setStyleSheet(stylesheet_string)
【问题讨论】: