def initInteractive(setup):
    logging.info("Initializing Nexus migration tool.")
    os.environ.setdefault('ESCDELAY', '25')
    try:
        stdscr = unicurses.initscr()
        unicurses.noecho()
        unicurses.cbreak()
        try:
            unicurses.start_color()
        except:
            pass
        scr = Screen(stdscr, setup.args)
        saf = Safety(scr)
        win = Main(scr)
        scr.render()
        while True:
            win.show()
            if not scr.modified() or saf.show(): break
    except:
        logging.exception("Error running Nexus migration tool:")
        raise
    finally:
        logging.info("Terminating Nexus migration tool.")
        logging.shutdown()
        if 'stdscr' in locals():
            unicurses.echo()
            unicurses.nocbreak()
            unicurses.endwin()
예제 #2
0
    def __init__(self, player):
        self.player = player

        self.on_menu = True  # Shifts the focus between menu and board, = show new ship
        self.menu_hi = 0  # Which ele is hightlighted in the menu
        self.menu_sel = -1  # Current item selected, relevant when board is active
        self.num_ships_set = 0

        self.menu = self.player.left_to_set()

        self.new_ship_x = 0
        self.new_ship_y = 0
        self.new_ship_hor = True

        self.title = f'Set ships for player: {self.player.name}'

        self.max_y, self.max_x = uc.getmaxyx(stdscr)

        uc.noecho()  # Disable typing on the screen
        uc.cbreak()  # catching characters directly without waiting for [ENTER]
        uc.curs_set(0)  # Disable blinking curser
        uc.keypad(stdscr, True)  # for catching the arrow keys
        uc.start_color()

        self.init_wins()
예제 #3
0
def main():
    ## Curses normal init sequence
    stdscr = curses.initscr()
    curses.noecho()  # no echo, but we still see the cursor
    curses.curs_set(False)  #turns off the cursor drawing
    stdscr.keypad(True)  # allows special keys and arrow keys

    try:
        curses.start_color()

        window = curses.newwin(10, 25, 3, 3)
        window.addstr(1, 1, "Hey there!")

        window.box()

        while True:
            key = window.getch()
            if key == 27:
                break

    except Exception as e:
        stdscr.addstr(0, 0, str(e))
        stdscr.getch()
    finally:

        curses.endwin()

    return 0
예제 #4
0
    def _start(self):
        """
        Initialize the screen and input mode.
        """
        self.stdscr = curses.initscr()
        self.has_color = curses.has_colors()
        if self.has_color:
            curses.start_color()
            if curses_.COLORS < 8:
                # not colourful enough
                self.has_color = False
        if self.has_color:
            try:
                curses.use_default_colors()
                self.has_default_colors=True
            except _curses.error:
                self.has_default_colors=False
        self._setup_colour_pairs()
        curses.noecho()
        # curses.meta(None, 1)
        #todo
        curses.meta( None,1)
        curses.halfdelay(1) # use set_input_timeouts to adjust
        self.stdscr.keypad(True)

        if not self._signal_keys_set:
            self._old_signal_keys = self.tty_signal_keys()
            
        self.set_mouse_tracking(True)

        super(Screen, self)._start()
예제 #5
0
def main():
  ## Curses normal init sequence
  stdscr = curses.initscr()
  curses.noecho() # no echo, but we still see the cursor
  curses.curs_set(False) #turns off the cursor drawing
  stdscr.keypad(True) # allows special keys and arrow keys
  
  try:
    curses.start_color()

    window = curses.newwin(2, 25, 3, 5)
    window.addstr(0,0,"Hello, World!")

    # this window will now be displayed. Since we are doing getch
    # on window, that one is brought to front, window 2 isn't.
    # We can tackle this with panels. Or, explicitly call window2.refresh()
    window2 = curses.newwin(2, 25, 3, 50)
    window2.addstr(0,0,"Hello, World again!")
    
    while True:
      key = window.getch()
      if key == 27:
        break

  except Exception as e:
    stdscr.addstr(0,0,str(e))
    stdscr.getch()
  finally:
    
    curses.endwin()
  
  return 0
