当前位置: 首页>>代码示例>>Python>>正文


Python QDataStream.writeInt16方法代码示例

本文整理汇总了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())
开发者ID:hooloong,项目名称:gitpython,代码行数:29,代码来源:moviedata.py

示例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
开发者ID:hooloong,项目名称:gitpython,代码行数:27,代码来源:ships_ans.py

示例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
开发者ID:imagingearth,项目名称:PyQt4-Examples,代码行数:22,代码来源:ships.py

示例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))
开发者ID:pyros2097,项目名称:SabelIDE,代码行数:26,代码来源:level.py


注:本文中的PyQt4.QtCore.QDataStream.writeInt16方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。