mirror of
https://github.com/markqvist/NomadNet.git
synced 2024-12-18 03:54:41 -05:00
Text UI general structure
This commit is contained in:
parent
c039ff2e2a
commit
9693e3e814
21
nomadnet/ui/textui/Conversations.py
Normal file
21
nomadnet/ui/textui/Conversations.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
class ConversationsDisplayShortcuts():
|
||||||
|
def __init__(self, app):
|
||||||
|
import urwid
|
||||||
|
self.app = app
|
||||||
|
|
||||||
|
self.widget = urwid.AttrMap(urwid.Text("Conversations Display Shortcuts"), "shortcutbar")
|
||||||
|
|
||||||
|
class ConversationsDisplay():
|
||||||
|
def __init__(self, app):
|
||||||
|
import urwid
|
||||||
|
self.app = app
|
||||||
|
|
||||||
|
pile = urwid.Pile([
|
||||||
|
urwid.Text(("body_text", "Conversations Display \U0001F332")),
|
||||||
|
])
|
||||||
|
|
||||||
|
self.shortcuts_display = ConversationsDisplayShortcuts(self.app)
|
||||||
|
self.widget = urwid.Filler(pile, 'top')
|
||||||
|
|
||||||
|
def shortcuts(self):
|
||||||
|
return self.shortcuts_display
|
21
nomadnet/ui/textui/Directory.py
Normal file
21
nomadnet/ui/textui/Directory.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
class DirectoryDisplayShortcuts():
|
||||||
|
def __init__(self, app):
|
||||||
|
import urwid
|
||||||
|
self.app = app
|
||||||
|
|
||||||
|
self.widget = urwid.AttrMap(urwid.Text("Directory Display Shortcuts"), "shortcutbar")
|
||||||
|
|
||||||
|
class DirectoryDisplay():
|
||||||
|
def __init__(self, app):
|
||||||
|
import urwid
|
||||||
|
self.app = app
|
||||||
|
|
||||||
|
pile = urwid.Pile([
|
||||||
|
urwid.Text(("body_text", "Directory Display \U0001F332")),
|
||||||
|
])
|
||||||
|
|
||||||
|
self.shortcuts_display = DirectoryDisplayShortcuts(self.app)
|
||||||
|
self.widget = urwid.Filler(pile, 'top')
|
||||||
|
|
||||||
|
def shortcuts(self):
|
||||||
|
return self.shortcuts_display
|
63
nomadnet/ui/textui/Extras.py
Normal file
63
nomadnet/ui/textui/Extras.py
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
from nomadnet.ui import *
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
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),
|
||||||
|
# ])
|
||||||
|
|
||||||
|
gf = urwid.GridFlow([
|
||||||
|
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),
|
||||||
|
], cell_width=20, h_sep=0, v_sep=0, align="left")
|
||||||
|
|
||||||
|
self.widget = urwid.Filler(urwid.Padding((urwid.Text("Test"),urwid.Text("Test 2"))), 'top')
|
||||||
|
#self.widget = urwid.Filler(pile, 'top')
|
75
nomadnet/ui/textui/Main.py
Normal file
75
nomadnet/ui/textui/Main.py
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
import RNS
|
||||||
|
|
||||||
|
from .Network import *
|
||||||
|
from .Conversations import *
|
||||||
|
from .Directory import *
|
||||||
|
from .Map import *
|
||||||
|
|
||||||
|
class SubDisplays():
|
||||||
|
def __init__(self, app):
|
||||||
|
import urwid
|
||||||
|
self.app = app
|
||||||
|
self.network_display = NetworkDisplay(self.app)
|
||||||
|
self.conversations_display = ConversationsDisplay(self.app)
|
||||||
|
self.directory_display = DirectoryDisplay(self.app)
|
||||||
|
self.map_display = MapDisplay(self.app)
|
||||||
|
|
||||||
|
self.active_display = self.network_display
|
||||||
|
|
||||||
|
def active(self):
|
||||||
|
return self.active_display
|
||||||
|
|
||||||
|
|
||||||
|
class MainDisplay():
|
||||||
|
def __init__(self, ui, app):
|
||||||
|
import urwid
|
||||||
|
self.ui = ui
|
||||||
|
self.app = app
|
||||||
|
|
||||||
|
self.menu_display = MenuDisplay(self.app, self)
|
||||||
|
self.sub_displays = SubDisplays(self.app)
|
||||||
|
|
||||||
|
self.frame = urwid.Frame(self.sub_displays.active().widget, header=self.menu_display.widget, footer=self.sub_displays.active().shortcuts().widget)
|
||||||
|
self.widget = self.frame
|
||||||
|
|
||||||
|
def show_network(self, user_data):
|
||||||
|
self.sub_displays.active_display = self.sub_displays.network_display
|
||||||
|
self.update_active_sub_display()
|
||||||
|
|
||||||
|
def show_conversations(self, user_data):
|
||||||
|
self.sub_displays.active_display = self.sub_displays.conversations_display
|
||||||
|
self.update_active_sub_display()
|
||||||
|
|
||||||
|
def show_directory(self, user_data):
|
||||||
|
self.sub_displays.active_display = self.sub_displays.directory_display
|
||||||
|
self.update_active_sub_display()
|
||||||
|
|
||||||
|
def show_map(self, user_data):
|
||||||
|
self.sub_displays.active_display = self.sub_displays.map_display
|
||||||
|
self.update_active_sub_display()
|
||||||
|
|
||||||
|
def update_active_sub_display(self):
|
||||||
|
self.frame.contents["body"] = (self.sub_displays.active().widget, None)
|
||||||
|
self.frame.contents["footer"] = (self.sub_displays.active().shortcuts().widget, None)
|
||||||
|
|
||||||
|
|
||||||
|
class MenuDisplay():
|
||||||
|
def __init__(self, app, handler):
|
||||||
|
import urwid
|
||||||
|
|
||||||
|
class MenuButton(urwid.Button):
|
||||||
|
button_left = urwid.Text('[')
|
||||||
|
button_right = urwid.Text(']')
|
||||||
|
|
||||||
|
self.app = app
|
||||||
|
|
||||||
|
menu_text = ("pack", urwid.Text(" \U00002638"))
|
||||||
|
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))
|
||||||
|
|
||||||
|
buttons = [menu_text, button_network, button_conversations, button_directory, button_map]
|
||||||
|
columns = urwid.Columns(buttons, dividechars=1)
|
||||||
|
|
||||||
|
self.widget = urwid.AttrMap(columns, "menubar")
|
21
nomadnet/ui/textui/Map.py
Normal file
21
nomadnet/ui/textui/Map.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
class MapDisplayShortcuts():
|
||||||
|
def __init__(self, app):
|
||||||
|
import urwid
|
||||||
|
self.app = app
|
||||||
|
|
||||||
|
self.widget = urwid.AttrMap(urwid.Text("Map Display Shortcuts"), "shortcutbar")
|
||||||
|
|
||||||
|
class MapDisplay():
|
||||||
|
def __init__(self, app):
|
||||||
|
import urwid
|
||||||
|
self.app = app
|
||||||
|
|
||||||
|
pile = urwid.Pile([
|
||||||
|
urwid.Text(("body_text", "Map Display \U0001F332")),
|
||||||
|
])
|
||||||
|
|
||||||
|
self.shortcuts_display = MapDisplayShortcuts(self.app)
|
||||||
|
self.widget = urwid.Filler(pile, 'top')
|
||||||
|
|
||||||
|
def shortcuts(self):
|
||||||
|
return self.shortcuts_display
|
21
nomadnet/ui/textui/Network.py
Normal file
21
nomadnet/ui/textui/Network.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
class NetworkDisplayShortcuts():
|
||||||
|
def __init__(self, app):
|
||||||
|
import urwid
|
||||||
|
self.app = app
|
||||||
|
|
||||||
|
self.widget = urwid.AttrMap(urwid.Text("Network Display Shortcuts"), "shortcutbar")
|
||||||
|
|
||||||
|
class NetworkDisplay():
|
||||||
|
def __init__(self, app):
|
||||||
|
import urwid
|
||||||
|
self.app = app
|
||||||
|
|
||||||
|
pile = urwid.Pile([
|
||||||
|
urwid.Text(("body_text", "Network Display \U0001F332")),
|
||||||
|
])
|
||||||
|
|
||||||
|
self.shortcuts_display = NetworkDisplayShortcuts(self.app)
|
||||||
|
self.widget = urwid.Filler(pile, 'top')
|
||||||
|
|
||||||
|
def shortcuts(self):
|
||||||
|
return self.shortcuts_display
|
5
nomadnet/ui/textui/__init__.py
Normal file
5
nomadnet/ui/textui/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import os
|
||||||
|
import glob
|
||||||
|
|
||||||
|
modules = glob.glob(os.path.dirname(__file__)+"/*.py")
|
||||||
|
__all__ = [ os.path.basename(f)[:-3] for f in modules if not f.endswith('__init__.py')]
|
Loading…
Reference in New Issue
Block a user