예제 #6
0
파일: terminal.py 프로젝트: Chiel92/tfate
def init():
    """Initialize curses and start application."""
    global stdscr
    stdscr = curses.initscr()

    # Display settings
    curses.cbreak()
    curses.noecho()

    # Key input settings
    curses.raw()
    curses.keypad(stdscr, 1)

    # No cursor
    curses.curs_set(0)

    global TERMNAME
    TERMNAME = curses.termname()
    info('Terminal name: ' + TERMNAME)

    global LONGNAME
    LONGNAME = curses.longname()
    info('Long terminal name: ' + LONGNAME)

    global TERMATTRS
    TERMATTRS = curses.termattrs()
    info('Terminal attributes: ' + str(TERMATTRS))

    init_colors()
def initInteractive(setup):
    logging.info("Initializing Nexus migration tool.")
    os.environ.setdefault('ESCDELAY', '25')
    try:
        stdscr = unicurses.initscr()
        unicurses.noecho()
        unicurses.cbreak()
        try: unicurses.start_color()
        except: pass
        scr = Screen(stdscr, setup.args)
        saf = Safety(scr)
        win = Main(scr)
        scr.render()
        while True:
            win.show()
            if not scr.modified() or saf.show(): break
    except:
        logging.exception("Error running Nexus migration tool:")
        raise
    finally:
        logging.info("Terminating Nexus migration tool.")
        logging.shutdown()
        if 'stdscr' in locals():
            unicurses.echo()
            unicurses.nocbreak()
            unicurses.endwin()
예제 #8
0
 def _dbg_instr(self): # messy input string (intended for debugging)
     curses.echo()
     self.stdscr.nodelay(0)
     curses.halfdelay(100)
     str = self.stdscr.getstr()
     curses.noecho()
     return str
예제 #9
0
def main():

    if not curses.has_colors():
        print("Your terminal emulator needs to have colors.")
        return 0

    ## Curses normal init sequence
    stdscr = curses.initscr()
    curses.noecho()  # no echo, but we still see the cursor
    curses.curs_set(False)  #turns off the cursor drawing
    stdscr.keypad(True)  # allows special keys and arrow keys

    try:
        curses.start_color()

        curses.update_panels()
        curses.doupdate()

        while True:
            key = curses.getch()
            if key == 27:
                break

            curses.update_panels()
            curses.doupdate()

    except Exception as e:
        stdscr.addstr(0, 0, str(e))
        stdscr.getch()
    finally:

        curses.endwin()

    return 0
예제 #10
0
def initializeCursesTerminal():
    """Initialize the curses terminal and return the window object."""

    stdscr = unicurses.initscr()
    
    unicurses.start_color()
    unicurses.noecho()
    unicurses.cbreak()
    unicurses.keypad(stdscr, True)
    unicurses.timeout(False)
    unicurses.curs_set(False)

    return stdscr
예제 #11
0
    def _init_curses(self):
        """Initialize the curses environment and windows."""
        for win in self.get_windows():
            # Make getch and getstr non-blocking.
            uc.nodelay(win, True)

            # Allow non-ascii keys.
            uc.keypad(win, True)

        # Don't echo text.
        uc.noecho()

        # Don't show the cursor.
        uc.curs_set(False)
        logger.debug("Curses display initialized")
예제 #12
0
def main():
    ## Curses normal init sequence
    stdscr = curses.initscr()
    curses.noecho()  # no echo, but we still see the cursor
    curses.curs_set(False)  #turns off the cursor drawing
    stdscr.keypad(True)  # allows special keys and arrow keys

    try:
        curses.start_color()

        window = curses.newwin(3, 20, 5, 5)
        window.addstr(1, 1, "Hey there!")
        window.box()

        window2 = curses.newwin(3, 20, 4, 4)
        window2.addstr(1, 1, "Hey there, again!")
        window2.box()

        panel = curses.new_panel(window)
        panel2 = curses.new_panel(window2)

        #curses.move_panel(panel, 10, 30)

        curses.update_panels()
        curses.doupdate()

        top_p = None

        while True:
            key = curses.getch()
            if key == 27:
                break

            top_p = panel if top_p is panel2 else panel2
            curses.top_panel(top_p)

            curses.update_panels()
            curses.doupdate()

    except Exception as e:
        stdscr.addstr(0, 0, str(e))
        stdscr.getch()
    finally:

        curses.endwin()

    return 0
