diff --git a/coretk/coretk/dialogs/about.py b/coretk/coretk/dialogs/about.py new file mode 100644 index 00000000..28ddea33 --- /dev/null +++ b/coretk/coretk/dialogs/about.py @@ -0,0 +1,44 @@ +import tkinter as tk + +from coretk.dialogs.dialog import Dialog +from coretk.widgets import CodeText + +LICENSE = """\ +Copyright (c) 2005-2020, the Boeing Company. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE.\ +""" + + +class AboutDialog(Dialog): + def __init__(self, master, app): + super().__init__(master, app, "About CORE", modal=True) + self.draw() + + def draw(self): + self.top.columnconfigure(0, weight=1) + self.top.rowconfigure(0, weight=1) + + text = CodeText(self.top) + text.insert("1.0", LICENSE) + text.config(state=tk.DISABLED) + text.grid(sticky="nsew") diff --git a/coretk/coretk/dialogs/hooks.py b/coretk/coretk/dialogs/hooks.py index dc677e12..d40f1c36 100644 --- a/coretk/coretk/dialogs/hooks.py +++ b/coretk/coretk/dialogs/hooks.py @@ -3,6 +3,7 @@ from tkinter import ttk from core.api.grpc import core_pb2 from coretk.dialogs.dialog import Dialog +from coretk.widgets import CodeText class HookDialog(Dialog): @@ -43,7 +44,7 @@ class HookDialog(Dialog): frame.columnconfigure(0, weight=1) frame.rowconfigure(0, weight=1) frame.grid(row=1, sticky="nsew", pady=2) - self.data = tk.Text(frame) + self.data = CodeText(frame) self.data.insert( 1.0, ( diff --git a/coretk/coretk/dialogs/serviceconfiguration.py b/coretk/coretk/dialogs/serviceconfiguration.py index 1d8059d8..446f9c12 100644 --- a/coretk/coretk/dialogs/serviceconfiguration.py +++ b/coretk/coretk/dialogs/serviceconfiguration.py @@ -2,12 +2,11 @@ import logging import tkinter as tk from tkinter import ttk -from tkinter.scrolledtext import ScrolledText from core.api.grpc import core_pb2 from coretk.dialogs.dialog import Dialog from coretk.images import ImageEnum, Images -from coretk.widgets import ListboxScroll +from coretk.widgets import CodeText, ListboxScroll class ServiceConfiguration(Dialog): @@ -182,7 +181,7 @@ class ServiceConfiguration(Dialog): button.grid(row=0, column=2) frame.grid(row=3, column=0, sticky="nsew") - self.service_file_data = ScrolledText(tab1) + self.service_file_data = CodeText(tab1) self.service_file_data.grid(row=4, column=0, sticky="nsew") if len(self.filenames) > 0: self.filename_combobox.current(0) diff --git a/coretk/coretk/menuaction.py b/coretk/coretk/menuaction.py index 1a64800c..c4cc27bc 100644 --- a/coretk/coretk/menuaction.py +++ b/coretk/coretk/menuaction.py @@ -12,6 +12,7 @@ import grpc from core.api.grpc import core_pb2 from coretk.appconfig import XML_PATH +from coretk.dialogs.about import AboutDialog from coretk.dialogs.canvasbackground import CanvasBackgroundDialog from coretk.dialogs.canvassizeandscale import SizeAndScaleDialog from coretk.dialogs.hooks import HooksDialog @@ -151,3 +152,7 @@ class MenuAction: def edit_observer_widgets(self): dialog = ObserverDialog(self.app, self.app) dialog.show() + + def show_about(self): + dialog = AboutDialog(self.app, self.app) + dialog.show() diff --git a/coretk/coretk/menubar.py b/coretk/coretk/menubar.py index e56c55ec..288a517f 100644 --- a/coretk/coretk/menubar.py +++ b/coretk/coretk/menubar.py @@ -462,5 +462,5 @@ class Menubar(tk.Menu): label="Core Documentation (www)", command=self.menuaction.help_core_documentation, ) - menu.add_command(label="About", state=tk.DISABLED) + menu.add_command(label="About", command=self.menuaction.show_about) self.add_cascade(label="Help", menu=menu) diff --git a/coretk/coretk/widgets.py b/coretk/coretk/widgets.py index bd6904b2..760846a3 100644 --- a/coretk/coretk/widgets.py +++ b/coretk/coretk/widgets.py @@ -1,7 +1,8 @@ import logging import tkinter as tk from functools import partial -from tkinter import ttk +from tkinter import font, ttk +from tkinter.scrolledtext import ScrolledText from core.api.grpc import core_pb2 @@ -155,3 +156,26 @@ class CheckboxList(FrameScroll): func = partial(self.clicked, name, var) checkbox = ttk.Checkbutton(self.frame, text=name, variable=var, command=func) checkbox.grid(sticky="w") + + +class CodeFont(font.Font): + def __init__(self): + super().__init__(font="TkFixedFont", color="green") + + +class CodeText(ScrolledText): + def __init__(self, master, **kwargs): + super().__init__( + master, + bd=0, + bg="black", + cursor="xterm lime lime", + fg="lime", + font=CodeFont(), + highlightbackground="black", + insertbackground="lime", + selectbackground="lime", + selectforeground="black", + relief=tk.FLAT, + **kwargs + )