本文整理匯總了Python中qtpy.QtGui.QPixmap.size方法的典型用法代碼示例。如果您正苦於以下問題:Python QPixmap.size方法的具體用法?Python QPixmap.size怎麽用?Python QPixmap.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qtpy.QtGui.QPixmap
的用法示例。
在下文中一共展示了QPixmap.size方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: imageFiles
# 需要導入模塊: from qtpy.QtGui import QPixmap [as 別名]
# 或者: from qtpy.QtGui.QPixmap import size [as 別名]
def imageFiles(self, new_files):
"""
JSON-formatted dictionary keyed on states (integers), with filenames
of the image file to display for the state.
Parameters
----------
new_files : str
"""
self._state_images_string = str(new_files)
try:
new_file_dict = json.loads(self._state_images_string)
except Exception:
self._state_images = {}
return
self._sizeHint = QSize(0, 0)
for (state, filename) in new_file_dict.items():
if is_pydm_app():
try:
file_path = self.app.get_path(filename)
except Exception as e:
logger.exception("Couldn't get file with path %s", filename)
file_path = filename
else:
file_path = filename
# First, lets try SVG. We have to try SVG first, otherwise
# QPixmap will happily load the SVG and turn it into a raster image.
# Really annoying: We have to try to load the file as SVG,
# and we expect it will fail often (because many images aren't SVG).
# Qt prints a warning message to stdout any time SVG loading fails.
# So we have to temporarily silence Qt warning messages here.
qInstallMessageHandler(self.qt_message_handler)
svg = QSvgRenderer()
svg.repaintNeeded.connect(self.update)
if svg.load(file_path):
self._state_images[int(state)] = (filename, svg)
self._sizeHint = self._sizeHint.expandedTo(svg.defaultSize())
qInstallMessageHandler(None)
continue
qInstallMessageHandler(None)
# SVG didn't work, lets try QPixmap
image = QPixmap(file_path)
if not image.isNull():
self._state_images[int(state)] = (filename, image)
self._sizeHint = self._sizeHint.expandedTo(image.size())
continue
# If we get this far, the file specified could not be loaded at all.
logger.error("Could not load image: {}".format(filename))
self._state_images[int(state)] = (filename, None)
示例2: FadingTipBox
# 需要導入模塊: from qtpy.QtGui import QPixmap [as 別名]
# 或者: from qtpy.QtGui.QPixmap import size [as 別名]
#.........這裏部分代碼省略.........
for widget in self.widgets:
widget.setDisabled(False)
if self.button_disable == 'previous':
self.button_previous.setDisabled(True)
self.button_home.setDisabled(True)
elif self.button_disable == 'next':
self.button_next.setDisabled(True)
self.button_end.setDisabled(True)
def set_data(self, title, content, current, image, run, frames=None,
step=None):
""" """
self.label_title.setText(title)
self.combo_title.clear()
self.combo_title.addItems(frames)
self.combo_title.setCurrentIndex(step)
# min_content_len = max([len(f) for f in frames])
# self.combo_title.setMinimumContentsLength(min_content_len)
# Fix and try to see how it looks with a combo box
self.label_current.setText(current)
self.button_current.setText(current)
self.label_content.setText(content)
self.image = image
if image is None:
self.label_image.setFixedHeight(1)
self.label_image.setFixedWidth(1)
else:
extension = image.split('.')[-1]
self.image = QPixmap(get_image_path(image), extension)
self.label_image.setPixmap(self.image)
self.label_image.setFixedSize(self.image.size())
if run is None:
self.button_run.setVisible(False)
else:
self.button_run.setDisabled(False)
self.button_run.setVisible(True)
# Refresh layout
self.layout().activate()
def set_pos(self, x, y):
""" """
self.x = x
self.y = y
self.move(QPoint(x, y))
def build_paths(self):
""" """
geo = self.geometry()
radius = 0
shadow = self.offset_shadow
x0, y0 = geo.x(), geo.y()
width, height = geo.width() - shadow, geo.height() - shadow
left, top = 0, 0
right, bottom = width, height
self.round_rect_path = QPainterPath()
self.round_rect_path.moveTo(right, top + radius)
self.round_rect_path.arcTo(right-radius, top, radius, radius, 0.0,
90.0)
self.round_rect_path.lineTo(left+radius, top)