mirror of
https://github.com/markqvist/NomadNet.git
synced 2024-10-01 01:26:07 -04:00
Added log display
This commit is contained in:
parent
48f3cd50c7
commit
8aec40fba2
@ -241,6 +241,9 @@ class NomadNetworkApp:
|
||||
else:
|
||||
self.config["textui"]["intro_time"] = self.config["textui"].as_int("intro_time")
|
||||
|
||||
if not "editor" in self.config["textui"]:
|
||||
self.config["textui"]["editor"] = "editor"
|
||||
|
||||
if not "animation_interval" in self.config["textui"]:
|
||||
self.config["textui"]["animation_interval"] = 1
|
||||
else:
|
||||
@ -324,6 +327,7 @@ user_interface = text
|
||||
|
||||
[textui]
|
||||
|
||||
# Amount of time to show intro screen
|
||||
intro_time = 1
|
||||
|
||||
# Specify the number of colors to use
|
||||
@ -341,6 +345,11 @@ colormode = 16
|
||||
# colormode = 256
|
||||
# colormode = 24bit
|
||||
|
||||
# What editor to use for editing text. By
|
||||
# default the operating systems "editor"
|
||||
# alias will be used.
|
||||
editor = editor
|
||||
|
||||
[node]
|
||||
|
||||
enable_node = No
|
||||
|
@ -1 +1 @@
|
||||
__version__ = "0.0.5"
|
||||
__version__ = "0.0.6"
|
@ -20,7 +20,7 @@ THEMES = {
|
||||
('heading', 'light gray,underline', 'default', 'underline', 'g93,underline', 'default'),
|
||||
('menubar', 'black', 'light gray', 'standout', '#111', '#bbb'),
|
||||
('shortcutbar', 'black', 'light gray', 'standout', '#111', '#bbb'),
|
||||
('body_text', 'white', 'default', 'default', '#0a0', 'default'),
|
||||
('body_text', 'white', 'default', 'default', '#ddd', 'default'),
|
||||
('error_text', 'dark red', 'default', 'default', 'dark red', 'default'),
|
||||
('warning_text', 'yellow', 'default', 'default', '#ba4', 'default'),
|
||||
('inactive_text', 'dark gray', 'default', 'default', 'dark gray', 'default'),
|
||||
|
21
nomadnet/ui/textui/Config.py
Normal file
21
nomadnet/ui/textui/Config.py
Normal file
@ -0,0 +1,21 @@
|
||||
class ConfigDisplayShortcuts():
|
||||
def __init__(self, app):
|
||||
import urwid
|
||||
self.app = app
|
||||
|
||||
self.widget = urwid.AttrMap(urwid.Text("Config Display Shortcuts"), "shortcutbar")
|
||||
|
||||
class ConfigDisplay():
|
||||
def __init__(self, app):
|
||||
import urwid
|
||||
self.app = app
|
||||
|
||||
pile = urwid.Pile([
|
||||
urwid.Text(("body_text", "Config Display \U0001F332")),
|
||||
])
|
||||
|
||||
self.shortcuts_display = ConfigDisplayShortcuts(self.app)
|
||||
self.widget = urwid.Filler(pile, 'top')
|
||||
|
||||
def shortcuts(self):
|
||||
return self.shortcuts_display
|
43
nomadnet/ui/textui/Log.py
Normal file
43
nomadnet/ui/textui/Log.py
Normal file
@ -0,0 +1,43 @@
|
||||
import urwid
|
||||
import nomadnet
|
||||
|
||||
class LogDisplayShortcuts():
|
||||
def __init__(self, app):
|
||||
import urwid
|
||||
self.app = app
|
||||
|
||||
self.widget = urwid.AttrMap(urwid.Text("Log Display Shortcuts"), "shortcutbar")
|
||||
|
||||
class LogDisplay():
|
||||
def __init__(self, app):
|
||||
import urwid
|
||||
self.app = app
|
||||
self.log_term = LogTerminal(self.app)
|
||||
|
||||
pile = urwid.Pile([
|
||||
("weight", 90, self.log_term),
|
||||
("fixed", 1, urwid.Text(("body_text", "Log Display \U0001F332"))),
|
||||
])
|
||||
|
||||
self.shortcuts_display = LogDisplayShortcuts(self.app)
|
||||
self.widget = urwid.LineBox(self.log_term)
|
||||
|
||||
def shortcuts(self):
|
||||
return self.shortcuts_display
|
||||
|
||||
class LogTerminal(urwid.WidgetWrap):
|
||||
def __init__(self, app):
|
||||
self.app = app
|
||||
self.log_term = urwid.Terminal(
|
||||
("tail", "-fn50", self.app.logfilepath),
|
||||
encoding='utf-8',
|
||||
escape_sequence="up"
|
||||
)
|
||||
urwid.WidgetWrap.__init__(self, self.log_term)
|
||||
|
||||
|
||||
def keypress(self, size, key):
|
||||
if key == "up":
|
||||
nomadnet.NomadNetworkApp.get_shared_instance().ui.main_display.frame.set_focus("header")
|
||||
|
||||
return super(LogTerminal, self).keypress(size, key)
|
@ -4,7 +4,9 @@ import time
|
||||
from .Network import *
|
||||
from .Conversations import *
|
||||
from .Directory import *
|
||||
from .Config import *
|
||||
from .Map import *
|
||||
from .Log import *
|
||||
import urwid
|
||||
|
||||
class SubDisplays():
|
||||
@ -13,7 +15,9 @@ class SubDisplays():
|
||||
self.network_display = NetworkDisplay(self.app)
|
||||
self.conversations_display = ConversationsDisplay(self.app)
|
||||
self.directory_display = DirectoryDisplay(self.app)
|
||||
self.config_display = ConfigDisplay(self.app)
|
||||
self.map_display = MapDisplay(self.app)
|
||||
self.log_display = LogDisplay(self.app)
|
||||
|
||||
self.active_display = self.conversations_display
|
||||
|
||||
@ -101,6 +105,14 @@ class MainDisplay():
|
||||
self.sub_displays.active_display = self.sub_displays.map_display
|
||||
self.update_active_sub_display()
|
||||
|
||||
def show_config(self, user_data):
|
||||
self.sub_displays.active_display = self.sub_displays.config_display
|
||||
self.update_active_sub_display()
|
||||
|
||||
def show_log(self, user_data):
|
||||
self.sub_displays.active_display = self.sub_displays.log_display
|
||||
self.update_active_sub_display()
|
||||
|
||||
def update_active_sub_display(self):
|
||||
self.frame.contents["body"] = (self.sub_displays.active().widget, None)
|
||||
self.update_active_shortcuts()
|
||||
@ -127,11 +139,13 @@ class MenuDisplay():
|
||||
button_network = (11, MenuButton("Network", on_press=handler.show_network))
|
||||
button_conversations = (17, MenuButton("Conversations", on_press=handler.show_conversations))
|
||||
button_directory = (13, MenuButton("Directory", on_press=handler.show_directory))
|
||||
button_map = (7, MenuButton("Map", on_press=handler.show_map))
|
||||
button_quit = (8, MenuButton("Quit", on_press=handler.quit))
|
||||
button_map = (7, MenuButton("Map", on_press=handler.show_map))
|
||||
button_log = (7, MenuButton("Log", on_press=handler.show_log))
|
||||
button_config = (10, MenuButton("Config", on_press=handler.show_config))
|
||||
button_quit = (8, MenuButton("Quit", on_press=handler.quit))
|
||||
|
||||
# buttons = [menu_text, button_conversations, button_node, button_directory, button_map]
|
||||
buttons = [menu_text, button_conversations, button_network, button_quit]
|
||||
buttons = [menu_text, button_conversations, button_network, button_log, button_config, button_quit]
|
||||
columns = MenuColumns(buttons, dividechars=1)
|
||||
columns.handler = handler
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user