Example #1
0
    def _fillMenu(self):
        """Fill the menu.
        """
        #       print "%s _fillMenu"

        itemKeys = self.itemDict.keys()
        itemKeys.sort()
        #       print "%s found items: %s" % (self, itemKeys)
        for label in itemKeys:
            subPathList = list(self.getLabels()) + [label]
            fullPath = self.itemDict[label]
            #               print "adding script %r: %r" % (label, fullPath)
            self.menu.add_command(
                label=label,
                command=ScriptLoader(subPathList=subPathList,
                                     fullPath=fullPath),
            )

        subdirList = self.subDict.keys()
        subdirList.sort()
        #       print "%s found subdirs: %s" % (self, subdirList)
        for subdir in subdirList:
            pathList = self.subDict[subdir]
            #               print "adding submenu %r: %r" % (subdir, pathList)
            self.subNodeList.append(_MenuNode(self, subdir, pathList))
Example #2
0
 def doOpen(self):
     """Handle Open... menu item.
     """
     initialDir = os.path.expanduser("~")
     if initialDir == "~":
         initialDir = None
     fullPath = tkFileDialog.askopenfilename(
         master=self.master,
         initialdir=initialDir,
         title="TUI Script",
         filetypes=[("Python", "*.py")],
     )
     if not fullPath:
         return
     pathList = os.path.split(fullPath)
     ScriptLoader(subPathList=pathList, fullPath=fullPath)()