예제 #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()
예제 #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)
예제 #3
0
 def _create_statusbar(self):
     self.statusbar = Statusbar(self)
예제 #4
0
 def _create_statusbar(self):
     self.statusbar = Statusbar(self)
     self.statusbar.pack(side="bottom", fill="x")
     self.statusbar.add_section("port",12, "port %s" % self.listener.port)
     self.statusbar.add_progress(mode="indeterminate")
예제 #5
0
class MonitorApp(AbstractRwbGui):
    def __init__(self):
        AbstractRwbGui.__init__(self, NAME, DEFAULT_SETTINGS)
        self.wm_geometry("900x500")
        port = self.get_setting("monitor.port")
        print "using port", port
        self.listener = RemoteRobotListener(self, port=port, callback=self._listen)
        self.wm_title("rwb.monitor port: %s" % self.listener.port)
        self._create_menubar()
        self._create_statusbar()
        self._create_notebook()
        self.stack = []
        self.event_id = 0
#        self.status_label.configure(text="port: %s" % self.listener.port)

    def _create_menubar(self):
        self.menubar = tk.Menu(self)
        self.configure(menu=self.menubar)

        self.file_menu = tk.Menu(self.menubar, tearoff=False)
        self.file_menu.add_command(label="Exit", command=self._on_exit)

        self.help_menu = tk.Menu(self, tearoff=False)
        self.help_menu.add_command(label="View help on the web", command=self._on_view_help)
        self.help_menu.add_separator()
        self.help_menu.add_command(label="About the robotframework workbench", command=self._on_about)

        self.menubar.add_cascade(menu=self.file_menu, label="File", underline=0)
        self.menubar.add_cascade(menu=self.help_menu, label="Help", underline=0)

    def _on_view_help(self):
        import webbrowser
        webbrowser.open(HELP_URL)

    def _on_exit(self):
        self.destroy()

    def _create_statusbar(self):
        self.statusbar = Statusbar(self)
        self.statusbar.pack(side="bottom", fill="x")
        self.statusbar.add_section("port",12, "port %s" % self.listener.port)
        self.statusbar.add_progress(mode="indeterminate")
        # grip = ttk.Sizegrip(self.statusbar)
        # grip.pack(side="right")
        # self.status_label = ttk.Label(self.statusbar, text="", anchor="w")
        # self.status_label.pack(side="left", fill="both", expand="true", padx=8)
        # self.statusbar.pack(side="bottom", fill="x")

    def _create_notebook(self):
        self.notebook = ttk.Notebook(self)
        self.notebook.pack(side="top", fill="both", expand=True)
        self.log_tree = RobotLogTree(self.notebook, auto_open=("failed","suite","test","keyword"))
        self.log_messages = RobotLogMessages(self.notebook)
        self.notebook.add(self.log_tree, text="Details")
        self.notebook.add(self.log_messages, text="Messages")
        self.notebook.pack(side="top", fill="both", expand=True)
        self.listeners = (self.log_tree, self.log_messages)

    def _listen(self, cmd, *args):
        self.event_id += 1
        for listener in self.listeners:
            listener.listen(self.event_id, cmd, args)

        if cmd in ("start_test", "start_suite", "start_keyword"):
            name = args[0]
            cmd_type = cmd.split("_")[1]
            self.stack.append((cmd_type, name))
            self.update_display()
        elif cmd in ("end_test", "end_suite", "end_keyword"):
            cmd_type = cmd.split("_")[1]
            self.stack.pop()
            self.update_display()

    def update_display(self):
        if len(self.stack) == 1:
            self.statusbar.progress_start()
        elif len(self.stack) == 0:
            self.statusbar.progress_stop()

        s = ".".join([x[1] for x in self.stack]).strip()
        self.statusbar.message(s, clear=True, lifespan=0)
예제 #6
0
 def _create_statusbar(self):
     self.statusbar = Statusbar(self)
     self.statusbar.pack(side="bottom", fill="x")
     self.statusbar.add_section("port", 12, "port %s" % self.listener.port)
     self.statusbar.add_progress(mode="indeterminate")
예제 #7
0
class MonitorApp(AbstractRwbGui):
    def __init__(self):
        AbstractRwbGui.__init__(self, NAME, DEFAULT_SETTINGS)
        self.wm_geometry("900x500")
        port = self.get_setting("monitor.port")
        print "using port", port
        self.listener = RemoteRobotListener(self,
                                            port=port,
                                            callback=self._listen)
        self.wm_title("rwb.monitor port: %s" % self.listener.port)
        self._create_menubar()
        self._create_statusbar()
        self._create_notebook()
        self.stack = []
        self.event_id = 0


#        self.status_label.configure(text="port: %s" % self.listener.port)

    def _create_menubar(self):
        self.menubar = tk.Menu(self)
        self.configure(menu=self.menubar)

        self.file_menu = tk.Menu(self.menubar, tearoff=False)
        self.file_menu.add_command(label="Exit", command=self._on_exit)

        self.help_menu = tk.Menu(self, tearoff=False)
        self.help_menu.add_command(label="View help on the web",
                                   command=self._on_view_help)
        self.help_menu.add_separator()
        self.help_menu.add_command(label="About the robotframework workbench",
                                   command=self._on_about)

        self.menubar.add_cascade(menu=self.file_menu,
                                 label="File",
                                 underline=0)
        self.menubar.add_cascade(menu=self.help_menu,
                                 label="Help",
                                 underline=0)

    def _on_view_help(self):
        import webbrowser
        webbrowser.open(HELP_URL)

    def _on_exit(self):
        self.destroy()

    def _create_statusbar(self):
        self.statusbar = Statusbar(self)
        self.statusbar.pack(side="bottom", fill="x")
        self.statusbar.add_section("port", 12, "port %s" % self.listener.port)
        self.statusbar.add_progress(mode="indeterminate")
        # grip = ttk.Sizegrip(self.statusbar)
        # grip.pack(side="right")
        # self.status_label = ttk.Label(self.statusbar, text="", anchor="w")
        # self.status_label.pack(side="left", fill="both", expand="true", padx=8)
        # self.statusbar.pack(side="bottom", fill="x")

    def _create_notebook(self):
        self.notebook = ttk.Notebook(self)
        self.notebook.pack(side="top", fill="both", expand=True)
        self.log_tree = RobotLogTree(self.notebook,
                                     auto_open=("failed", "suite", "test",
                                                "keyword"))
        self.log_messages = RobotLogMessages(self.notebook)
        self.notebook.add(self.log_tree, text="Details")
        self.notebook.add(self.log_messages, text="Messages")
        self.notebook.pack(side="top", fill="both", expand=True)
        self.listeners = (self.log_tree, self.log_messages)

    def _listen(self, cmd, *args):
        self.event_id += 1
        for listener in self.listeners:
            listener.listen(self.event_id, cmd, args)

        if cmd in ("start_test", "start_suite", "start_keyword"):
            name = args[0]
            cmd_type = cmd.split("_")[1]
            self.stack.append((cmd_type, name))
            self.update_display()
        elif cmd in ("end_test", "end_suite", "end_keyword"):
            cmd_type = cmd.split("_")[1]
            self.stack.pop()
            self.update_display()

    def update_display(self):
        if len(self.stack) == 1:
            self.statusbar.progress_start()
        elif len(self.stack) == 0:
            self.statusbar.progress_stop()

        s = ".".join([x[1] for x in self.stack]).strip()
        self.statusbar.message(s, clear=True, lifespan=0)