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


Python QDeclarativeView.showFullScreen方法代码示例

本文整理汇总了Python中PyQt4.QtDeclarative.QDeclarativeView.showFullScreen方法的典型用法代码示例。如果您正苦于以下问题:Python QDeclarativeView.showFullScreen方法的具体用法?Python QDeclarativeView.showFullScreen怎么用?Python QDeclarativeView.showFullScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtDeclarative.QDeclarativeView的用法示例。


在下文中一共展示了QDeclarativeView.showFullScreen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Infoboard

# 需要导入模块: from PyQt4.QtDeclarative import QDeclarativeView [as 别名]
# 或者: from PyQt4.QtDeclarative.QDeclarativeView import showFullScreen [as 别名]
class Infoboard(object):
    def __init__(self, schedule_dir):
        self.schedule_dir = schedule_dir
        self.videos = {}
        self.playlist = []

        self.app = QApplication(sys.argv)

        self.view = QDeclarativeView()
        self.view.setSource(QUrl('scene.qml'))
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)

        self.viewRoot = self.view.rootObject()
        self.viewRoot.quit.connect(self.app.quit)
        self.viewRoot.finished.connect(self.show_next)

        self.view.setGeometry(100, 100, 400, 240)
        self.view.showFullScreen()

        self.watcher = QFileSystemWatcher()

    def schedule_dir_changed(self, filename):
        self.process_all_schedules()
        self.playlist = []

    def run(self):
        self.watcher.addPath(self.schedule_dir)
        self.watcher.directoryChanged.connect(self.schedule_dir_changed)
        self.process_all_schedules()
        self.show_next()
        self.app.exec_()

    def process_schedule(self, key, fobj):
        self.videos[key] = []
        for line in fobj:
            line = line.strip()
            if (not line) or line.startswith('#'): continue
            try:
                self.videos[key].append(Video(line))
            except:
                pass

    def process_all_schedules(self):
        for filename in glob.glob(self.schedule_dir + '/*.txt'):
            filename = os.path.abspath(filename)
            with open(filename, 'rb') as f:
                self.process_schedule(filename, f)

    def show_next(self):
        item = self.playlist_next()
        if not item:
          return

        if item.type == 'image':
            self.viewRoot.showImage(item.filename)
            QTimer.singleShot(item.duration * 1000, self.show_next)
        elif item.type == 'video':
            self.viewRoot.showVideo(item.filename)

    def playlist_next(self):
        if len(self.playlist) == 0:
            self.process_all_schedules()
            today = date.today()
            all_videos = []
            for key in sorted(self.videos.keys()):
                all_videos += self.videos[key]
            self.playlist = [video for video in all_videos
                    if video.start_date <= today and video.end_date >= today]
        if len(self.playlist) == 0:
            return None
        return self.playlist.pop(0)
开发者ID:fmfi-svt,项目名称:infoboard,代码行数:73,代码来源:server.py


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