From: <te...@us...> - 2003-08-06 01:36:08
|
Update of /cvsroot/quickrip/quickrip/cli In directory sc8-pr-cvs1:/tmp/cvs-serv11184/cli Added Files: cli.py ncurses.py Log Message: Removed old CLI, added new one 'cli/cli.py' - not at all working yet! Adjusted quickrip.py accordingly --- NEW FILE: cli.py --- #!/usr/bin/env python """ cli.py - QuickRip's command line interface copyright: (C) 2003, Tom Chance license: GNU General Public License (GPL) (see LICENSE file) web: http://quickrip.sf.net email: tom...@gm... """ try: import sys, os, re, output, curses, curses.wrapper import ncurses from base import * except ImportError, desc: print "Unable to load module (", desc, ")" raise SystemExit # QuickRip global configuration. import config __app__ = config.app __author__ = config.author __version__ = config.version __date__ = config.date __copyright__ = config.copyright __license__ = config.license class Main(QuickRip): """Command Line Interface, using ncurses library""" def __init__(self): self.initialise() global SCREEN_WIDTH; global SCREEN_HEIGHT SCREEN_WIDTH = float(os.popen("tput cols").read()) SCREEN_HEIGHT = float(os.popen("tput lines").read()) self.mode = '' curses.wrapper(self.hook) def hook(self, stdscr, mode="front"): self.stdscr = stdscr self.draw_screen() while 1: if self.mode is '': self.mode = 'front' self.front() choice = self.stdscr.getch() if chr(choice) in 'qQ': sys.exit(2) self.switch(choice) def draw_screen(self): self.stdscr.clear() app_string = "".join([__app__, " v.", __version__, " ", __copyright__]) self.stdscr.addstr(0,0,app_string,curses.A_STANDOUT) self.stdscr.refresh() def switch(self, choice): if self.mode== 'front': self.mode = 'titlelist' self.titleList() else: curses.beep() def front(self): self.draw_screen() self.stdscr.addstr(2,0,"Hit ENTER to scan the DVD",curses.A_BOLD) self.stdscr.refresh() return 1 def titleList(self): self.draw_screen() self.scanDVD() self.draw_screen() self.list = ncurses.TitleList(self.stdscr, SCREEN_WIDTH, SCREEN_HEIGHT, self.numtitles) #i = 2 #for title in self.titles: # i = i + 1 # self.stdscr.addstr(i,0,"".join(["* Title ", str(title['id']), ", ", title['timelabel']])) # self.stdscr.refresh() #self.stdscr.move(self.pointer['y'], self.pointer['x']) def int_noTitles(self): self.draw_screen() self.stdscr.addstr(4, 0, "ERROR: No titles were found!", curses.A_STANDOUT) def int_dispDVD(self, numtitles): self.j = 4 self.stdscr.addstr(2, 0, "Scanning DVD...", curses.A_BOLD) self.stdscr.addstr(4, 0, "".join([numtitles, " titles found on this DVD"])) self.stdscr.refresh() def int_dispTitle(self, title): self.j = self.j + 1 text = "".join(["* Title ", str(title['id']), ", ", title['timelabel']]) self.stdscr.addstr(self.j, 0, text) self.stdscr.refresh() def main(): cli = Main() --- NEW FILE: ncurses.py --- #!/usr/bin/env python """ cli.py - QuickRip's command line interface copyright: (C) 2003, Tom Chance license: GNU General Public License (GPL) (see LICENSE file) web: http://quickrip.sf.net email: tom...@gm... """ try: import curses, curses.wrapper except ImportError, desc: print "Unable to load module (", desc, ")" raise SystemExit class TitleList: """Handle the list of DVD titles in a window""" def __init__(self, mainwindow, SCREEN_WIDTH, SCREEN_HEIGHT, numtitles): height = SCREEN_HEIGHT - 10 width = SCREEN_WIDTH - 4 self.win = curses.newwin(height, width, 2, 2) self.win.border() self.win.addstr(0,2,"".join([numtitles, " DVD titles available"]),curses.A_BOLD) self.win.refresh() |