Ejemplo n.º 1
0
def popupControls(self, tl = None):
    """
    Popup control panel for interval.
    """
    from panda3d.direct.showbase.TkGlobal import Toplevel, Frame, Button, LEFT, X, Pmw
    import math
    from panda3d.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)
Ejemplo n.º 2
0
def popupControls(self, tl = None):
        """
        Popup control panel for interval.
        """
        from panda3d.direct.showbase.TkGlobal import Toplevel, Frame, Button, LEFT, X, Pmw
        import math
        from panda3d.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.setT(0.0)
            s.pause()
        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)
Ejemplo n.º 3
0
    def __init__(self, directNotify, tl = None):
        """
        NotifyPanel class pops up a control panel to view/set
        notify levels for all available DIRECT and PANDA notify categories
        """
        # Make sure TK mainloop is running
        from panda3d.direct.showbase.TkGlobal import Pmw, Toplevel, Frame
        from panda3d.direct.showbase.TkGlobal import Label, Radiobutton
        from panda3d.direct.showbase.TkGlobal import HORIZONTAL, X, W, NW, BOTH, LEFT, RIGHT, IntVar
        # To get severity levels
        from panda3d.pandac import NSFatal, NSError, NSWarning, NSInfo
        from panda3d.pandac import NSDebug, NSSpam

        if tl == None:
            tl = Toplevel()
            tl.title('Notify Controls')
            tl.geometry('300x400')
        # Init active category
        self.activeCategory = None
        # Create widgets
        mainFrame = Frame(tl)
        # Paned widget for dividing two halves
        framePane = Pmw.PanedWidget(mainFrame,
                                    orient = HORIZONTAL)
        categoryFrame = framePane.add('categories', size = 200)
        severityFrame = framePane.add('severities', size = 50)
        # Category frame
        # Assemble PANDA categories
        categories = self.getPandaCategoriesAsList()
        self.__categories = {}
        categoryNames = []
        for category in categories:
            name = category.getBasename()
            self.__categories[name] = category
            categoryNames.append(name)
        # Assemble DIRECT categories
        for name in directNotify.getCategories():
            category = directNotify.getCategory(name)
            self.__categories[name] = category
            categoryNames.append(name)
        # Sort resulting list of names
        categoryNames.sort()
        # Create a listbox
        self.categoryList = Pmw.ScrolledListBox(
            categoryFrame,
            labelpos = 'nw', label_text = 'Categories:',
            label_font=('MSSansSerif', 10, 'bold'),
            listbox_takefocus = 1,
            items = categoryNames,
            selectioncommand = self.setActivePandaCategory)
        self.categoryList.pack(expand = 1, fill = 'both')
                                           
        # Severity frame
        Label(severityFrame, text = 'Severity:',
              font=('MSSansSerif', 10, 'bold'),
              justify = RIGHT, anchor = W).pack(fill = X, padx = 5)
        self.severity = IntVar()
        self.severity.set(0)
        self.fatalSeverity = Radiobutton(severityFrame, text = 'Fatal',
                                         justify = 'left', anchor = 'w',
                                         value = NSFatal,
                                         variable = self.severity,
                                         command = self.setActiveSeverity)
        self.fatalSeverity.pack(fill = X)
        self.errorSeverity = Radiobutton(severityFrame, text = 'Error',
                                         justify = 'left', anchor = 'w',
                                         value = NSError,
                                         variable = self.severity,
                                         command = self.setActiveSeverity)
        self.errorSeverity.pack(fill = X)
        self.warningSeverity = Radiobutton(severityFrame, text = 'Warning',
                                           justify = 'left', anchor = 'w',
                                           value = NSWarning,
                                           variable = self.severity,
                                           command = self.setActiveSeverity)
        self.warningSeverity.pack(fill = X)
        self.infoSeverity = Radiobutton(severityFrame, text = 'Info',
                                        justify = 'left', anchor = 'w',
                                        value = NSInfo,
                                        variable = self.severity,
                                        command = self.setActiveSeverity)
        self.infoSeverity.pack(fill = X)
        self.debugSeverity = Radiobutton(severityFrame, text = 'Debug',
                                         justify = 'left', anchor = 'w',
                                         value = NSDebug,
                                         variable = self.severity,
                                         command = self.setActiveSeverity)
        self.debugSeverity.pack(fill = X)
        self.spamSeverity = Radiobutton(severityFrame, text = 'Spam',
                                        justify = 'left', anchor = 'w',
                                        value = NSSpam,
                                        variable = self.severity,
                                        command = self.setActiveSeverity)
        self.spamSeverity.pack(fill = X)
        # Pack frames
        framePane.pack(expand = 1, fill = 'both')
        mainFrame.pack(expand = 1, fill = 'both')
        # Get listbox
        listbox = self.categoryList.component('listbox')
        # Bind updates to arrow buttons
        listbox.bind('<KeyRelease-Up>', self.setActivePandaCategory)
        listbox.bind('<KeyRelease-Down>', self.setActivePandaCategory)
        # And grab focus (to allow keyboard navigation)
        listbox.focus_set()
        # And set active index (so keypresses will start with index 0)
        listbox.activate(0)
        # Select first item
        self.categoryList.select_set(0)
        self.setActivePandaCategory()