예제 #13
0
파일: main.py 프로젝트: akiky/manageri
def newgame():
    global name
    curses.erase()
    curses.mvaddstr(1, 1, "UUSI PELI")
    curses.mvaddstr(3, 1, "Kirjoita nimesi:")
    curses.echo()
    curses.move(4, 1)
    name = curses.getstr().decode(encoding="utf-8")
    curses.noecho()

    curses.mvaddstr(12, 1, name)
    curses.mvaddstr(10, 1, "Onko tiedot oikein? (K/E)")
    while 1:
        key = curses.getch()
        if (check_key(key, "k") or key == 27):
            break
        elif (key == ord('e') or key == ord('E')):
            newgame()
예제 #14
0
def start():
    global screen
    screen = curses.initscr()
    curses.noecho()
    curses.cbreak()
    curses.curs_set(0)
    screen.keypad(1)
    screen.nodelay(1)
    curses.nonl()
    screen.scrollok(False)
    curses.start_color()

    for i in range(0, 17):
        curses.init_pair(i+1, i, 0)
        #log.log("Pair : ({}, {}, 0)".format(i+1,i))

    h, w = screen.getmaxyx()
    log.log("Screen size : {}x{}".format(h, w))
예제 #15
0
def main():
    ## Curses normal init sequence
    stdscr = curses.initscr()
    curses.noecho()  # no echo, but we still see the cursor
    curses.curs_set(False)  #turns off the cursor drawing
    stdscr.keypad(True)  # allows special keys and arrow keys

    try:
        curses.start_color()

        curses.init_pair(1, curses.COLOR_YELLOW, curses.COLOR_GREEN)
        curses.init_pair(2, curses.COLOR_RED, curses.COLOR_GREEN)

        dude = curses.newwin(1, 1, 10, 30)
        curses.waddstr(dude, "@", curses.color_pair(2) + curses.A_BOLD)
        dude_panel = curses.new_panel(dude)

        grass = curses.newwin(10, 50, 5, 5)
        grass.bkgd(" ", curses.color_pair(1))
        grass_panel = curses.new_panel(grass)

        curses.top_panel(dude_panel)

        curses.update_panels()
        curses.doupdate()

        while True:
            key = curses.getch()
            if key == 27:
                break

            curses.update_panels()
            curses.doupdate()

    except Exception as e:
        stdscr.addstr(0, 0, str(e))
        stdscr.getch()
    finally:

        curses.endwin()

    return 0
예제 #16
0
def main():

    if not curses.has_colors():
        print("Your terminal emulator needs to have colors.")
        return 0

    ## Curses normal init sequence
    stdscr = curses.initscr()
    curses.noecho()  # no echo, but we still see the cursor
    curses.curs_set(False)  #turns off the cursor drawing
    stdscr.keypad(True)  # allows special keys and arrow keys

    try:
        curses.start_color()

        avatar = Player(stdscr, "@", curses.COLOR_RED, curses.COLOR_BLACK,
                        curses.A_BOLD)

        curses.attron(curses.color_pair(1))
        curses.vline("|", 10)
        curses.hline("-", 10)
        curses.attroff(curses.color_pair(1))

        while True:
            key = curses.getch()

            avatar.move(key)

            if key == 27:
                break

            curses.update_panels()
            curses.doupdate()

    except Exception as e:
        stdscr.addstr(0, 0, str(e))
        stdscr.getch()
    finally:

        curses.endwin()

    return 0
