Пример #1
0
 def __init__(self):
     self.Headless = NvcliHeadless()
     
     self.screen = curses.initscr()
     curses.noecho()
     curses.cbreak()
     self.screen.keypad(1)
     curses.start_color()
     curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
     curses.init_pair(2, curses.COLOR_RED, curses.COLOR_BLACK)
     curses.init_pair(3, curses.COLOR_GREEN, curses.COLOR_BLACK)
     curses.init_pair(4, curses.COLOR_YELLOW, curses.COLOR_BLACK)
     curses.init_pair(5, curses.COLOR_BLUE, curses.COLOR_BLACK)
     
     #self.screen.nodelay(1)
     self.screen.clear()
     self.screen.move(0, 0)
     self.screen.addstr("NVCLI input-grabber for terminal\n", curses.color_pair(1) | curses.A_BOLD)
     self.screen.move(1, 0)
     self.screen.addstr("The output is spoken, not shown here!\n", curses.color_pair(1) | curses.A_BOLD)
     
     self.mainLoop()
Пример #2
0
 def __init__(self):
     QtWidgets.QMainWindow.__init__(self)
     self.setWindowTitle("nvcli")
     
     self.NVCLI = NvcliHeadless()
Пример #3
0
class KeyGrabber(object):
    def __init__(self):
        self.Headless = NvcliHeadless()
        
        self.screen = curses.initscr()
        curses.noecho()
        curses.cbreak()
        self.screen.keypad(1)
        curses.start_color()
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
        curses.init_pair(2, curses.COLOR_RED, curses.COLOR_BLACK)
        curses.init_pair(3, curses.COLOR_GREEN, curses.COLOR_BLACK)
        curses.init_pair(4, curses.COLOR_YELLOW, curses.COLOR_BLACK)
        curses.init_pair(5, curses.COLOR_BLUE, curses.COLOR_BLACK)
        
        #self.screen.nodelay(1)
        self.screen.clear()
        self.screen.move(0, 0)
        self.screen.addstr("NVCLI input-grabber for terminal\n", curses.color_pair(1) | curses.A_BOLD)
        self.screen.move(1, 0)
        self.screen.addstr("The output is spoken, not shown here!\n", curses.color_pair(1) | curses.A_BOLD)
        
        self.mainLoop()
        #self.mainLoopTesting()
        
    def getDict(self):
	return {
		"^[": "key_esc",
		"KEY_F(1)": "key_f1",
		"KEY_F(2)": "key_f2",
		"KEY_F(3)": "key_f3",
		"KEY_F(12)": "key_f12",
		
		"KEY_UP": "key_up",
		"KEY_DOWN": "key_down",
		"KEY_LEFT": "key_left",
		"KEY_RIGHT": "key_right",
		"kLFT5": "key_ctrl_left",
		"kRIT5": "key_ctrl_right",
		
		"KEY_HOME": "key_pos1",
		"KEY_END": "key_end",
		"KEY_PPAGE": "key_ppage",
		"KEY_NPAGE": "key_npage",
		"^I": "key_tab",
		"KEY_BTAB": "key_backtab",
		
		"^J": "key_enter",
		"KEY_DC": "key_del",
		"KEY_IC": "key_insert",
		"^?": "key_backspace",
		
		"M-$": "ä",
		"M-^D": "Ä",
		"M-6": "ö",
		"M-^V": "Ö",
		"M-<": "ü",
		"M-^\\": "Ü",
		"M-^_": "ß",
		}
	
    def mainLoopTesting(self):
	event_dict = self.getDict()
	while True:
	    c = self.screen.getch()
	    keyname = curses.keyname(c)
	    print(c)
	    print(keyname)
	    key = event_dict[ keyname ]
	    
	
    def mainLoop(self):
	event_dict = self.getDict()
	while True:
	    c = self.screen.getch()
	    keyname = curses.keyname(c)
	    try:
		key = event_dict[ keyname ]
	    except KeyError:
	    	self.Headless.handleChars(keyname)
	    else:
		self.Headless.handleKeyInputEvent(key)
Пример #4
0
class KeyGrabber(QtWidgets.QMainWindow):
    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        self.setWindowTitle("nvcli")
        
        self.NVCLI = NvcliHeadless()
        
    def keyPressEvent(self, e):
        if (e.modifiers() & QtCore.Qt.ControlModifier):
            pass
        
        elif (e.modifiers() & QtCore.Qt.ShiftModifier):
            pass
        
        elif (e.modifiers() & QtCore.Qt.AltModifier):
            pass
        
        elif e.key() == QtCore.Qt.Key_Escape:
            self.NVCLI.handleKeyInputEvent("key_escape")
        elif e.key() == QtCore.Qt.Key_Return:
            self.NVCLI.handleKeyInputEvent("key_enter")
        elif e.key() == QtCore.Qt.Key_Tab:
            self.NVCLI.handleKeyInputEvent("key_tab")
        elif e.key() == QtCore.Qt.Key_Backtab:
            self.NVCLI.handleKeyInputEvent("key_backtab")
        elif e.key() == QtCore.Qt.Key_F12:
            self.NVCLI.handleKeyInputEvent("key_f12")
        
        elif e.key() == QtCore.Qt.Key_Up:
            self.NVCLI.handleKeyInputEvent("key_up")
        elif e.key() == QtCore.Qt.Key_Down:
            self.NVCLI.handleKeyInputEvent("key_down")
        elif e.key() == QtCore.Qt.Key_Left:
            self.NVCLI.handleKeyInputEvent("key_left")
        elif e.key() == QtCore.Qt.Key_Right:
            self.NVCLI.handleKeyInputEvent("key_right")