コード例 #1
0
ファイル: runtool.py プロジェクト: q9512268/core
    def draw_command_frame(self) -> None:
        # the main frame
        frame = ttk.Frame(self.top)
        frame.grid(row=0, column=0, sticky=tk.NSEW, padx=PADX)
        frame.columnconfigure(0, weight=1)
        frame.rowconfigure(1, weight=1)

        labeled_frame = ttk.LabelFrame(frame, text="Command", padding=FRAME_PAD)
        labeled_frame.grid(sticky=tk.EW, pady=PADY)
        labeled_frame.rowconfigure(0, weight=1)
        labeled_frame.columnconfigure(0, weight=1)
        entry = ttk.Entry(labeled_frame, textvariable=self.cmd)
        entry.grid(sticky=tk.EW)

        # results frame
        labeled_frame = ttk.LabelFrame(frame, text="Output", padding=FRAME_PAD)
        labeled_frame.grid(sticky=tk.NSEW, pady=PADY)
        labeled_frame.columnconfigure(0, weight=1)
        labeled_frame.rowconfigure(0, weight=1)

        self.result = CodeText(labeled_frame)
        self.result.text.config(state=tk.DISABLED, height=15)
        self.result.grid(sticky=tk.NSEW, pady=PADY)
        button_frame = ttk.Frame(labeled_frame)
        button_frame.grid(sticky=tk.NSEW)
        button_frame.columnconfigure(0, weight=1)
        button_frame.columnconfigure(1, weight=1)
        button = ttk.Button(button_frame, text="Run", command=self.click_run)
        button.grid(sticky=tk.EW, padx=PADX)
        button = ttk.Button(button_frame, text="Close", command=self.destroy)
        button.grid(row=0, column=1, sticky=tk.EW)
コード例 #2
0
ファイル: copyserviceconfig.py プロジェクト: umr-ds/core
 def draw(self) -> None:
     self.top.columnconfigure(0, weight=1)
     self.top.rowconfigure(0, weight=1)
     self.service_data = CodeText(self.top)
     self.service_data.grid(sticky="nsew", pady=PADY)
     self.service_data.text.insert(tk.END, self.data)
     self.service_data.text.config(state=tk.DISABLED)
     button = ttk.Button(self.top, text="Close", command=self.destroy)
     button.grid(sticky="ew")
コード例 #3
0
 def draw(self):
     self.top.columnconfigure(0, weight=1)
     self.top.rowconfigure(0, weight=1)
     image = Images.get(ImageEnum.ERROR, 36)
     label = ttk.Label(self.top, image=image)
     label.image = image
     label.grid(row=0, column=0)
     self.error_message = CodeText(self.top)
     self.error_message.text.insert("1.0", self.details)
     self.error_message.text.config(state="disabled")
     self.error_message.grid(row=1, column=0, sticky="nsew")
コード例 #4
0
ファイル: about.py プロジェクト: montag451/core
    def draw(self):
        self.top.columnconfigure(0, weight=1)
        self.top.rowconfigure(0, weight=1)

        codetext = CodeText(self.top)
        codetext.text.insert("1.0", LICENSE)
        codetext.text.config(state=tk.DISABLED)
        codetext.grid(sticky="nsew")

        label = ttk.Label(
            self.top, text="Icons from https://icons8.com", anchor=tk.CENTER
        )
        label.grid(sticky="ew")
コード例 #5
0
ファイル: error.py プロジェクト: xiaoxiaopingzi/core
 def draw(self) -> None:
     self.top.columnconfigure(0, weight=1)
     self.top.rowconfigure(1, weight=1)
     image = images.from_enum(ImageEnum.ERROR, width=images.ERROR_SIZE)
     label = ttk.Label(
         self.top, text=self.message, image=image, compound=tk.LEFT, anchor=tk.CENTER
     )
     label.image = image
     label.grid(sticky=tk.W, pady=PADY)
     self.error_message = CodeText(self.top)
     self.error_message.text.insert("1.0", self.details)
     self.error_message.text.config(state=tk.DISABLED)
     self.error_message.grid(sticky=tk.EW, pady=PADY)
     button = ttk.Button(self.top, text="Close", command=lambda: self.destroy())
     button.grid(sticky=tk.EW)