예제 #17
0
파일: main.py 프로젝트: akiky/manageri
def main():
    stdscr = curses.initscr()
    curses.keypad(stdscr, True)
    curses.curs_set(False)
    curses.noecho()
    curses.start_color()

    select = mainmenu()
    curses.erase()
    if (select == 3):
        pass

    elif (select == 2):
        curses.mvaddstr(1, 1, "Lataa peli")

    elif (select == 1):
        newgame()
        create_game()
        game_main_loop()

    curses.endwin()
예제 #18
0
    def __init__(self):  #, stdscreen):
        self.screen = uni.initscr()  #stdscreen
        uni.keypad(self.screen, True)
        uni.curs_set(0)
        uni.noecho()
        uni.cbreak()
        #menuwin = uni.subwin(self.screen, 23, 79, 0, 0)
        menuwin = uni.newwin(10, 40, 0, 0)
        #uni.box(menuwin, 0, 0)
        #uni.hline(2, 1)#, uni.ACS_HLINE, 77)
        #uni.mvwhline(menuwin, 2, 1, uni.ACS_HLINE, 40 - 2)
        uni.new_panel(menuwin)
        uni.refresh()

        submenu_items = [('beep', uni.beep), ('flash', uni.flash)]
        submenu = Menu(submenu_items, self.screen)

        main_menu_items = [('beep', uni.beep), ('flash', uni.flash),
                           ('submenu', submenu.display)]
        main_menu = Menu(main_menu_items, self.screen)
        main_menu.display()
예제 #19
0
 def __init__(self):
     # Initialize screen
     self.stdscr = uni.initscr()
     # Hide cursor
     uni.curs_set(0)
     # Characters available one-by-one
     uni.cbreak()
     # Prevent displying user input
     uni.noecho()
     # Allow user input
     uni.keypad(self.stdscr, True)
     # Enable colors
     uni.start_color()
     # Enable mouse
     uni.mouseinterval(0)
     uni.mousemask(uni.ALL_MOUSE_EVENTS)
     # Window dimensions
     y, x = uni.getmaxyx(self.stdscr)
     # Make maxx/maxy the last row/col visible
     self.maxy = y - 1
     self.maxx = x - 1
     # Drawing order of contained widgets
     self.widgets = []
예제 #20
0
파일: codetest.py 프로젝트: MeetLuck/works
import sys

import time, random
import unicurses as curses 

screen = curses.initscr()
screen.nodelay(1)
screen.border()
curses.noecho()
curses.curs_set(0)
dims = screen.getmaxyx()
height,width = dims[0]-1, dims[1]-1
curses.start_color()
curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)

row,col= 0,0
for i in range(256):
    screen.addch(row,col,i,curses.color_pair(0) )
    col +=1
    if col>75:
        row +=1
        col = 1
    screen.refresh()
    time.sleep(0.051)
