From 899cc41fbcd39e2cb2447f6372c4f93743a267d8 Mon Sep 17 00:00:00 2001 From: Ricardo Date: Thu, 2 Jun 2022 22:09:48 +0000 Subject: [PATCH] working --- main.py | 71 +++++++++++++++++++++++++++++++++++---------------------- notes | 8 +++++++ 2 files changed, 52 insertions(+), 27 deletions(-) create mode 100644 notes diff --git a/main.py b/main.py index 992c2ae..11f780f 100755 --- a/main.py +++ b/main.py @@ -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() +''' + diff --git a/notes b/notes new file mode 100644 index 0000000..70dbadc --- /dev/null +++ b/notes @@ -0,0 +1,8 @@ + + + + + + + +https://profs.info.uaic.ro/~busaco/teach/courses/net/docs/NCURSES.html