コード例 #6
0
    def draw(self):
        self.top.columnconfigure(0, weight=1)
        self.top.rowconfigure(1, weight=1)

        # name and states
        frame = ttk.Frame(self.top)
        frame.grid(sticky="ew", pady=PADY)
        frame.columnconfigure(0, weight=2)
        frame.columnconfigure(1, weight=7)
        frame.columnconfigure(2, weight=1)
        label = ttk.Label(frame, text="Name")
        label.grid(row=0, column=0, sticky="ew", padx=PADX)
        entry = ttk.Entry(frame, textvariable=self.name)
        entry.grid(row=0, column=1, sticky="ew", padx=PADX)
        values = tuple(x for x in core_pb2.SessionState.Enum.keys()
                       if x != "NONE")
        initial_state = core_pb2.SessionState.Enum.Name(
            core_pb2.SessionState.RUNTIME)
        self.state.set(initial_state)
        self.name.set(f"{initial_state.lower()}_hook.sh")
        combobox = ttk.Combobox(frame,
                                textvariable=self.state,
                                values=values,
                                state="readonly")
        combobox.grid(row=0, column=2, sticky="ew")
        combobox.bind("<<ComboboxSelected>>", self.state_change)

        # data
        self.codetext = CodeText(self.top)
        self.codetext.text.insert(
            1.0,
            ("#!/bin/sh\n"
             "# session hook script; write commands here to execute on the host at the\n"
             "# specified state\n"),
        )
        self.codetext.grid(sticky="nsew", pady=PADY)

        # button row
        frame = ttk.Frame(self.top)
        frame.grid(sticky="ew")
        for i in range(2):
            frame.columnconfigure(i, weight=1)
        button = ttk.Button(frame, text="Save", command=lambda: self.save())
        button.grid(row=0, column=0, sticky="ew", padx=PADX)
        button = ttk.Button(frame,
                            text="Cancel",
                            command=lambda: self.destroy())
        button.grid(row=0, column=1, sticky="ew")
コード例 #7
0
    def draw_tab_files(self) -> None:
        tab = ttk.Frame(self.notebook, padding=FRAME_PAD)
        tab.grid(sticky=tk.NSEW)
        tab.columnconfigure(0, weight=1)
        self.notebook.add(tab, text="Directories/Files")

        label = ttk.Label(
            tab, text="Directories and templates that will be used for this service."
        )
        label.grid(pady=PADY)

        frame = ttk.Frame(tab)
        frame.grid(sticky=tk.EW, pady=PADY)
        frame.columnconfigure(1, weight=1)
        label = ttk.Label(frame, text="Directories")
        label.grid(row=0, column=0, sticky=tk.W, padx=PADX)
        directories_combobox = ttk.Combobox(
            frame, values=self.directories, state="readonly"
        )
        directories_combobox.grid(row=0, column=1, sticky=tk.EW, pady=PADY)
        if self.directories:
            directories_combobox.current(0)

        label = ttk.Label(frame, text="Templates")
        label.grid(row=1, column=0, sticky=tk.W, padx=PADX)
        self.templates_combobox = ttk.Combobox(
            frame, values=self.templates, state="readonly"
        )
        self.templates_combobox.bind(
            "<<ComboboxSelected>>", self.handle_template_changed
        )
        self.templates_combobox.grid(row=1, column=1, sticky=tk.EW, pady=PADY)

        self.template_text = CodeText(tab)
        self.template_text.grid(sticky=tk.NSEW)
        tab.rowconfigure(self.template_text.grid_info()["row"], weight=1)
        if self.templates:
            self.templates_combobox.current(0)
            self.template_text.text.delete(1.0, "end")
            self.template_text.text.insert(
                "end", self.temp_service_files[self.templates[0]]
            )
        self.template_text.text.bind("<FocusOut>", self.update_template_file_data)
コード例 #8
0
    def draw(self):
        self.top.columnconfigure(0, weight=1)
        frame = ttk.Frame(self.top, padding=FRAME_PAD)
        frame.columnconfigure(0, weight=1)
        frame.columnconfigure(1, weight=10)
        frame.grid(row=0, column=0, sticky="ew")
        label = ttk.Label(frame, text="File: ")
        label.grid(row=0, column=0, sticky="ew", padx=PADX)
        entry = ttk.Entry(frame, textvariable=self.filepath)
        entry.config(state="disabled")
        entry.grid(row=0, column=1, sticky="ew")

        self.service_data = CodeText(self.top)
        self.service_data.grid(row=1, column=0, sticky="nsew")
        self.service_data.text.insert("end", self.data)
        self.service_data.text.config(state="disabled")

        button = ttk.Button(self.top, text="Close", command=self.destroy)
        button.grid(row=2, column=0, sticky="ew", padx=PADX)