curses.endwin()
예제 #21
0
파일: main.py 프로젝트: miezak/madodl
def main_loop(manga_list):
    global compc, compv

    for m in manga_list:
            req               = _parsers.ParseRequest(m)
            sout, title, path = get_listing(req._name)

            if _g.conf._usecache and _g.conf._found_in_cache:
                sout = subdir_recurse(sout, path)
            else:
                sout = sout.splitlines()
                sout = rem_subdir_recurse(sout, path)

            compv, compc, allf, compfile = walk_thru_listing(req, title, sout)

            if req._vols and req._vols[-1] == req.ALL:
                del req._vols[-1]

            if req._chps and req._chps[-1] == req.ALL:
                del req._chps[-1]

            missv = str([v for v in req._vols if v not in compv]).strip('[]')
            missc = str([c for c in req._chps if c not in compc]).strip('[]')

            if missv:
                _out._("couldn't find vol(s): " + missv)

            if missc:
                _out._("couldn't find chp(s): " + missc)

            if any((compfile, compc, compv)):
                # XXX sigh...
                # need to append MLOC when we get a cache match.
                ppfx = ''.join(['https://', loc['DOMAIN']])

                if _g.conf._found_in_cache:
                    ppfx = ''.join([ppfx, loc['MLOC']])

                try:
                    stdscr          = unicurses.initscr()
                    _g.conf._stdscr = stdscr
                    unicurses.noecho()

                    if compfile:
                        _out._('downloading complete archive... ', end='')
                        _g.conf._stdscr.erase()
                        _g.conf._stdscr.addstr(0, 0, compfile.name)
                        _g.conf._stdscr.refresh()
                        _curl.curl_to_file('/'.join([ppfx, 
                                                     _util.create_nwo_basename(
                                                        compfile.basename),
                                                     urllib
                                                       .parse
                                                       .quote(compfile.name)]),
                                           compfile.name, 'HTTP')
                    elif compv or compc:
                        _out._('downloading volume/chapters... ', end='')
                        for f,v,c in allf:
                            #_g.log.info('DL ' + f)
                            _g.conf._stdscr.erase()
                            _g.conf._stdscr.addstr(0, 0, 'title - {}'
                                                           .format(title))
                            _g.conf._stdscr.addstr(1, 0, 'current - {}'
                                                           .format(f.name))
                            _g.conf._stdscr.refresh()
                            _curl.curl_to_file('/'.join([ppfx,
                                                         _util
                                                           .create_nwo_basename(                                                             f.basename),
                                                         urllib
                                                           .parse
                                                           .quote(f.name)]),
                                               f.name, 'HTTP')
                except:
                    raise
                finally:
                    unicurses.nocbreak()
                    _g.conf._stdscr.keypad(False)
                    unicurses.echo()
                    unicurses.endwin()

                print('done', file=sys.stderr)
            else:
                _out._('could not find any requested volume/chapters.')
                return 1

    return 0
예제 #22
0
 def echo(self, yes: bool = True):
     """If False, then all keypresses by the user are not drawn on the screen."""
     if yes:
         unicurses.echo()
     else:
         unicurses.noecho()
예제 #23
0
파일: main.py 프로젝트: pqlime/jsrlive-cli
import struct
import sys
import threading
import time
import unicurses
import wave


os.chdir(os.path.dirname(os.path.realpath(__file__)))  # Changes working directory to the script's parent directory


# Screen config

stdscr = unicurses.initscr()  # initiates the unicurses module & returns a writable screen obj

unicurses.noecho()  # disables echoing of user input
unicurses.cbreak()  # characters are read one-by-one
unicurses.curs_set(0)  # Hide the cursor from view by the user
unicurses.start_color()  # enables color in terminal

stdscr.keypad(True)  # returns special keys like PAGE_UP, etc.
stdscr.nodelay(False)  # enables input blocking to keep CPU down

locale.setlocale(locale.LC_ALL, '')
encoding = locale.getpreferredencoding()  # get the preferred system encoding for unicode support

if sys.platform == 'win32':  # Windows: set codepage to 65001 for unicode support
    os.system('chcp 65001')

# Settings
예제 #24
0
 def __init__(self):
     stdscr = uni.initscr()
     uni.start_color()
     uni.cbreak()
     uni.noecho()
     uni.keypad(stdscr, True)
예제 #25
0
        self.game_menu_interface.disable()

    def key_event(self, key):
        if not self.game_menu_interface.enabled and not self.game_field.enabled and not self.game_stat.enabled:
            self.main_menu.key_event(key)
        elif self.main_menu.enabled and self.game_menu_interface.blocked:
            self.main_menu.key_event(key)
        elif not self.main_menu.enabled and self.game_menu_interface.blocked:
            self.game_field.key_event(key)
        else:
            self.game_menu_interface.key_event(key)

