def popupControls(self, tl=None): from direct.showbase.TkGlobal import Toplevel, Frame, Button, LEFT, X, Pmw import math from direct.tkwidgets import EntryScale if tl == None: tl = Toplevel() tl.title('Interval Controls') outerFrame = Frame(tl) def entryScaleCommand(t, s=self): s.setT(t) s.pause() self.es = es = EntryScale.EntryScale( outerFrame, text=self.getName(), min=0, max=math.floor(self.getDuration() * 100) / 100, command=entryScaleCommand) es.set(self.getT(), fCommand=0) es.pack(expand=1, fill=X) bf = Frame(outerFrame) def toStart(s=self, es=es): s.setT(0.0) s.pause() def toEnd(s=self): s.setT(s.getDuration()) s.pause() jumpToStart = Button(bf, text='<<', command=toStart) def doPlay(s=self, es=es): s.resume(es.get()) stop = Button(bf, text='Stop', command=lambda s=self: s.pause()) play = Button(bf, text='Play', command=doPlay) jumpToEnd = Button(bf, text='>>', command=toEnd) jumpToStart.pack(side=LEFT, expand=1, fill=X) play.pack(side=LEFT, expand=1, fill=X) stop.pack(side=LEFT, expand=1, fill=X) jumpToEnd.pack(side=LEFT, expand=1, fill=X) bf.pack(expand=1, fill=X) outerFrame.pack(expand=1, fill=X) def update(t, es=es): es.set(t, fCommand=0) if not hasattr(self, 'setTHooks'): self.setTHooks = [] self.setTHooks.append(update) self.setWantsTCallback(1) def onDestroy(e, s=self, u=update): if u in s.setTHooks: s.setTHooks.remove(u) tl.bind('<Destroy>', onDestroy) return
def popupControls(self, tl = None): """ Popup control panel for interval. """ from direct.showbase.TkGlobal import Toplevel, Frame, Button, LEFT, X, Pmw import math from direct.tkwidgets import EntryScale if tl == None: tl = Toplevel() tl.title('Interval Controls') outerFrame = Frame(tl) def entryScaleCommand(t, s=self): s.setT(t) s.pause() self.es = es = EntryScale.EntryScale( outerFrame, text = self.getName(), min = 0, max = math.floor(self.getDuration() * 100) / 100, command = entryScaleCommand) es.set(self.getT(), fCommand = 0) es.pack(expand = 1, fill = X) bf = Frame(outerFrame) # Jump to start and end def toStart(s=self, es=es): s.clearToInitial() s.setT(0) es.set(0, fCommand = 0) def toEnd(s=self): s.setT(s.getDuration()) s.pause() jumpToStart = Button(bf, text = '<<', command = toStart) # Stop/play buttons def doPlay(s=self, es=es): s.resume(es.get()) stop = Button(bf, text = 'Stop', command = lambda s=self: s.pause()) play = Button( bf, text = 'Play', command = doPlay) jumpToEnd = Button(bf, text = '>>', command = toEnd) jumpToStart.pack(side = LEFT, expand = 1, fill = X) play.pack(side = LEFT, expand = 1, fill = X) stop.pack(side = LEFT, expand = 1, fill = X) jumpToEnd.pack(side = LEFT, expand = 1, fill = X) bf.pack(expand = 1, fill = X) outerFrame.pack(expand = 1, fill = X) # Add function to update slider during setT calls def update(t, es=es): es.set(t, fCommand = 0) if not hasattr(self, "setTHooks"): self.setTHooks = [] self.setTHooks.append(update) self.setWantsTCallback(1) # Clear out function on destroy def onDestroy(e, s=self, u=update): if u in s.setTHooks: s.setTHooks.remove(u) tl.bind('<Destroy>', onDestroy)
def popupControls(self, tl=None): """ Popup control panel for interval. """ from direct.showbase.TkGlobal import Toplevel, Frame, Button, LEFT, X, Pmw import math from direct.tkwidgets import EntryScale if tl == None: tl = Toplevel() tl.title('Interval Controls') outerFrame = Frame(tl) def entryScaleCommand(t, s=self): s.setT(t) s.pause() self.es = es = EntryScale.EntryScale( outerFrame, text=self.getName(), min=0, max=math.floor(self.getDuration() * 100) / 100, command=entryScaleCommand) es.set(self.getT(), fCommand=0) es.pack(expand=1, fill=X) bf = Frame(outerFrame) # Jump to start and end def toStart(s=self, es=es): s.clearToInitial() s.setT(0) es.set(0, fCommand=0) def toEnd(s=self): s.setT(s.getDuration()) s.pause() jumpToStart = Button(bf, text='<<', command=toStart) # Stop/play buttons def doPlay(s=self, es=es): s.resume(es.get())
def popupControls(self, tl=None): """ Popup control panel for interval. """ import math # Don't use a regular import, to prevent ModuleFinder from picking # it up as a dependency when building a .p3d package. import importlib, sys if sys.version_info >= (3, 0): tkinter = importlib.import_module('tkinter') else: tkinter = importlib.import_module('Tkinter') if tl == None: tl = tkinter.Toplevel() tl.title('Interval Controls') outerFrame = tkinter.Frame(tl) def entryScaleCommand(t, s=self): s.setT(t) s.pause() self.es = es = EntryScale.EntryScale( outerFrame, text=self.getName(), min=0, max=math.floor(self.getDuration() * 100) / 100, command=entryScaleCommand) es.set(self.getT(), fCommand=0) es.pack(expand=1, fill=tkinter.X) bf = tkinter.Frame(outerFrame) # Jump to start and end def toStart(s=self, es=es): s.setT(0.0) s.pause() def toEnd(s=self): s.setT(s.getDuration()) s.pause() jumpToStart = tkinter.Button(bf, text='<<', command=toStart) # Stop/play buttons def doPlay(s=self, es=es): s.resume(es.get()) stop = tkinter.Button(bf, text='Stop', command=lambda s=self: s.pause()) play = tkinter.Button(bf, text='Play', command=doPlay) jumpToEnd = tkinter.Button(bf, text='>>', command=toEnd) jumpToStart.pack(side=tkinter.LEFT, expand=1, fill=tkinter.X) play.pack(side=tkinter.LEFT, expand=1, fill=tkinter.X) stop.pack(side=tkinter.LEFT, expand=1, fill=tkinter.X) jumpToEnd.pack(side=tkinter.LEFT, expand=1, fill=tkinter.X) bf.pack(expand=1, fill=tkinter.X) outerFrame.pack(expand=1, fill=tkinter.X) # Add function to update slider during setT calls def update(t, es=es): es.set(t, fCommand=0) if not hasattr(self, "setTHooks"): self.setTHooks = [] self.setTHooks.append(update) self.setWantsTCallback(1) # Clear out function on destroy def onDestroy(e, s=self, u=update): if u in s.setTHooks: s.setTHooks.remove(u) tl.bind('<Destroy>', onDestroy)