def set_bg(self, _bg="jhin.png"):
"""set widget background to given jpg/png/color"""
palette = QtGui.QPalette()
if "." in _bg:
if "\\" in _bg:
img = imgGetter.getimg("fullpath", _bg)
# elif _bg in os.listdir(Data.BACKGROUNDPATH):
else:
img = imgGetter.getimg("bg", _bg)
# rescale for window
if img.width() == 0 or img.height() == 0:
img = QtGui.QColor("#123456")
else:
if self.width() / self.height() >= img.width() / img.height():
img = img.scaledToWidth(self.width())
else:
img = img.scaledToHeight(self.height())
else:
img = QtGui.QColor(_bg)
palette.setBrush(QtGui.QPalette.Background, QtGui.QBrush(img))
self.setPalette(palette)
# Keybinding
评论列表
文章目录