if __name__ == "__main__":
    stdscr = initscr()
    clear()
    noecho()
    cbreak()
    curs_set(0)
    keypad(stdscr, True)
    start_color()
    use_default_colors()
    nodelay(stdscr, True)
    init_pair(1, COLOR_BLACK, COLOR_WHITE)
    init_pair(2, COLOR_WHITE, COLOR_BLUE)
    init_pair(3, COLOR_BLACK, COLOR_BLUE)
    init_pair(4, COLOR_WHITE, COLOR_CYAN)
    init_pair(5, COLOR_YELLOW, COLOR_GREEN)
    init_pair(6, COLOR_GREEN, COLOR_BLACK)
    init_pair(7, COLOR_RED, COLOR_BLACK)
    init_pair(8, COLOR_BLUE, COLOR_YELLOW)
    init_pair(9, COLOR_RED, COLOR_YELLOW)
예제 #26
0
    def key_event(self, key):
        if not self.game_menu_interface.enabled and not self.game_field.enabled and not self.game_stat.enabled:
            self.main_menu.key_event(key)
        elif self.main_menu.enabled and self.game_menu_interface.blocked:
            self.main_menu.key_event(key)
        elif not self.main_menu.enabled and self.game_menu_interface.blocked:
            self.game_field.key_event(key)
        else:
            self.game_menu_interface.key_event(key)


if __name__ == "__main__":
    stdscr = initscr()
    clear()
    noecho()
    cbreak()
    curs_set(0)
    keypad(stdscr, True)
    start_color()
    use_default_colors()
    nodelay(stdscr, True)
    init_pair(1, COLOR_BLACK, COLOR_WHITE)
    init_pair(2, COLOR_WHITE, COLOR_BLUE)
    init_pair(3, COLOR_BLACK, COLOR_BLUE)
    init_pair(4, COLOR_WHITE, COLOR_CYAN)
    init_pair(5, COLOR_YELLOW, COLOR_GREEN)
    init_pair(6, COLOR_GREEN, COLOR_BLACK)
    init_pair(7, COLOR_RED, COLOR_BLACK)
    init_pair(8, COLOR_BLUE, COLOR_YELLOW)
    init_pair(9, COLOR_RED, COLOR_YELLOW)
예제 #27
0
파일: game.py 프로젝트: initrl/SleepWell
 def __init__(self):
     self.screen = unicurses.initscr()
     unicurses.noecho()
     unicurses.cbreak()
     unicurses.curs_set(0)
     self.screen.refresh()
        def bar(*args, **kw):
            kw['ssl_version'] = ssl.PROTOCOL_TLSv1
            return func(*args, **kw)
        return bar
    ssl.wrap_socket = sslwrap(ssl.wrap_socket)

# Start the tool by initializing unicurses and creating a new Screen object.
# Before doing so, set the ESCDELAY environment variable to 25, in an attempt to
# mitigate the delay following the pressing of the escape key during line
# editing.
if __name__ == '__main__':
    os.environ.setdefault('ESCDELAY', '25')
    fixssl()
    try:
        stdscr = unicurses.initscr()
        unicurses.noecho()
        unicurses.cbreak()
        try: unicurses.start_color()
        except: pass
        scr = Screen(stdscr)
        saf = Safety(scr)
        win = Main(scr)
        scr.render()
        while True:
            win.show()
            if not scr.modified() or saf.show(): break
    finally:
        if 'stdscr' in locals():
            unicurses.echo()
            unicurses.nocbreak()
            unicurses.endwin()
예제 #29
0
def main(stdscr):
    curses.cbreak()
    curses.noecho()
    stdscr.keypad(True)
    height, width = stdscr.getmaxyx()

    suffix_text = ' (TAB to search by artist)'
    albums_panel = Menu('Album(s) for the selected artist' + suffix_text,
                        (height, width, 0, 0))

    tracks_panel = Menu('Track(s) for the selected album' + suffix_text,
                        (height, width, 0, 0))

    criteria = show_search_screen(stdscr)
    _data_manager = DataManager()
    artist = _data_manager._search_artist(criteria)
    albums = _data_manager.get_artist_albums(artist['id'])

    clear_screen(stdscr)

    albums_panel.items = albums
    albums_panel.init()
    albums_panel.update()
    albums_panel.show()

    current_panel = albums_panel
    is_running = True

    while is_running:
        curses.doupdate()
        current_panel.update()

        key = stdscr.getch()
        action = current_panel.handle_events(key)

        if action is not None:
            action_result = action()
            if current_panel == albums_panel and action_result is not None:
                _id, uri = action_result
                tracks = _data_manager.get_album_tracklist(_id)
                current_panel.hide()
                current_panel = tracks_panel
                current_panel.items = tracks
                current_panel.init()
                current_panel.show()
            elif current_panel == tracks_panel and action_result is not None:
                _id, uri = action_result
                _data_manager.play(uri)

        if key == TAB:
            current_panel.hide()
            criteria = show_search_screen(stdscr)
            artist = _data_manager._search_artist(criteria)
            albums = _data_manager.get_artist_albums(artist['id'])

            clear_screen(stdscr)
            current_panel = albums_panel
            current_panel.items = albums
            current_panel.init()
            current_panel.show()

        if key == ord('q') or key == ord('Q'):
            is_running = False

        current_panel.update()
import logging
import unicurses
from nex2art.menu import Safety, Main
from nex2art.core import Setup, Screen

# Start the tool by initializing unicurses and creating a new Screen object.
# Before doing so, set the ESCDELAY environment variable to 25, in an attempt to
# mitigate the delay following the pressing of the escape key during line
# editing.
if __name__ == '__main__':
    setup = Setup()
    logging.info("Initializing Nexus migration tool.")
    os.environ.setdefault('ESCDELAY', '25')
    try:
        stdscr = unicurses.initscr()
        unicurses.noecho()
        unicurses.cbreak()
        try:
            unicurses.start_color()
        except:
            pass
        scr = Screen(stdscr)
        saf = Safety(scr)
        win = Main(scr)
        scr.render()
        while True:
            win.show()
            if not scr.modified() or saf.show(): break
    except:
        logging.exception("Error running Nexus migration tool:")
        raise
예제 #31
0
파일: snake_d.py 프로젝트: mawunka/tz
import unicurses as curses
import time
import os
from random import randint, choice

os.environ['ESCDELAY'] = '25'
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
curses.keypad(stdscr, 1)
curses.wborder(stdscr)
curses.curs_set(0)
middley, middlex = map(lambda x: x // 2, curses.getmaxyx(
    stdscr))  # get middle coordinates depending on the size of the terminal

UP = 259  # ascii key codes
DOWN = 258
LEFT = 261
RIGHT = 260

asci = '''
   _____ _   _          _  ________ 
  / ____| \ | |   /\   | |/ /  ____|
 | (___ |  \| |  /  \  | ' /| |__   
  \___ \| . ` | / /\ \ |  < |  __|  
  ____) | |\  |/ ____ \| . \| |____ 
 |_____/|_| \_/_/    \_\_|\_\______|'''


def reset_game():
    '''
예제 #32
0
def initCurses():
    stdscr = uc.initscr()
    uc.noecho()
    uc.curs_set(False)
    uc.keypad(stdscr, True)
    uc.start_color()
예제 #33
0
    uni.wrefresh(menu_win)

def report_choice(mouse_x, mouse_y):
    i = startx + 2
    j = starty + 3
    for choice in range(0, n_choices):
        if (mouse_y == j + choice) and (mouse_x >= i) and (mouse_x <= i + len(choices[choice])):
            if choice == n_choices - 1:
                return -1
            else:
                return choice + 1
            break

stdscr = uni.initscr()
uni.clear()
uni.noecho()
uni.cbreak()
uni.curs_set(0)
startx = int((80 - WIDTH) / 2)
starty = int((24 - HEIGHT) / 2)

menu_win = uni.newwin(HEIGHT, WIDTH, starty, startx)
uni.keypad(menu_win, True)
uni.mvaddstr(0, 0, "Click on Exit to quit (works best in a virtual console)")
uni.refresh()
print_menu(menu_win, 1)
uni.mouseinterval(0)
uni.mousemask(uni.ALL_MOUSE_EVENTS)


msg = "MOUSE: {0}, {1}, {2}, Choice made is: {3}, Chosen string is: {4}"