This commit is contained in:
Ricardo
2022-06-02 22:09:48 +00:00
parent 8915134779
commit 899cc41fbc
2 changed files with 52 additions and 27 deletions

71
main.py
View File

@@ -2,21 +2,16 @@
import curses
from curses import panel
from curses import wrapper
class Menu(object):
def __init__(self, items, stdscreen):
# self.window = stdscreen.subwin(0, 0)
self.window = stdscreen
self.window.keypad(1)
self.panel = panel.new_panel(self.window)
self.panel.hide()
panel.update_panels()
self.position = 0
self.items = items
self.items.append(("exit", "exit"))
@@ -70,59 +65,81 @@ class Menu(object):
class MyApp(object):
def printS(self):
print("Yep, works")
def __init__(self, screen):
curses.curs_set(0)
curses.start_color()
curses.init_color(0,0,0,0)
screen.box()
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 = (curses.COLS - 2) * 0.22 # Take 2 characters out from the boarders and then calculate 22%
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 = int(Cols56) + 1 # Ditch the fractional part and add 1
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
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 = (curses.LINES - 2) * 0.95 # Take 2 characters out from the boarders and then calculate 56%
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"
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()
components = curses.newwin(Lines,Cols22,3,1)
# components.box()
# components.addstr(1, 1, "precious components")
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 = 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 = curses.newwin(lines, cols56, 3, 1+cols22*2)
info.box()
info.addstr(1, 1, "My precious info")
info.refresh()
# c = screen.getch()
submenu_items = [("Resistors", curses.beep), ("Capacitors", curses.beep), ("Coils", curses.flash), ("IC\'s", curses.flash)]
submenu = Menu(submenu_items, components)
submenu.display()
# resistors_items = [("10R", curses.beep), ("10K", curses.beep), ("330R", curses.flash), ("57K", curses.flash)]
# resistorsMenu = Menu(resistors_items, parts)
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__":
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()
'''

8
notes Normal file
View File

@@ -0,0 +1,8 @@
https://profs.info.uaic.ro/~busaco/teach/courses/net/docs/NCURSES.html