コード例 #9
0
ファイル: alerts.py プロジェクト: montag451/core
 def draw(self):
     self.top.columnconfigure(0, weight=1)
     self.top.rowconfigure(1, weight=1)
     frame = ttk.Frame(self.top)
     frame.grid(row=0, column=0, sticky="ew", pady=PADY)
     frame.columnconfigure(0, weight=1)
     frame.columnconfigure(1, weight=9)
     label = ttk.Label(frame, text="File", anchor="w")
     label.grid(row=0, column=0, sticky="ew")
     entry = ttk.Entry(frame, textvariable=self.path, state="disabled")
     entry.grid(row=0, column=1, sticky="ew")
     try:
         file = open("/var/log/core-daemon.log", "r")
         log = file.readlines()
     except FileNotFoundError:
         log = "Log file not found"
     codetext = CodeText(self.top)
     codetext.text.insert("1.0", log)
     codetext.text.see("end")
     codetext.text.config(state=tk.DISABLED)
     codetext.grid(row=1, column=0, sticky="nsew")
コード例 #10
0
ファイル: error.py プロジェクト: walterhil/core
    def draw(self) -> None:
        self.top.columnconfigure(0, weight=1)
        self.top.rowconfigure(1, weight=1)

        frame = ttk.Frame(self.top, padding=FRAME_PAD)
        frame.grid(pady=PADY, sticky="ew")
        frame.columnconfigure(1, weight=1)
        image = Images.get(ImageEnum.ERROR, 36)
        label = ttk.Label(frame, image=image)
        label.image = image
        label.grid(row=0, column=0, padx=PADX)
        label = ttk.Label(frame, text=self.title)
        label.grid(row=0, column=1, sticky="ew")

        self.error_message = CodeText(self.top)
        self.error_message.text.insert("1.0", self.details)
        self.error_message.text.config(state="disabled")
        self.error_message.grid(sticky="nsew", pady=PADY)

        button = ttk.Button(self.top,
                            text="Close",
                            command=lambda: self.destroy())
        button.grid(sticky="ew")
コード例 #11
0
    def draw_tab_files(self) -> None:
        tab = ttk.Frame(self.notebook, padding=FRAME_PAD)
        tab.grid(sticky=tk.NSEW)
        tab.columnconfigure(0, weight=1)
        self.notebook.add(tab, text="Files")

        label = ttk.Label(
            tab,
            text="Config files and scripts that are generated for this service."
        )
        label.grid()

        frame = ttk.Frame(tab)
        frame.grid(sticky=tk.EW, pady=PADY)
        frame.columnconfigure(1, weight=1)
        label = ttk.Label(frame, text="File Name")
        label.grid(row=0, column=0, padx=PADX, sticky=tk.W)
        self.filename_combobox = ttk.Combobox(frame, values=self.filenames)
        self.filename_combobox.bind("<<ComboboxSelected>>",
                                    self.display_service_file_data)
        self.filename_combobox.grid(row=0, column=1, sticky=tk.EW, padx=PADX)
        button = ttk.Button(frame,
                            image=self.documentnew_img,
                            command=self.add_filename)
        button.grid(row=0, column=2, padx=PADX)
        button = ttk.Button(frame,
                            image=self.editdelete_img,
                            command=self.delete_filename)
        button.grid(row=0, column=3)

        frame = ttk.Frame(tab)
        frame.grid(sticky=tk.EW, pady=PADY)
        frame.columnconfigure(1, weight=1)
        button = ttk.Radiobutton(
            frame,
            variable=self.radiovar,
            text="Copy Source File",
            value=1,
            state=tk.DISABLED,
        )
        button.grid(row=0, column=0, sticky=tk.W, padx=PADX)
        entry = ttk.Entry(frame, state=tk.DISABLED)
        entry.grid(row=0, column=1, sticky=tk.EW, padx=PADX)
        image = Images.get(ImageEnum.FILEOPEN, 16)
        button = ttk.Button(frame, image=image)
        button.image = image
        button.grid(row=0, column=2)

        frame = ttk.Frame(tab)
        frame.grid(sticky=tk.EW, pady=PADY)
        frame.columnconfigure(0, weight=1)
        button = ttk.Radiobutton(
            frame,
            variable=self.radiovar,
            text="Use text below for file contents",
            value=2,
        )
        button.grid(row=0, column=0, sticky=tk.EW)
        image = Images.get(ImageEnum.FILEOPEN, 16)
        button = ttk.Button(frame, image=image)
        button.image = image
        button.grid(row=0, column=1)
        image = Images.get(ImageEnum.DOCUMENTSAVE, 16)
        button = ttk.Button(frame, image=image)
        button.image = image
        button.grid(row=0, column=2)

        self.service_file_data = CodeText(tab)
        self.service_file_data.grid(sticky=tk.NSEW)
        tab.rowconfigure(self.service_file_data.grid_info()["row"], weight=1)
        if len(self.filenames) > 0:
            self.filename_combobox.current(0)
            self.service_file_data.text.delete(1.0, "end")
            self.service_file_data.text.insert(
                "end", self.temp_service_files[self.filenames[0]])
        self.service_file_data.text.bind("<FocusOut>",
                                         self.update_temp_service_file_data)
