Exemple #1
0
    def __init__(self, *args, **kwargs):
        AbstractRwbGui.__init__(self, NAME, DEFAULT_SETTINGS)
        self.working_set = sys.argv[1:]

        self.wm_title("Keyword Browser - Robot Framework Workbench")
        self.kwt = KwBrowser(self, borderwidth=1, relief="solid")
        menubar = Menubar(self)
        self.statusbar = Statusbar(self)
        self.statusbar.pack(side="bottom", fill="x")
        self.kwt.pack(side="top", fill="both", expand=True, padx=4)
        self.bind("<<Reload>>", lambda event: self.reload())
        self.bind("<<LoadFile>>", lambda event: self.load_resource())
        self.configure(menu=menubar)
        self.reload()
Exemple #2
0
class KwBrowserApp(AbstractRwbGui):
    '''A Tkinter application that wraps the browser frame'''
    def __init__(self, *args, **kwargs):
        AbstractRwbGui.__init__(self, NAME, DEFAULT_SETTINGS)
        self.working_set = sys.argv[1:]

        self.wm_title("Keyword Browser - Robot Framework Workbench")
        self.kwt = KwBrowser(self, borderwidth=1, relief="solid")
        menubar = Menubar(self)
        self.statusbar = Statusbar(self)
        self.statusbar.pack(side="bottom", fill="x")
        self.kwt.pack(side="top", fill="both", expand=True, padx=4)
        self.bind("<<Reload>>", lambda event: self.reload())
        self.bind("<<LoadFile>>", lambda event: self.load_resource())
        self.configure(menu=menubar)
        self.reload()

    def reload(self):
        '''(Re)load the libdoc files

        This will load all of the .xml files in docDir, and any
        filenames that were on the command line.

        Ideally we should automatically reload if we notice the
        data source(s) has changed on disk. For now this is good
        enough
        '''
        self.kwt.reset()
        self.kwt.add_built_in_libraries()

        for path in self.working_set:
            if os.path.isdir(path):
                for filename in os.listdir(path):
                    if (filename.endswith(".xml") or 
                        filename.endswith(".txt") or
                        filename.endswith(".tsv")):
                        try:
                            fullname = os.path.join(path, filename)
                            self.kwt.add_file(fullname)
                        except Exception, e:
                            message = "unable to load '%s'" % fullname
                            message += ": " + str(e)
                            self.log.warning(message)
            else:
                try:
                    self.kwt.add_file(path)
                except Exception, e:
                    message = "unable to load '%s'" % path
                    message += ": " + str(e)
                    self.log.warning(message)