本文整理汇总了Python中PyQt4.QtCore.QDataStream.writeInt16方法的典型用法代码示例。如果您正苦于以下问题:Python QDataStream.writeInt16方法的具体用法?Python QDataStream.writeInt16怎么用?Python QDataStream.writeInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QDataStream
的用法示例。
在下文中一共展示了QDataStream.writeInt16方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: saveQDataStream
# 需要导入模块: from PyQt4.QtCore import QDataStream [as 别名]
# 或者: from PyQt4.QtCore.QDataStream import writeInt16 [as 别名]
def saveQDataStream(self):
error = None
fh = None
try:
fh = QFile(self.__fname)
if not fh.open(QIODevice.WriteOnly):
raise IOError(str(fh.errorString()))
stream = QDataStream(fh)
stream.writeInt32(MovieContainer.MAGIC_NUMBER)
stream.writeInt32(MovieContainer.FILE_VERSION)
stream.setVersion(QDataStream.Qt_4_2)
for key, movie in self.__movies:
stream << movie.title
stream.writeInt16(movie.year)
stream.writeInt16(movie.minutes)
stream << movie.acquired << movie.notes
except EnvironmentError as e:
error = "Failed to save: {0}".format(e)
finally:
if fh is not None:
fh.close()
if error is not None:
return False, error
self.__dirty = False
return True, "Saved {0} movie records to {1}".format(
len(self.__movies),
QFileInfo(self.__fname).fileName())
示例2: save
# 需要导入模块: from PyQt4.QtCore import QDataStream [as 别名]
# 或者: from PyQt4.QtCore.QDataStream import writeInt16 [as 别名]
def save(self):
exception = None
fh = None
try:
if self.filename.isEmpty():
raise IOError("no filename specified for saving")
fh = QFile(self.filename)
if not fh.open(QIODevice.WriteOnly):
raise IOError(str(fh.errorString()))
stream = QDataStream(fh)
stream.writeInt32(MAGIC_NUMBER)
stream.writeInt16(FILE_VERSION)
stream.setVersion(QDataStream.Qt_4_1)
for ship in self.ships:
stream << ship.name << ship.owner << ship.country \
<< ship.description
stream.writeInt32(ship.teu)
self.dirty = False
except IOError as e:
exception = e
finally:
if fh is not None:
fh.close()
if exception is not None:
raise exception
示例3: save
# 需要导入模块: from PyQt4.QtCore import QDataStream [as 别名]
# 或者: from PyQt4.QtCore.QDataStream import writeInt16 [as 别名]
def save(self):
exception = None
fh = None
try:
if self.filename.isEmpty():
raise IOError, "no filename specified for saving"
fh = QFile(self.filename)
if not fh.open(QIODevice.WriteOnly):
raise IOError, unicode(fh.errorString())
stream = QDataStream(fh)
stream.writeInt32(MAGIC_NUMBER)
stream.writeInt16(FILE_VERSION)
stream.setVersion(QDataStream.Qt_4_1)
for ship in self.ships.values():
stream << ship.name << ship.owner << ship.country
stream << ship.description
stream.writeInt32(ship.teu)
self.dirty = False
except IOError, err:
exception = err
示例4: save
# 需要导入模块: from PyQt4.QtCore import QDataStream [as 别名]
# 或者: from PyQt4.QtCore.QDataStream import writeInt16 [as 别名]
def save(self):
if self.filename.isEmpty():
path = "."
fname = QFileDialog.getSaveFileName(self,
"Page Designer - Save As", path,
"Page Designer Files (*.pgd)")
if fname.isEmpty():
return
self.filename = fname
fh = None
try:
fh = QFile(self.filename)
if not fh.open(QIODevice.WriteOnly):
raise IOError, unicode(fh.errorString())
self.scene.clearSelection()
stream = QDataStream(fh)
stream.setVersion(QDataStream.Qt_4_2)
stream.writeInt32(MagicNumber)
stream.writeInt16(FileVersion)
for item in self.scene.items():
self.writeItemToStream(stream, item)
except IOError, e:
QMessageBox.warning(self, "Page Designer -- Save Error",
"Failed to save {0}: {1}".format(self.filename, e))