added basic about dialog and created codetext widget for displaying text in terminal like colors using scrolledtext widget
This commit is contained in:
parent
0593d0c6a2
commit
9ef5cdd70b
6 changed files with 79 additions and 6 deletions
44
coretk/coretk/dialogs/about.py
Normal file
44
coretk/coretk/dialogs/about.py
Normal file
|
@ -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")
|
|
@ -3,6 +3,7 @@ from tkinter import ttk
|
||||||
|
|
||||||
from core.api.grpc import core_pb2
|
from core.api.grpc import core_pb2
|
||||||
from coretk.dialogs.dialog import Dialog
|
from coretk.dialogs.dialog import Dialog
|
||||||
|
from coretk.widgets import CodeText
|
||||||
|
|
||||||
|
|
||||||
class HookDialog(Dialog):
|
class HookDialog(Dialog):
|
||||||
|
@ -43,7 +44,7 @@ class HookDialog(Dialog):
|
||||||
frame.columnconfigure(0, weight=1)
|
frame.columnconfigure(0, weight=1)
|
||||||
frame.rowconfigure(0, weight=1)
|
frame.rowconfigure(0, weight=1)
|
||||||
frame.grid(row=1, sticky="nsew", pady=2)
|
frame.grid(row=1, sticky="nsew", pady=2)
|
||||||
self.data = tk.Text(frame)
|
self.data = CodeText(frame)
|
||||||
self.data.insert(
|
self.data.insert(
|
||||||
1.0,
|
1.0,
|
||||||
(
|
(
|
||||||
|
|
|
@ -2,12 +2,11 @@
|
||||||
import logging
|
import logging
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
from tkinter.scrolledtext import ScrolledText
|
|
||||||
|
|
||||||
from core.api.grpc import core_pb2
|
from core.api.grpc import core_pb2
|
||||||
from coretk.dialogs.dialog import Dialog
|
from coretk.dialogs.dialog import Dialog
|
||||||
from coretk.images import ImageEnum, Images
|
from coretk.images import ImageEnum, Images
|
||||||
from coretk.widgets import ListboxScroll
|
from coretk.widgets import CodeText, ListboxScroll
|
||||||
|
|
||||||
|
|
||||||
class ServiceConfiguration(Dialog):
|
class ServiceConfiguration(Dialog):
|
||||||
|
@ -182,7 +181,7 @@ class ServiceConfiguration(Dialog):
|
||||||
button.grid(row=0, column=2)
|
button.grid(row=0, column=2)
|
||||||
frame.grid(row=3, column=0, sticky="nsew")
|
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")
|
self.service_file_data.grid(row=4, column=0, sticky="nsew")
|
||||||
if len(self.filenames) > 0:
|
if len(self.filenames) > 0:
|
||||||
self.filename_combobox.current(0)
|
self.filename_combobox.current(0)
|
||||||
|
|
|
@ -12,6 +12,7 @@ import grpc
|
||||||
|
|
||||||
from core.api.grpc import core_pb2
|
from core.api.grpc import core_pb2
|
||||||
from coretk.appconfig import XML_PATH
|
from coretk.appconfig import XML_PATH
|
||||||
|
from coretk.dialogs.about import AboutDialog
|
||||||
from coretk.dialogs.canvasbackground import CanvasBackgroundDialog
|
from coretk.dialogs.canvasbackground import CanvasBackgroundDialog
|
||||||
from coretk.dialogs.canvassizeandscale import SizeAndScaleDialog
|
from coretk.dialogs.canvassizeandscale import SizeAndScaleDialog
|
||||||
from coretk.dialogs.hooks import HooksDialog
|
from coretk.dialogs.hooks import HooksDialog
|
||||||
|
@ -151,3 +152,7 @@ class MenuAction:
|
||||||
def edit_observer_widgets(self):
|
def edit_observer_widgets(self):
|
||||||
dialog = ObserverDialog(self.app, self.app)
|
dialog = ObserverDialog(self.app, self.app)
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
|
def show_about(self):
|
||||||
|
dialog = AboutDialog(self.app, self.app)
|
||||||
|
dialog.show()
|
||||||
|
|
|
@ -462,5 +462,5 @@ class Menubar(tk.Menu):
|
||||||
label="Core Documentation (www)",
|
label="Core Documentation (www)",
|
||||||
command=self.menuaction.help_core_documentation,
|
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)
|
self.add_cascade(label="Help", menu=menu)
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import logging
|
import logging
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from functools import partial
|
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
|
from core.api.grpc import core_pb2
|
||||||
|
|
||||||
|
@ -155,3 +156,26 @@ class CheckboxList(FrameScroll):
|
||||||
func = partial(self.clicked, name, var)
|
func = partial(self.clicked, name, var)
|
||||||
checkbox = ttk.Checkbutton(self.frame, text=name, variable=var, command=func)
|
checkbox = ttk.Checkbutton(self.frame, text=name, variable=var, command=func)
|
||||||
checkbox.grid(sticky="w")
|
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
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue