BlinkenArea - GitList
Repositories
Blog
Wiki
stage_director
Code
Commits
Branches
Tags
Search
Tree:
8418363
Branches
Tags
master
stage_director
sync_gui.py
show current position as h:mm:ss.ss
Stefan Schuermans
commited
8418363
at 2013-11-14 21:38:33
sync_gui.py
Blame
History
Raw
#! /usr/bin/env python import os from gi.repository import Gtk import time_fmt scriptdir = os.path.dirname(os.path.abspath(__file__)) class SyncGui: def __init__(self): self.builder = Gtk.Builder() self.builder.add_from_file(scriptdir + "/sync_gui.glade") self.position = self.builder.get_object("Position") self.positionScale = self.builder.get_object("PositionScale") self.positionAt = self.builder.get_object("PositionAt") self.positionRemaining = self.builder.get_object("PositionRemaining") self.btnPause = self.builder.get_object("Pause") self.btnPlay = self.builder.get_object("Play") self.status = self.builder.get_object("Status") handlers = { "onDestroy": self.onDestroy, "onNewPosition": self.onNewPosition, "onPrevious": self.onPrevious, "onBackward": self.onBackward, "onStop": self.onStop, "onPause": self.onPause, "onPlay": self.onPlay, "onForward": self.onForward, "onNext": self.onNext, } self.builder.connect_signals(handlers) self.status.push(0, "TODO...") self.showCurrentPosition() def showPosition(self, sec): if sec < 0: sec = 0 if sec > self.position.get_upper(): sec = self.position.get_upper() posAt = time_fmt.sec2str(sec) posRemaining = time_fmt.sec2str(self.position.get_upper() - sec) self.positionAt.set_text(posAt) self.positionRemaining.set_text(posRemaining) def showCurrentPosition(self): sec = self.positionScale.get_value() self.showPosition(sec) def onDestroy(self, widget): Gtk.main_quit() def onNewPosition(self, widget, scroll, value): print("new position " + str(value)); self.showPosition(value) def onPrevious(self, widget): print("previous") def onBackward(self, widget): print("backward") def onStop(self, widget): print("stop") self.btnPause.set_visible(False) self.btnPlay.set_visible(True) def onPause(self, widget): print("pause") self.btnPause.set_visible(False) self.btnPlay.set_visible(True) def onPlay(self, widget): print("play") self.btnPause.set_visible(True) self.btnPlay.set_visible(False) def onForward(self, widget): print("forward") def onNext(self, widget): print("next") if __name__ == "__main__": app = SyncGui() Gtk.main()