Ejemplo n.º 4
0
    def __init__(self, directNotify, tl=None):
        """
        NotifyPanel class pops up a control panel to view/set
        notify levels for all available DIRECT and PANDA notify categories
        """
        # Make sure TK mainloop is running
        from panda3d.direct.showbase.TkGlobal import Pmw, Toplevel, Frame
        from panda3d.direct.showbase.TkGlobal import Label, Radiobutton
        from panda3d.direct.showbase.TkGlobal import HORIZONTAL, X, W, NW, BOTH, LEFT, RIGHT, IntVar
        # To get severity levels
        from panda3d.pandac import NSFatal, NSError, NSWarning, NSInfo
        from panda3d.pandac import NSDebug, NSSpam

        if tl == None:
            tl = Toplevel()
            tl.title('Notify Controls')
            tl.geometry('300x400')
        # Init active category
        self.activeCategory = None
        # Create widgets
        mainFrame = Frame(tl)
        # Paned widget for dividing two halves
        framePane = Pmw.PanedWidget(mainFrame, orient=HORIZONTAL)
        categoryFrame = framePane.add('categories', size=200)
        severityFrame = framePane.add('severities', size=50)
        # Category frame
        # Assemble PANDA categories
        categories = self.getPandaCategoriesAsList()
        self.__categories = {}
        categoryNames = []
        for category in categories:
            name = category.getBasename()
            self.__categories[name] = category
            categoryNames.append(name)
        # Assemble DIRECT categories
        for name in directNotify.getCategories():
            category = directNotify.getCategory(name)
            self.__categories[name] = category
            categoryNames.append(name)
        # Sort resulting list of names
        categoryNames.sort()
        # Create a listbox
        self.categoryList = Pmw.ScrolledListBox(
            categoryFrame,
            labelpos='nw',
            label_text='Categories:',
            label_font=('MSSansSerif', 10, 'bold'),
            listbox_takefocus=1,
            items=categoryNames,
            selectioncommand=self.setActivePandaCategory)
        self.categoryList.pack(expand=1, fill='both')

        # Severity frame
        Label(severityFrame,
              text='Severity:',
              font=('MSSansSerif', 10, 'bold'),
              justify=RIGHT,
              anchor=W).pack(fill=X, padx=5)
        self.severity = IntVar()
        self.severity.set(0)
        self.fatalSeverity = Radiobutton(severityFrame,
                                         text='Fatal',
                                         justify='left',
                                         anchor='w',
                                         value=NSFatal,
                                         variable=self.severity,
                                         command=self.setActiveSeverity)
        self.fatalSeverity.pack(fill=X)
        self.errorSeverity = Radiobutton(severityFrame,
                                         text='Error',
                                         justify='left',
                                         anchor='w',
                                         value=NSError,
                                         variable=self.severity,
                                         command=self.setActiveSeverity)
        self.errorSeverity.pack(fill=X)
        self.warningSeverity = Radiobutton(severityFrame,
                                           text='Warning',
                                           justify='left',
                                           anchor='w',
                                           value=NSWarning,
                                           variable=self.severity,
                                           command=self.setActiveSeverity)
        self.warningSeverity.pack(fill=X)
        self.infoSeverity = Radiobutton(severityFrame,
                                        text='Info',
                                        justify='left',
                                        anchor='w',
                                        value=NSInfo,
                                        variable=self.severity,
                                        command=self.setActiveSeverity)
        self.infoSeverity.pack(fill=X)
        self.debugSeverity = Radiobutton(severityFrame,
                                         text='Debug',
                                         justify='left',
                                         anchor='w',
                                         value=NSDebug,
                                         variable=self.severity,
                                         command=self.setActiveSeverity)
        self.debugSeverity.pack(fill=X)
        self.spamSeverity = Radiobutton(severityFrame,
                                        text='Spam',
                                        justify='left',
                                        anchor='w',
                                        value=NSSpam,
                                        variable=self.severity,
                                        command=self.setActiveSeverity)
        self.spamSeverity.pack(fill=X)
        # Pack frames
        framePane.pack(expand=1, fill='both')
        mainFrame.pack(expand=1, fill='both')
        # Get listbox
        listbox = self.categoryList.component('listbox')
        # Bind updates to arrow buttons
        listbox.bind('<KeyRelease-Up>', self.setActivePandaCategory)
        listbox.bind('<KeyRelease-Down>', self.setActivePandaCategory)
        # And grab focus (to allow keyboard navigation)
        listbox.focus_set()
        # And set active index (so keypresses will start with index 0)
        listbox.activate(0)
        # Select first item
        self.categoryList.select_set(0)
        self.setActivePandaCategory()