mirror of
https://github.com/markqvist/NomadNet.git
synced 2026-12-01 20:36:28 -05:00
User interface skeleton
This commit is contained in:
parent
9fdcbf11b8
commit
fbc151060e
8 changed files with 136 additions and 15 deletions
8
nomadnet/ui/GraphicalUI.py
Normal file
8
nomadnet/ui/GraphicalUI.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import RNS
|
||||
import nomadnet
|
||||
|
||||
class GraphicalUI:
|
||||
|
||||
def __init__(self):
|
||||
RNS.log("Graphical UI not implemented", RNS.LOG_ERROR)
|
||||
nomadnet.panic()
|
||||
8
nomadnet/ui/MenuUI.py
Normal file
8
nomadnet/ui/MenuUI.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import RNS
|
||||
import nomadnet
|
||||
|
||||
class MenuUI:
|
||||
|
||||
def __init__(self):
|
||||
RNS.log("Menu UI not implemented", RNS.LOG_ERROR)
|
||||
nomadnet.panic()
|
||||
39
nomadnet/ui/TextUI.py
Normal file
39
nomadnet/ui/TextUI.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import RNS
|
||||
from nomadnet import NomadNetworkApp
|
||||
import importlib
|
||||
|
||||
class TextUI:
|
||||
|
||||
def __init__(self):
|
||||
self.app = NomadNetworkApp.get_shared_instance()
|
||||
|
||||
self.loop = None
|
||||
self.main_widget = None
|
||||
|
||||
if importlib.util.find_spec("urwid") != None:
|
||||
import urwid
|
||||
else:
|
||||
RNS.log("The text-mode user interface requires Urwid to be installed on your system.", RNS.LOG_ERROR)
|
||||
RNS.log("You can install it with the command: pip3 install urwid", RNS.LOG_ERROR)
|
||||
nomadnet.panic()
|
||||
|
||||
loop = urwid.MainLoop(self.build_intro())
|
||||
loop.run()
|
||||
|
||||
def build_intro(self):
|
||||
import urwid
|
||||
|
||||
font = urwid.font.HalfBlock5x4Font()
|
||||
|
||||
big_text = "Nomad Network"
|
||||
big_text = urwid.BigText(("intro_bigtext", big_text), 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(("intro_smalltext", "-= Starting =-"), align="center"),
|
||||
])
|
||||
|
||||
return urwid.Filler(intro)
|
||||
8
nomadnet/ui/WebUI.py
Normal file
8
nomadnet/ui/WebUI.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import RNS
|
||||
import nomadnet
|
||||
|
||||
class WebUI:
|
||||
|
||||
def __init__(self):
|
||||
RNS.log("Web UI not implemented", RNS.LOG_ERROR)
|
||||
nomadnet.panic()
|
||||
|
|
@ -1,5 +1,37 @@
|
|||
import os
|
||||
import glob
|
||||
import RNS
|
||||
import nomadnet
|
||||
|
||||
from .MenuUI import MenuUI
|
||||
from .TextUI import TextUI
|
||||
from .GraphicalUI import GraphicalUI
|
||||
from .WebUI import WebUI
|
||||
|
||||
UI_NONE = 0x00
|
||||
UI_MENU = 0x01
|
||||
UI_TEXT = 0x02
|
||||
UI_GRAPHICAL = 0x03
|
||||
UI_WEB = 0x04
|
||||
|
||||
UI_MODES = [UI_MENU, UI_TEXT, UI_GRAPHICAL, UI_WEB]
|
||||
|
||||
modules = glob.glob(os.path.dirname(__file__)+"/*.py")
|
||||
__all__ = [ os.path.basename(f)[:-3] for f in modules if not f.endswith('__init__.py')]
|
||||
__all__ = [ os.path.basename(f)[:-3] for f in modules if not f.endswith('__init__.py')]
|
||||
|
||||
def spawn(uimode):
|
||||
if uimode in UI_MODES:
|
||||
RNS.log("Starting user interface...", RNS.LOG_INFO)
|
||||
if uimode == UI_MENU:
|
||||
return MenuUI()
|
||||
elif uimode == UI_TEXT:
|
||||
return TextUI()
|
||||
elif uimode == UI_GRAPHICAL:
|
||||
return GraphicalUI()
|
||||
elif uimode == UI_WEB:
|
||||
return WebUI()
|
||||
else:
|
||||
return None
|
||||
else:
|
||||
RNS.log("Invalid UI mode", RNS.LOG_ERROR)
|
||||
nomadnet.panic()
|
||||
Loading…
Add table
Add a link
Reference in a new issue