本文整理汇总了Python中PyQt5.QtCore.Qt方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.Qt方法的具体用法?Python QtCore.Qt怎么用?Python QtCore.Qt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore
的用法示例。
在下文中一共展示了QtCore.Qt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import Qt [as 别名]
def save(self):
# Only open dialog if there is no filename yet
#PYQT5 Returns a tuple in PyQt5, we only need the filename
if not self.filename:
self.filename = QtWidgets.QFileDialog.getSaveFileName(self, 'Save File')[0]
if self.filename:
# Append extension if not there yet
if not self.filename.endswith(".writer"):
self.filename += ".writer"
# We just store the contents of the text file along with the
# format in html, which Qt does in a very nice way for us
with open(self.filename,"wt") as file:
file.write(self.text.toHtml())
self.changesSaved = True
示例2: ParseCategory
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import Qt [as 别名]
def ParseCategory(self, items):
"""
Parses a XML category
"""
nodes = []
for item in items:
node = QtWidgets.QTreeWidgetItem()
node.setText(0, item[0])
# see if it's a category or a level
if isinstance(item[1], str):
# it's a level
node.setData(0, Qt.UserRole, item[1])
node.setToolTip(0, item[1])
else:
# it's a category
children = self.ParseCategory(item[1])
for cnode in children:
node.addChild(cnode)
node.setToolTip(0, item[0])
nodes.append(node)
return tuple(nodes)
示例3: UpdateListItem
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import Qt [as 别名]
def UpdateListItem(self, updateTooltipPreview=False):
"""
Updates the list item
"""
if not hasattr(self, 'listitem'): return
if self.listitem is None: return
if updateTooltipPreview:
# It's just like Qt to make this overly complicated. XP
img = self.renderInLevelIcon()
byteArray = QtCore.QByteArray()
buf = QtCore.QBuffer(byteArray)
img.save(buf, 'PNG')
byteObj = bytes(byteArray)
b64 = base64.b64encode(byteObj).decode('utf-8')
self.listitem.setToolTip('<img src="data:image/png;base64,' + b64 + '" />')
self.listitem.setText(self.ListString())
示例4: paint
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import Qt [as 别名]
def paint(self, painter, option, widget):
"""
Paints the object
"""
if self.isSelected():
painter.setPen(QtGui.QPen(globals.theme.color('object_lines_s'), 1, Qt.DotLine))
painter.drawRect(self.SelectionRect)
painter.fillRect(self.SelectionRect, globals.theme.color('object_fill_s'))
painter.fillRect(self.DrawGrabberRectTL, globals.theme.color('object_lines_s'))
painter.fillRect(self.DrawGrabberRectTR, globals.theme.color('object_lines_s'))
painter.fillRect(self.DrawGrabberRectBL, globals.theme.color('object_lines_s'))
painter.fillRect(self.DrawGrabberRectBR, globals.theme.color('object_lines_s'))
painter.fillRect(self.DrawGrabberRectMT, globals.theme.color('object_lines_s'))
painter.fillRect(self.DrawGrabberRectML, globals.theme.color('object_lines_s'))
painter.fillRect(self.DrawGrabberRectMB, globals.theme.color('object_lines_s'))
painter.fillRect(self.DrawGrabberRectMR, globals.theme.color('object_lines_s'))
示例5: setSize
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import Qt [as 别名]
def setSize(self, width):
self.prepareGeometryChange()
self.BoundingRect = QtCore.QRectF(0, 0, width * (TileWidth/16), width * (TileWidth/16))
centerOffset = (8 - (width / 2)) * (TileWidth/16)
fullOffset = -(width * (TileWidth/16)) + TileWidth
xval = 0
if self.alignMode & Qt.AlignHCenter:
xval = centerOffset
elif self.alignMode & Qt.AlignRight:
xval = fullOffset
yval = 0
if self.alignMode & Qt.AlignVCenter:
yval = centerOffset
elif self.alignMode & Qt.AlignBottom:
yval = fullOffset
self.setPos(xval, yval)
self.width = width
示例6: addObj
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import Qt [as 别名]
def addObj(self):
global Tileset
Tileset.addObject(new=True)
pix = QtGui.QPixmap(24, 24)
pix.fill(Qt.transparent)
painter = QtGui.QPainter(pix)
painter.drawPixmap(0, 0, Tileset.tiles[0].image.scaledToWidth(24, Qt.SmoothTransformation))
painter.end()
del painter
count = len(Tileset.objects)
item = QtGui.QStandardItem(QtGui.QIcon(pix), 'Object {0}'.format(count-1))
item.setFlags(item.flags() & ~Qt.ItemIsEditable)
window.objmodel.appendRow(item)
index = window.objectList.currentIndex()
window.objectList.setCurrentIndex(index)
self.setObject(index)
window.objectList.update()
self.update()
示例7: updateList
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import Qt [as 别名]
def updateList(self):
# Update the list >.>
object = window.objmodel.itemFromIndex(window.objectList.currentIndex())
if not object: return
tex = QtGui.QPixmap(self.size[0] * 24, self.size[1] * 24)
tex.fill(Qt.transparent)
painter = QtGui.QPainter(tex)
Xoffset = 0
Yoffset = 0
for y, row in enumerate(self.tiles):
for x, tile in enumerate(row):
painter.drawPixmap(x*24, y*24, tile)
painter.end()
object.setIcon(QtGui.QIcon(tex))
window.objectList.update()
示例8: saveImage
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import Qt [as 别名]
def saveImage(self, nml=False):
fn = QtWidgets.QFileDialog.getSaveFileName(self, 'Choose a new filename', '', '.png (*.png)')[0]
if fn == '': return
tex = QtGui.QPixmap(960, 960)
tex.fill(Qt.transparent)
painter = QtGui.QPainter(tex)
Xoffset = 0
Yoffset = 0
for tile in Tileset.tiles:
tileimg = tile.image
if nml:
tileimg = tile.normalmap
painter.drawPixmap(Xoffset, Yoffset, tileimg)
Xoffset += 60
if Xoffset >= 960:
Xoffset = 0
Yoffset += 60
painter.end()
tex.save(fn)
示例9: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import Qt [as 别名]
def __init__(self, main=None, nml=None):
"""
Initializes the TilesetTile
"""
if not main:
main = QtGui.QPixmap(60, 60)
main.fill(Qt.transparent)
self.exists = False
self.main = main
if not nml:
nml = QtGui.QPixmap(60, 60)
nml.fill(QtGui.QColor(128, 128, 255))
self.nml = nml
self.isAnimated = False
self.animFrame = 0
self.animTiles = []
self.setCollisions(0)
self.collOverlay = None
示例10: data
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import Qt [as 别名]
def data(self, index, role=Qt.DisplayRole):
"""
Get what we have for a specific row
"""
if not index.isValid(): return None
n = index.row()
if n < 0: return None
if n >= len(self.items): return None
if role == Qt.DecorationRole:
return self.items[n].Icon
elif role == Qt.BackgroundRole:
return QtWidgets.qApp.palette().base()
elif role == Qt.UserRole:
return self.items[n].Name
elif role == Qt.StatusTipRole:
return self.items[n].Name
else:
return None
示例11: HandleItemChange
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import Qt [as 别名]
def HandleItemChange(self, current, previous):
"""
Catch the selected level and enable/disable OK button as needed
"""
self.currentlevel = current.data(0, Qt.UserRole)
if self.currentlevel is None:
self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(False)
else:
self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True)
self.currentlevel = str(self.currentlevel)
示例12: HandleItemActivated
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import Qt [as 别名]
def HandleItemActivated(self, item, column):
"""
Handle a doubleclick on a level
"""
self.currentlevel = item.data(0, Qt.UserRole)
if self.currentlevel is not None:
self.currentlevel = str(self.currentlevel)
self.accept()
示例13: LoadNumberFont
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import Qt [as 别名]
def LoadNumberFont():
"""
Creates a valid font we can use to display the item numbers
"""
if globals.NumberFont is not None: return
# this is a really crappy method, but I can't think of any other way
# normal Qt defines Q_WS_WIN and Q_WS_MAC but we don't have that here
s = QtCore.QSysInfo()
if hasattr(s, 'WindowsVersion'):
globals.NumberFont = QtGui.QFont('Tahoma', (7 / 24) * globals.TileWidth)
elif hasattr(s, 'MacintoshVersion'):
globals.NumberFont = QtGui.QFont('Lucida Grande', (9 / 24) * globals.TileWidth)
else:
globals.NumberFont = QtGui.QFont('Sans', (8 / 24) * globals.TileWidth)
示例14: boundingRect
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import Qt [as 别名]
def boundingRect(self):
"""
Required for Qt
"""
return self.BoundingRect
示例15: mousePressEvent
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import Qt [as 别名]
def mousePressEvent(self, event):
"""
Overrides mouse pressing events if needed for cloning
"""
if event.button() != Qt.LeftButton or QtWidgets.QApplication.keyboardModifiers() != Qt.ControlModifier:
if not globals.SpriteImagesShown:
oldpos = (self.objx, self.objy)
LevelEditorItem.mousePressEvent(self, event)
if not globals.SpriteImagesShown:
self.setNewObjPos(oldpos[0], oldpos[1])
return
newitem = SpriteItem(self.type, self.objx, self.objy, self.spritedata, self.layer, self.initialState)
import widgets
newitem.listitem = widgets.ListWidgetItem_SortsByOther(newitem, newitem.ListString())
del widgets
globals.mainWindow.spriteList.addItem(newitem.listitem)
globals.Area.sprites.append(newitem)
globals.mainWindow.scene.addItem(newitem)
globals.mainWindow.scene.clearSelection()
self.setSelected(True)
newitem.UpdateListItem()
SetDirty()