Pyside2 从 C++ 到 Python 的翻译
Translation from C++ to Python for Pyside2
我正在尝试更改进度条的颜色。根据 PYSIDE2 文档(实际上几乎是从 C++ 复制粘贴的),语法如下:
QProgressBar::chunk {
background-color: #05B8CC;
width: 20px;
}
我试过以下方法:
self.pbar.chunk('background-color: whatever')
self.pbar(chunk{'background-color: whatever'})
self.pbar(chunk('background-color: whatever'))
self.pbar.Qchunk('background-color: whatever')
self.pbar::chunk('background-color: whatever')
self.pbar:chunk('background.color: whatever')
etc
似乎无论我如何或在哪里放置 "chunk",我都会收到一个错误,指出 "chunk" 无法识别、不是方法、不是选项,或者通常无法理解。按照我尝试的方式,块在样式表中也无法识别。我广泛搜索了 PySide2 文档,只能找到几个用 C++ 编写的示例,实际上根本没有帮助。
请将上面的C++语句翻译成Python。另外,如果 PySide2 的 PYTHON 文档有资源,我将不胜感激 link。谢谢
在 Pyside2 中,您可以使用 Python 字符串设置小部件的样式表:
app.setStyleSheet('QProgressBar::chunk { background: solid orange; }')
P.S:而你可以确实设计出丑陋的设计;)
我正在尝试更改进度条的颜色。根据 PYSIDE2 文档(实际上几乎是从 C++ 复制粘贴的),语法如下:
QProgressBar::chunk {
background-color: #05B8CC;
width: 20px;
}
我试过以下方法:
self.pbar.chunk('background-color: whatever')
self.pbar(chunk{'background-color: whatever'})
self.pbar(chunk('background-color: whatever'))
self.pbar.Qchunk('background-color: whatever')
self.pbar::chunk('background-color: whatever')
self.pbar:chunk('background.color: whatever')
etc
似乎无论我如何或在哪里放置 "chunk",我都会收到一个错误,指出 "chunk" 无法识别、不是方法、不是选项,或者通常无法理解。按照我尝试的方式,块在样式表中也无法识别。我广泛搜索了 PySide2 文档,只能找到几个用 C++ 编写的示例,实际上根本没有帮助。
请将上面的C++语句翻译成Python。另外,如果 PySide2 的 PYTHON 文档有资源,我将不胜感激 link。谢谢
在 Pyside2 中,您可以使用 Python 字符串设置小部件的样式表:
app.setStyleSheet('QProgressBar::chunk { background: solid orange; }')
P.S:而你可以确实设计出丑陋的设计;)