本文整理匯總了Python中PySide2.QtCore.QSize方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QSize方法的具體用法?Python QtCore.QSize怎麽用?Python QtCore.QSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PySide2.QtCore
的用法示例。
在下文中一共展示了QtCore.QSize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: sampleLatentAtPos
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QSize [as 別名]
def sampleLatentAtPos(self, pos):
imgRect = self.getImageDims()
gridDims = self.gridSize #self.latentSize *
w = int(imgRect.width() / self.gridSize.width()) #self.latentSize * ( #self.getCurrentLatentWidth()
h_l = self.latentSize // 2
self.sampledLatentPos = self.getGridCoords(pos)
posGrid = self.sampledLatentPos - QPoint(h_l, h_l)
posGrid.setX(min(max(posGrid.x(), 0), gridDims.width() - h_l))
posGrid.setY(min(max(posGrid.y(), 0), gridDims.height() - h_l))
posImg = QPoint(int(imgRect.width() * posGrid.x() / gridDims.width()), int(imgRect.height() * posGrid.y() / gridDims.height()))
fullImg = self._image.pixmap()
imgRegion = fullImg.copy(QRect(posImg, QSize(w, w))).toImage()
region_array = np.ndarray(shape=(imgRegion.height(), imgRegion.width(), 4), dtype=np.uint8, buffer=imgRegion.bits())
self.sampledLatent = region_array[:, :, [2, 1, 0]] #BGR -> RGB
示例2: test_level
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QSize [as 別名]
def test_level(level_info, qtbot):
*level_info, transparent = level_info
level_ref = LevelRef()
level_ref.load_level(*level_info)
Block._block_cache.clear()
# monkeypatch level names, since the level name data is broken atm
level_ref.level.name = current_test_name()
level_view = LevelView(None, level_ref, ContextMenu(level_ref))
level_view.transparency = transparent
level_view.draw_jumps = False
level_view.draw_grid = False
level_view.draw_autoscroll = True
rect = QRect(QPoint(0, 0), QSize(*level_ref.level.size) * 16)
level_view.setGeometry(rect)
_test_level_against_reference(level_view, qtbot)
示例3: __init__
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QSize [as 別名]
def __init__(self, parent, toolbar, icon, title):
"""
* :param parent: Parent window
* :param toolbar:dict
* :param icon:str
* :param title:str
"""
super(JToolbar, self).__init__(parent)
self.icon = icon
self.setMovable(False)
self.setContextMenuPolicy(Qt.PreventContextMenu)
self.setIconSize(QSize(32, 32))
self.about_title = "About"
if toolbar:
# If a dict is passed generate buttons from dict
for btn in toolbar:
try:
if btn["icon"]:
item = QAction(QIcon(btn["icon"]), btn["name"], self)
except KeyError:
item = QAction(btn["name"], self)
item.triggered.connect(self._on_click(btn["url"]))
self.addAction(item)
示例4: setupUi
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QSize [as 別名]
def setupUi(self, onionSkinObject_layout):
onionSkinObject_layout.setObjectName("onionSkinObject_layout")
onionSkinObject_layout.resize(204, 38)
self.horizontalLayout = QtWidgets.QHBoxLayout(onionSkinObject_layout)
self.horizontalLayout.setSpacing(3)
self.horizontalLayout.setContentsMargins(4, 2, 4, 2)
self.horizontalLayout.setObjectName("horizontalLayout")
self.object_label = QtWidgets.QLabel(onionSkinObject_layout)
self.object_label.setObjectName("object_label")
self.horizontalLayout.addWidget(self.object_label)
self.object_remove_btn = QtWidgets.QPushButton(onionSkinObject_layout)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.object_remove_btn.sizePolicy().hasHeightForWidth())
self.object_remove_btn.setSizePolicy(sizePolicy)
self.object_remove_btn.setMinimumSize(QtCore.QSize(16, 16))
self.object_remove_btn.setMaximumSize(QtCore.QSize(16, 16))
self.object_remove_btn.setObjectName("object_remove_btn")
self.horizontalLayout.addWidget(self.object_remove_btn)
self.retranslateUi(onionSkinObject_layout)
QtCore.QMetaObject.connectSlotsByName(onionSkinObject_layout)
示例5: _init_widgets
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QSize [as 別名]
def _init_widgets(self):
layout = QHBoxLayout()
ast_label = QLabel(self)
self._ast_label = ast_label
if self._display_size:
size_label = QLabel(self)
size_label.setProperty('class', 'ast_viewer_size')
size_label.setAlignment(Qt.AlignRight)
size_label.setMaximumSize(QSize(24, 65536))
self._size_label = size_label
layout.addWidget(self._size_label)
if self._ast is not None:
self.reload()
layout.addWidget(ast_label)
layout.setContentsMargins(0, 0, 0, 0)
self.setLayout(layout)
示例6: setupUi
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QSize [as 別名]
def setupUi(self, ExcelSelectionDialog):
ExcelSelectionDialog.setObjectName("ExcelSelectionDialog")
ExcelSelectionDialog.resize(272, 229)
ExcelSelectionDialog.setMaximumSize(QtCore.QSize(272, 229))
ExcelSelectionDialog.setModal(True)
self.verticalLayout = QtWidgets.QVBoxLayout(ExcelSelectionDialog)
self.verticalLayout.setObjectName("verticalLayout")
self.sheets_list = QtWidgets.QListWidget(ExcelSelectionDialog)
self.sheets_list.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.sheets_list.setObjectName("sheets_list")
self.verticalLayout.addWidget(self.sheets_list)
self.buttonBox = QtWidgets.QDialogButtonBox(ExcelSelectionDialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.verticalLayout.addWidget(self.buttonBox)
self.retranslateUi(ExcelSelectionDialog)
self.buttonBox.accepted.connect(ExcelSelectionDialog.accept)
self.buttonBox.rejected.connect(ExcelSelectionDialog.reject)
QtCore.QMetaObject.connectSlotsByName(ExcelSelectionDialog)
示例7: sizeHint
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QSize [as 別名]
def sizeHint(self):
return QSize(300, 100)
示例8: sizeHint
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QSize [as 別名]
def sizeHint(self, option, idx):
width = self.expected_char_widths[idx.column()]
data = idx.data()
if data is not None:
width = max(width, len(data))
return QSize(self.char_width * width + 4, self.char_height)
示例9: sizeHint
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QSize [as 別名]
def sizeHint(self, option, idx):
return QSize(self.char_width * self.expected_char_widths[idx.column()] + 4, self.char_height)
示例10: minimumSizeHint
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QSize [as 別名]
def minimumSizeHint(self):
return QtCore.QSize(640, 480)
示例11: __init__
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QSize [as 別名]
def __init__(self, parent=None):
super(HotboxManagerToolbar, self).__init__(parent)
self.setIconSize(QtCore.QSize(16, 16))
self.new = QtWidgets.QAction(icon('manager-new.png'), '', self)
self.new.setToolTip('Create new hotbox')
self.new.triggered.connect(self.newRequested.emit)
self.edit = QtWidgets.QAction(icon('manager-edit.png'), '', self)
self.edit.setToolTip('Edit hotbox')
self.edit.triggered.connect(self.editRequested.emit)
self.delete = QtWidgets.QAction(icon('manager-delete.png'), '', self)
self.delete.setToolTip('Delete hotbox')
self.delete.triggered.connect(self.deleteRequested.emit)
self.link = QtWidgets.QAction(icon('link.png'), '', self)
self.link.setToolTip('Link to external hotbox file')
self.link.triggered.connect(self.linkRequested.emit)
self.unlink = QtWidgets.QAction(icon('unlink.png'), '', self)
self.unlink.setToolTip('Remove hotbox file link')
self.unlink.triggered.connect(self.unlinkRequested.emit)
self.import_ = QtWidgets.QAction(icon('manager-import.png'), '', self)
self.import_.setToolTip('Import hotbox')
self.import_.triggered.connect(self.importRequested.emit)
self.export = QtWidgets.QAction(icon('manager-export.png'), '', self)
self.export.setToolTip('Export hotbox')
self.export.triggered.connect(self.exportRequested.emit)
self.hotkeyset = QtWidgets.QAction(icon('touch.png'), '', self)
self.hotkeyset.setToolTip('Set hotkey')
self.hotkeyset.triggered.connect(self.setHotkeyRequested.emit)
self.addAction(self.new)
self.addAction(self.edit)
self.addAction(self.delete)
self.addSeparator()
self.addAction(self.link)
self.addAction(self.unlink)
self.addSeparator()
self.addAction(self.import_)
self.addAction(self.export)
self.addSeparator()
self.addAction(self.hotkeyset)
示例12: get_size
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QSize [as 別名]
def get_size(self):
width = int(self.hbwidth.text()) if self.hbwidth.text() else 1
height = int(self.hbheight.text()) if self.hbheight.text() else 1
return QtCore.QSize(width, height)
示例13: _addAccountToWindow
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QSize [as 別名]
def _addAccountToWindow(self, account, balance, resize_parent=False):
wrapper_layout = QVBoxLayout()
account_layout = QHBoxLayout()
rows_layout = QVBoxLayout()
address_layout = QHBoxLayout()
account_label = QLabel(account)
account_label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
copy_button = QPushButton()
copy_button.setAutoFillBackground(True)
copy_button.setIcon(QIcon('icons/copy.svg'))
self.connect(copy_button, SIGNAL('clicked()'), lambda: self.copyAddress(account))
address_layout.addWidget(account_label)
address_layout.addWidget(copy_button)
balance_label = QLabel('Balance: %.5f ethers' % balance)
balance_label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
self.balance_widgets[account] = balance_label
rows_layout.addLayout(address_layout)
rows_layout.addWidget(balance_label)
avatar = QLabel()
img_filename = render_avatar(account)
pixmap = QPixmap(img_filename)
avatar.setPixmap(pixmap)
account_layout.addWidget(avatar)
account_layout.addLayout(rows_layout)
wrapper_layout.addLayout(account_layout)
wrapper_layout.addSpacing(20)
self.accounts_layout.addLayout(wrapper_layout)
if resize_parent:
sizeHint = self.sizeHint()
self.parentWidget().parentWidget().resize(QSize(sizeHint.width(), sizeHint.height() + 40))
示例14: _addTokenToWindow
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QSize [as 別名]
def _addTokenToWindow(self, token_information, resize_parent=False):
wrapper_layout = QVBoxLayout()
token_layout = QHBoxLayout()
rows_layout = QVBoxLayout()
token_label = QLabel(token_information.name)
token_label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
symbol_label = QLabel(token_information.symbol)
symbol_label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
total_supply_label = QLabel('Total Supply: %d coins' % token_information.totalSupply)
total_supply_label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
rows_layout.addWidget(token_label)
rows_layout.addWidget(symbol_label)
rows_layout.addWidget(total_supply_label)
avatar = QLabel()
img_filename = render_avatar(token_information.address)
pixmap = QPixmap(img_filename)
avatar.setPixmap(pixmap)
token_layout.addWidget(avatar)
token_layout.addLayout(rows_layout)
wrapper_layout.addLayout(token_layout)
wrapper_layout.addSpacing(20)
self.tokens_layout.addLayout(wrapper_layout)
if resize_parent:
sizeHint = self.size()
self.parentWidget().parentWidget().resize(QSize(sizeHint.width(), sizeHint.height() + 100))
示例15: updateIndicatorSize
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QSize [as 別名]
def updateIndicatorSize(self, stroke=3, offset=2, crossSize=10):
"""
draw a box and crosshair under mouse cursor as rectangle of size latentSize
"""
multiplier = 1 #TODO optional: scale indicator with zoom level
stroke *= multiplier
offset *= multiplier
crossSize *= multiplier
halfStroke = stroke / 2
rect = self.getImageDims()
latentSize = self.latentSize * rect.width() / self.gridSize.width()
halfSize = latentSize / 2
crossSize = min(crossSize, int(halfSize - 3))
pixmap = QPixmap(QSize(int(latentSize + stroke + offset), int(latentSize + stroke + offset)))
#fill rectangle with transparent color
pixmap.fill(QColor(0,0,0,0)) #transparent
painter = QPainter(pixmap)
r = QRectF(QPoint(), QSizeF(latentSize, latentSize))
r.adjust(offset+halfStroke, offset+halfStroke, -halfStroke, -halfStroke)
#draw shadow under rectangle
pen = QPen(QColor(50, 50, 50, 100), stroke) #shadow
painter.setPen(pen)
painter.drawRect(r)
if crossSize > 4:
painter.drawLine(QPointF(offset+halfSize, offset+halfSize-crossSize), QPointF(offset+halfSize, offset+halfSize+crossSize))
painter.drawLine(QPointF(offset+halfSize-crossSize, offset+halfSize), QPointF(offset+halfSize+crossSize, offset+halfSize))
r.adjust(-offset, -offset, -offset, -offset)
pen = QPen(QColor(styleColor[0], styleColor[1], styleColor[2], 200), stroke)
painter.setPen(pen)
painter.drawRect(r)
if crossSize > 4:
painter.drawLine(QPointF(halfSize, halfSize - crossSize), QPointF(halfSize, halfSize + crossSize))
painter.drawLine(QPointF(halfSize - crossSize, halfSize), QPointF(halfSize + crossSize, halfSize))
painter.end()
self._latentIndicator.setPixmap(pixmap)