working
This commit is contained in:
71
main.py
71
main.py
@@ -2,21 +2,16 @@
|
|||||||
|
|
||||||
import curses
|
import curses
|
||||||
from curses import panel
|
from curses import panel
|
||||||
from curses import wrapper
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Menu(object):
|
class Menu(object):
|
||||||
def __init__(self, items, stdscreen):
|
def __init__(self, items, stdscreen):
|
||||||
# self.window = stdscreen.subwin(0, 0)
|
|
||||||
self.window = stdscreen
|
self.window = stdscreen
|
||||||
self.window.keypad(1)
|
self.window.keypad(1)
|
||||||
self.panel = panel.new_panel(self.window)
|
self.panel = panel.new_panel(self.window)
|
||||||
self.panel.hide()
|
self.panel.hide()
|
||||||
panel.update_panels()
|
panel.update_panels()
|
||||||
|
|
||||||
self.position = 0
|
self.position = 0
|
||||||
self.items = items
|
self.items = items
|
||||||
self.items.append(("exit", "exit"))
|
self.items.append(("exit", "exit"))
|
||||||
@@ -70,59 +65,81 @@ class Menu(object):
|
|||||||
|
|
||||||
class MyApp(object):
|
class MyApp(object):
|
||||||
|
|
||||||
def printS(self):
|
|
||||||
print("Yep, works")
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, screen):
|
def __init__(self, screen):
|
||||||
curses.curs_set(0)
|
curses.curs_set(0)
|
||||||
|
curses.start_color()
|
||||||
curses.init_color(0,0,0,0)
|
curses.init_color(0,0,0,0)
|
||||||
screen.box()
|
screen.box()
|
||||||
|
|
||||||
Cols22 = (curses.COLS - 2) * 0.22 # Take 2 characters out from the boarders and then calculate 22%
|
cols22 = (curses.COLS - 2) * 0.22 # Take 2 characters out from the boarders and then calculate 22%
|
||||||
Cols22 = int(Cols22) # Ditch the fractional part
|
cols22 = int(cols22) # Ditch the fractional part
|
||||||
|
|
||||||
Cols56 = (curses.COLS - 2) * 0.56 # Take 2 characters out from the boarders and then calculate 56%
|
cols56 = (curses.COLS - 2) * 0.56 # Take 2 characters out from the boarders and then calculate 56%
|
||||||
Cols56 = int(Cols56) + 1 # Ditch the fractional part and add 1
|
cols56 = int(cols56) + 1 # Ditch the fractional part and add 1
|
||||||
|
|
||||||
Lines = (curses.LINES - 2) * 0.95 # Take 2 characters out from the boarders and then calculate 56%
|
lines = (curses.LINES - 2) * 0.95 # Take 2 characters out from the boarders and then calculate 56%
|
||||||
Lines = int(Lines) # Ditch the fractional part
|
lines = int(lines) # Ditch the fractional part
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# title = "Sparks-Skraps" + " COLS -> " + str(curses.COLS) + " LINES -> " + str(Cols56)
|
# title = "Sparks-Skraps" + " COLS -> " + str(curses.COLS) + " lines -> " + str(cols56)
|
||||||
title = "Sparks-Skraps"
|
title = "Sparks-Skraps"
|
||||||
titlePos = (curses.COLS / 2) - (len(title) / 2)
|
titlePos = (curses.COLS / 2) - (len(title) / 2)
|
||||||
|
|
||||||
screen.addstr(1, int(titlePos), title, 2)
|
screen.addstr(1, int(titlePos), title, curses.A_BOLD)
|
||||||
screen.refresh()
|
screen.refresh()
|
||||||
|
|
||||||
|
|
||||||
components = curses.newwin(Lines,Cols22,3,1)
|
components = curses.newwin(lines,cols22,3,1)
|
||||||
# components.box()
|
components.box()
|
||||||
# components.addstr(1, 1, "precious components")
|
components.addstr(1, 1, "precious components")
|
||||||
components.refresh()
|
components.refresh()
|
||||||
|
|
||||||
parts = curses.newwin(Lines, Cols22, 3, 1+Cols22)
|
parts = curses.newwin(lines, cols22, 3, 1+cols22)
|
||||||
parts.box()
|
parts.box()
|
||||||
parts.addstr(1, 1, "My precious parts")
|
parts.addstr(1, 1, "My precious parts")
|
||||||
parts.refresh()
|
parts.refresh()
|
||||||
|
|
||||||
info = curses.newwin(Lines, Cols56, 3, 1+Cols22*2)
|
info = curses.newwin(lines, cols56, 3, 1+cols22*2)
|
||||||
info.box()
|
info.box()
|
||||||
info.addstr(1, 1, "My precious info")
|
info.addstr(1, 1, "My precious info")
|
||||||
info.refresh()
|
info.refresh()
|
||||||
|
|
||||||
|
|
||||||
# c = screen.getch()
|
# resistors_items = [("10R", curses.beep), ("10K", curses.beep), ("330R", curses.flash), ("57K", curses.flash)]
|
||||||
|
# resistorsMenu = Menu(resistors_items, parts)
|
||||||
submenu_items = [("Resistors", curses.beep), ("Capacitors", curses.beep), ("Coils", curses.flash), ("IC\'s", curses.flash)]
|
|
||||||
submenu = Menu(submenu_items, components)
|
|
||||||
submenu.display()
|
|
||||||
|
|
||||||
|
components_items = [("Resistors", (r = 1)), ("Capacitors", curses.beep), ("Coils", curses.flash), ("IC\'s", curses.flash)]
|
||||||
|
componentsMenu = Menu(components_items, components)
|
||||||
|
componentsMenu.display()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
curses.wrapper(MyApp)
|
curses.wrapper(MyApp)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
components = curses.newwin(lines,cols22,3,1)
|
||||||
|
# components.box()
|
||||||
|
# components.addstr(1, 1, "precious components")
|
||||||
|
components.refresh()
|
||||||
|
|
||||||
|
parts = curses.newwin(lines, cols22, 3, 1+cols22)
|
||||||
|
parts.box()
|
||||||
|
parts.addstr(1, 1, "My precious parts")
|
||||||
|
parts.refresh()
|
||||||
|
|
||||||
|
info = curses.newwin(lines, cols56, 3, 1+cols22*2)
|
||||||
|
info.box()
|
||||||
|
info.addstr(1, 1, "My precious info")
|
||||||
|
info.refresh()
|
||||||
|
'''
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user