mirror of
https://github.com/markqvist/NomadNet.git
synced 2025-01-11 07:09:26 -05:00
Text UI general structure
This commit is contained in:
parent
9693e3e814
commit
07a62dd08d
@ -4,6 +4,7 @@ import time
|
||||
|
||||
from nomadnet import NomadNetworkApp
|
||||
from nomadnet.ui import *
|
||||
from nomadnet.ui.textui import *
|
||||
|
||||
class TextUI:
|
||||
|
||||
@ -29,10 +30,11 @@ class TextUI:
|
||||
self.screen = urwid.raw_display.Screen()
|
||||
self.screen.register_palette(palette)
|
||||
|
||||
self.main_display = DemoDisplay(self, self.app)
|
||||
#self.main_display = nomadnet.ui.textui.Extras.DemoDisplay(self, self.app)
|
||||
self.main_display = nomadnet.ui.textui.Main.MainDisplay(self, self.app)
|
||||
|
||||
if intro_timeout > 0:
|
||||
self.intro_display = IntroDisplay(self.app)
|
||||
self.intro_display = nomadnet.ui.textui.Extras.IntroDisplay(self.app)
|
||||
initial_widget = self.intro_display.widget
|
||||
else:
|
||||
initial_widget = self.main_display.widget
|
||||
@ -52,64 +54,3 @@ class TextUI:
|
||||
|
||||
def display_main(self, loop, user_data):
|
||||
self.loop.widget = self.main_display.widget
|
||||
|
||||
|
||||
class DemoDisplay():
|
||||
def __init__(self, ui, app):
|
||||
import urwid
|
||||
|
||||
def color_mono(btn):
|
||||
ui.set_colormode(nomadnet.ui.COLORMODE_MONO)
|
||||
|
||||
def color_16(btn):
|
||||
ui.set_colormode(nomadnet.ui.COLORMODE_16)
|
||||
|
||||
def color_88(btn):
|
||||
ui.set_colormode(nomadnet.ui.COLORMODE_88)
|
||||
|
||||
def color_8bit(btn):
|
||||
ui.set_colormode(nomadnet.ui.COLORMODE_256)
|
||||
|
||||
def color_true(btn):
|
||||
ui.set_colormode(nomadnet.ui.COLORMODE_TRUE)
|
||||
|
||||
pile = urwid.Pile([
|
||||
urwid.Text(("heading", "This is a heading")),
|
||||
urwid.Text(("body_text", "Hello World \U0001F332")),
|
||||
urwid.Button(("buttons", "Monochrome"), color_mono),
|
||||
urwid.Button(("buttons", "16 color"), color_16),
|
||||
urwid.Button(("buttons", "88 color"), color_88),
|
||||
urwid.Button(("buttons", "256 color"), color_8bit),
|
||||
urwid.Button(("buttons", "True color"), color_true),
|
||||
])
|
||||
|
||||
self.widget = urwid.Filler(pile, 'top')
|
||||
|
||||
class MainDisplay():
|
||||
def __init__(self, app):
|
||||
import urwid
|
||||
|
||||
pile = urwid.Pile([
|
||||
urwid.Text(("body_text", "Hello World \U0001F332")),
|
||||
])
|
||||
|
||||
self.widget = urwid.Filler(pile, 'top')
|
||||
|
||||
class IntroDisplay():
|
||||
def __init__(self, app):
|
||||
import urwid
|
||||
self.app = app
|
||||
|
||||
font = urwid.font.HalfBlock5x4Font()
|
||||
|
||||
big_text = urwid.BigText(("intro_title", "Nomad Network"), font)
|
||||
big_text = urwid.Padding(big_text, align="center", width="clip")
|
||||
|
||||
intro = urwid.Pile([
|
||||
big_text,
|
||||
urwid.Text(("Version %s" % (str(self.app.version))), align="center"),
|
||||
urwid.Divider(),
|
||||
urwid.Text(("-= Starting =- "), align="center"),
|
||||
])
|
||||
|
||||
self.widget = urwid.Filler(intro)
|
@ -31,6 +31,8 @@ THEMES = {
|
||||
THEME_DARK: [
|
||||
# Style name # 16-color style # Monochrome style # 88, 256 and true-color style
|
||||
('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'),
|
||||
('buttons', 'light green,bold', 'default', 'default', '#00a533', 'default')
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user