Beispiel #1
0
    def createStepperProgram(self):
        top = panel.top_panel()
        menu = top.userptr()
        menu.window.clear()
        menu.window.refresh()
        curses.reset_shell_mode()

        prog = []
        build = 1
        speed = 0
        revolutions = 0
        while build:
            while True:
                try:
                    speed = int(raw_input('Enter Speed (-160 - 160 RPM: '))
                    if speed >= -160 and speed <= 160:
                        break
                    else:
                        print "Speed out of range. Try again..."
                except Exception as e:
                    print "Invalid input for speed. Try again..."
                    continue

            while True:
                try:
                    revolutions = abs(float(raw_input('Enter Revolutions: ')))
                    break
                except Exception as e:
                    print "Invalid input for revolutions. Try again..."
                    continue

            while True:
                cont = raw_input(
                    'Would you like to additional steps to your program? (Yes/No)'
                ).lower()
                if cont == "yes" or cont == "y":
                    break
                elif cont == "no" or cont == "n":
                    build = 0
                    break
                else:
                    print "Invalid input... Try again."

            prog.append([speed, revolutions])

        fileName = raw_input('Please enter the name of the program:')

        with open("programs/" + fileName + ".pgm", 'wb') as f:
            pickle.dump(prog, f)

        print "Created file " + fileName
        print tabulate(prog, headers=["speed", "revolutions"])

        raw_input('Hit enter to continue:')

        curses.reset_prog_mode()
        menu.window.clear()
        menu.window.refresh()
        curses.doupdate()
Beispiel #2
0
    def deleteStepperProgram(self):
        progName = self.getSelectedItem()
        program = []

        os.remove("programs/" + progName)
        top = panel.top_panel()
        menu = top.userptr()
        menu.items = programMenuItems("delete")
Beispiel #3
0
 def addUser(self):
     top = panel.top_panel()
     menu = top.userptr()
     menu.window.clear()
     menu.window.refresh()
     curses.reset_shell_mode()
     userdb.cliAddUser()
     self.updateAdminMenu()
     curses.reset_prog_mode()
     menu.window.clear()
     menu.window.refresh()
Beispiel #4
0
 def changePassword(self):
     top = panel.top_panel()
     menu = top.userptr()
     menu.window.clear()
     menu.window.refresh()
     curses.reset_shell_mode()
     userdb.cliChangePassword(self.curUserName, 1)
     userdb.resetPassword(self.curUserName)
     curses.reset_prog_mode()
     menu.window.clear()
     menu.window.refresh()
     self.print_msg(self.curUserName + " Password Changed", 10, 10)
Beispiel #5
0
 def addEmail(self):
     top = panel.top_panel()
     menu = top.userptr()
     menu.window.clear()
     menu.window.refresh()
     curses.reset_shell_mode()
     email = raw_input("Email address:")
     userdb.editEmail(self.curUserName, email)
     curses.reset_prog_mode()
     menu.window.clear()
     menu.window.refresh()
     self.print_msg(email + " added", 10, 10)
Beispiel #6
0
  def f(stdscr):
    panels = []
    windows = []
    for i in xrange(10):
      c = lambda: ['the quick brown fox jumped over the lazy dog', str(i)]
      w = Window(callback=c, win=curses.newwin(30, 30, 0,0))
      w.update()
      p = new_panel(w.win)
      p.set_userptr(w)
      panels.append(p)

    for i in xrange(15):
      p = top_panel()
      p.show()
      update_panels()

      stdscr.getch()
      p.bottom()
      p.userptr().win.resize(10,10)
      p.userptr().update()
Beispiel #7
0
    def run(self):
        """Main game loop
        """
        while True:
            ch = self.stdscr.getch()
            if ch == ord('q'):
                break
            elif ch == curses.KEY_UP:
                self._move_cur(0)
            elif ch == curses.KEY_DOWN:
                self._move_cur(1)
            elif ch == curses.KEY_LEFT:
                self._move_cur(2)
            elif ch == curses.KEY_RIGHT:
                self._move_cur(3)
            elif ch == ord('1'):
                if not self.pdia.hidden():
                    self.pdia.hide()
                    #raise Exception(cpanel.top_panel(), cpanel.bottom_panel())
                else:
                    self.pdia.show()
                # self.p2.move(11, self.dia2.getbegyx()[1] - 1)
                self._draw_map()
            elif ch == ord('`'):
                del self.p2
                del self.pdia
                self._draw_map()
                raise Exception(cpanel.top_panel())

            elif ch == ord('2'):
                self.map.addstr(self.cur[0], self.cur[1], '~~', curses.color_pair(1))
                self._clear_cur()
            elif ch == ord('3'):
                self.map.addstr(self.cur[0], self.cur[1], '..', curses.color_pair(2))
                self._clear_cur()
            elif ch == ord('4'):
                self.map.addstr(self.cur[0], self.cur[1], '^^', curses.color_pair(3))
                self._clear_cur()
            elif ch == ord('5'):
                self.map.addstr(self.cur[0], self.cur[1], '  ', curses.color_pair(0))
                self._clear_cur()
Beispiel #8
0
 def deleteUser(self):
     userdb.deleteUser(self.curUserName)
     self.updateAdminMenu()
     pan = panel.top_panel()
     menu = pan.userptr()
     menu.exit()
Beispiel #9
0
 def getSelectedItem(self):
     top = panel.top_panel()
     menu = top.userptr()
     menu.window.clear()
     return menu.items[menu.position][0]
Beispiel #10
0
 def print_msg(self, message, y, x):
     top = panel.top_panel()
     top.window().clear()
     top.window().addstr(y, x, message, curses.A_NORMAL)
     time.sleep(1)
Beispiel #11
0
 def print_selection(self):
     top = panel.top_panel()
     top.window().clear()
     top.window().addstr(10, 30, self.getSelectedItem(), curses.A_NORMAL)