コード例 #12
0
ファイル: alerts.py プロジェクト: xiaoxiaopingzi/core
    def draw(self) -> None:
        self.top.columnconfigure(0, weight=1)
        self.top.rowconfigure(0, weight=1)
        self.top.rowconfigure(1, weight=1)

        frame = ttk.Frame(self.top)
        frame.columnconfigure(0, weight=1)
        frame.rowconfigure(0, weight=1)
        frame.grid(sticky=tk.NSEW, pady=PADY)
        self.tree = ttk.Treeview(
            frame,
            columns=("time", "level", "session_id", "node", "source"),
            show="headings",
        )
        self.tree.grid(row=0, column=0, sticky=tk.NSEW)
        self.tree.column("time", stretch=tk.YES)
        self.tree.heading("time", text="Time")
        self.tree.column("level", stretch=tk.YES, width=100)
        self.tree.heading("level", text="Level")
        self.tree.column("session_id", stretch=tk.YES, width=100)
        self.tree.heading("session_id", text="Session ID")
        self.tree.column("node", stretch=tk.YES, width=100)
        self.tree.heading("node", text="Node")
        self.tree.column("source", stretch=tk.YES, width=100)
        self.tree.heading("source", text="Source")
        self.tree.bind("<<TreeviewSelect>>", self.click_select)

        for exception in self.app.statusbar.core_alarms:
            level_name = exception.level.name
            node_id = exception.node_id if exception.node_id else ""
            insert_id = self.tree.insert(
                "",
                tk.END,
                text=exception.date,
                values=(
                    exception.date,
                    level_name,
                    exception.session_id,
                    node_id,
                    exception.source,
                ),
                tags=(level_name, ),
            )
            self.alarm_map[insert_id] = exception

        error_name = ExceptionLevel.ERROR.name
        self.tree.tag_configure(error_name, background="#ff6666")
        fatal_name = ExceptionLevel.FATAL.name
        self.tree.tag_configure(fatal_name, background="#d9d9d9")
        warning_name = ExceptionLevel.WARNING.name
        self.tree.tag_configure(warning_name, background="#ffff99")
        notice_name = ExceptionLevel.NOTICE.name
        self.tree.tag_configure(notice_name, background="#85e085")

        yscrollbar = ttk.Scrollbar(frame,
                                   orient="vertical",
                                   command=self.tree.yview)
        yscrollbar.grid(row=0, column=1, sticky=tk.NS)
        self.tree.configure(yscrollcommand=yscrollbar.set)

        xscrollbar = ttk.Scrollbar(frame,
                                   orient="horizontal",
                                   command=self.tree.xview)
        xscrollbar.grid(row=1, sticky=tk.EW)
        self.tree.configure(xscrollcommand=xscrollbar.set)

        self.codetext = CodeText(self.top)
        self.codetext.text.config(state=tk.DISABLED, height=11)
        self.codetext.grid(sticky=tk.NSEW, pady=PADY)

        frame = ttk.Frame(self.top)
        frame.grid(sticky=tk.EW)
        frame.columnconfigure(0, weight=1)
        frame.columnconfigure(1, weight=1)
        button = ttk.Button(frame, text="Reset", command=self.reset_alerts)
        button.grid(row=0, column=0, sticky=tk.EW, padx=PADX)
        button = ttk.Button(frame, text="Close", command=self.destroy)
        button.grid(row=0, column=1, sticky=tk.EW)