コード例 #1
0
def dashboard_test_case( win, name, path, ignore = None ):
    create = ( os.environ.get("TEST_CREATE_SNAPSHOT","False") == "True" )
    snap_shot_file = os.path.join(os.path.join(path,"tests/snapshots"),"%s.dmp"%(name))
    win.refresh()
    if os.path.exists(snap_shot_file):
        snapshot = load_snapshot( open(snap_shot_file,"rb") )
        max_y,max_x,difference,has_differences = compare_snapshot( win, snapshot, ignore )
        if has_differences:
            if create:
                backup_win = BytesIO()
                win.putwin(backup_win)
                backup_win.seek(0,0)
                overlay = curses.getwin(backup_win)
                view_differences(overlay,(max_y,max_x,difference,has_differences))
                if prompt(overlay,"%s:Accept these differences?"%name):
                    del overlay
                    win.touchwin()
                    win.refresh()
                    save_snapshot(win,open(snap_shot_file,"wb"))
                    win.clear()
                    return
            assert False, "%s:Screen differences found:\n%s"%(name,format_differences(max_y,max_x,difference,has_differences))
    else:
        if create:
            if prompt(win,"%s:Is this screen correct?"%name):
                save_snapshot(win,open(snap_shot_file,"wb"))
                win.touchwin()
                win.refresh()
                win.clear()
                return
        assert False, "%s:No snapshot found"%name
    win.clear()
コード例 #2
0
 def restore(self):
     self.screen.clear()
     pos, fn = self.form_screens.pop(-1)
     fh = open(fn, "rb")
     self.screen = curses.getwin(fh)
     self.screen.move(pos[0], pos[1])
     log("restore:pos", pos)
     fh.close()
     os.remove(fn)
コード例 #3
0
ファイル: guiMain.py プロジェクト: icedwater/clifox
 def restore(self):
  self.screen.clear()
  pos,fn=self.form_screens.pop(-1)
  fh=open(fn,"rb")
  self.screen=curses.getwin(fh)
  self.screen.move(pos[0],pos[1])
  log("restore:pos",pos)
  fh.close()
  os.remove(fn)
コード例 #4
0
def load():
    f = open('save.hero', 'r')
    hero = pickle.load(f)
    f.close()
    p.init_game(hero, hero.dungeonLevel, hero.cetus_amulet_level)
    f = open('save.pad', 'r')
    pad = curses.getwin(f)
    f.close()
    f = open('save.win', 'r')
    win = curses.getwin(f)
    f.close()
    f = open('save.enemies', 'r')
    enemies = pickle.load(f)
    f.close()
    f = open('save.items', 'r')
    map_items = pickle.load(f)
    f.close()
    p.place_hero(hero, pad, True)
    return hero, pad, win, enemies, map_items
コード例 #5
0
ファイル: visualize.py プロジェクト: piddek/pttp
    def slide_text(self, l):
        if l == "":
            return True

        if self.slidedir == "left":
            xcount = len(l) - 1
            while xcount >= 0:
                self.screen.move(self.cur_line, self.indent)
                self.screen.addstr(l[xcount:len(l)])
                self.screen.refresh()
                time_to_sleep = float(1) / 20
                time.sleep(time_to_sleep)
                xcount -= 1
        elif self.slidedir == "right":
            for pos in range(self.termwidth - self.indent + 1):
                self.screen.move(self.cur_line, self.termwidth - pos - 1)
                self.screen.clrtoeol()
                self.screen.addstr(l[0:pos + 1])
                self.screen.refresh()
                time_to_sleep = float(1) / 20
                time.sleep(time_to_sleep)
        elif self.slidedir == "top":
            tmpfile = tempfile.TemporaryFile()
            self.screen.putwin(tmpfile)
            for i in range(1, self.cur_line + 1):
                tmpfile.seek(0)
                self.screen = curses.getwin(
                    tmpfile)  # overwrite self.screen with saved screen
                self.screen.addstr(i, self.indent, l)
                self.screen.refresh()
                time.sleep(float(1) / 10)
        elif self.slidedir == "bottom":
            tmpfile = tempfile.TemporaryFile()
            self.screen.putwin(tmpfile)
            for i in range(self.termheight - 1, self.cur_line - 1, -1):
                tmpfile.seek(0)
                self.screen = curses.getwin(
                    tmpfile)  # overwrite self.screen with saved screen
                self.screen.addstr(i, self.indent, l)
                self.screen.move(i, self.indent)
                self.screen.addstr(l)
                self.screen.refresh()
                time.sleep(float(1) / 10)
コード例 #6
0
ファイル: SimpleWiFi.py プロジェクト: kkangshawn/SimpleWiFi
def clearscr(stdscr):
    stdscr.clear()
    STATIC.mainWnd.seek(0)
    try:
        stdscr = curses.getwin(STATIC.mainWnd)
    except:
        stdscr.addstr(3, 3, "curses.getwin() error.")
        stdscr.addstr(4, 3, "check your putwin() routine.")
        stdscr.refresh()
        stdscr.getkey()
    return stdscr
コード例 #7
0
    def Restore(self):
        # Stack cannot be empty
        if len(self.stack) == 0:
            return

        self.stackFile.seek(self.stack[-1])
        self.screen = curses.getwin(self.stackFile)

        # Clear Notification Line
        DEBUG.Display(" ")

        self.Refresh()
コード例 #8
0
ファイル: screen.py プロジェクト: rbavishi/Habitican-Curse
    def Restore(self):
        # Stack cannot be empty
        if len(self.stack) == 0:
            return

        self.stackFile.seek(self.stack[-1])
        self.screen = curses.getwin(self.stackFile)

        # Clear Notification Line
        DEBUG.Display(" ")

        self.Refresh()
コード例 #9
0
def clearscr(stdscr):
    stdscr.clear()
    STATIC.mainWnd.seek(0)
    try:
        stdscr = curses.getwin(STATIC.mainWnd)
    except:
        stdscr.addstr(3, 3, "curses.getwin() error.")
        stdscr.addstr(4, 3, "check your putwin() routine.")
        stdscr.refresh()
        stdscr.getkey()

    return stdscr
コード例 #10
0
    def RestoreRegister(self, register):
        # Should be between 0 and C.NUM_CONTEXT_REGISTERS-1
        if register >= C.NUM_CONTEXT_REGISTERS:
            return

        # Register is empty
        if not self.active_registers[register]:
            return

        self.ctxts[register].seek(0)
        self.screen = curses.getwin(self.ctxts[register])

        # Clear Notification Line
        DEBUG.Display(" ")
        self.Refresh()
コード例 #11
0
ファイル: screen.py プロジェクト: rbavishi/Habitican-Curse
    def RestoreRegister(self, register):
        # Should be between 0 and C.NUM_CONTEXT_REGISTERS-1
        if register >= C.NUM_CONTEXT_REGISTERS:
            return

        # Register is empty
        if not self.active_registers[register]:
            return

        self.ctxts[register].seek(0)
        self.screen = curses.getwin(self.ctxts[register])

        # Clear Notification Line
        DEBUG.Display(" ")
        self.Refresh()
コード例 #12
0
ファイル: SimpleWiFi.py プロジェクト: kkangshawn/SimpleWiFi
def inputwnd(stdscr, msg = None, pos_y = None, pos_x = 2, size_y = 1, size_x = 30):
    tempscr = tempfile.TemporaryFile()
    stdscr.putwin(tempscr)

    if pos_y is None:
        pos_y = curses.LINES - 5
    if msg is not None and (len(msg) + 2 > size_x):
        size_x = len(msg) + 2
    inputWnd = curses.newwin(size_y, size_x, pos_y, pos_x)
    rectangle(stdscr, pos_y - 1, pos_x - 1, pos_y + size_y, pos_x + size_x)
    if msg is not None:
        stdscr.addstr(pos_y - 1, pos_x, " %s " % msg)
    stdscr.refresh()
    box = Textbox(inputWnd)
    box.edit()
    boxtext = box.gather()[:len(box.gather()) - 1]

    tempscr.seek(0)
    stdscr = curses.getwin(tempscr)
    stdscr.refresh()

    return boxtext
コード例 #13
0
def inputwnd(stdscr, msg=None, pos_y=None, pos_x=2, size_y=1, size_x=30):
    tempscr = tempfile.TemporaryFile()
    stdscr.putwin(tempscr)

    if pos_y is None:
        pos_y = curses.LINES - 5
    if msg is not None and (len(msg) + 2 > size_x):
        size_x = len(msg) + 2
    inputWnd = curses.newwin(size_y, size_x, pos_y, pos_x)
    rectangle(stdscr, pos_y - 1, pos_x - 1, pos_y + size_y, pos_x + size_x)
    if msg is not None:
        stdscr.addstr(pos_y - 1, pos_x, " %s " % msg)
    stdscr.refresh()
    box = Textbox(inputWnd)
    box.edit()
    boxtext = box.gather()[:len(box.gather()) - 1]

    tempscr.seek(0)
    stdscr = curses.getwin(tempscr)
    stdscr.refresh()

    return boxtext
コード例 #14
0
ファイル: test_curses.py プロジェクト: mcyril/ravel-ftn
#
コード例 #15
0
ファイル: tabs.py プロジェクト: ThinkChaos/py
def load(f):
  f = open(f, 'r')
  return curses.getwin(f)
コード例 #16
0
ファイル: test_curses.py プロジェクト: circinusX1/minimarmfs
def module_funcs(stdscr):
    "Test module-level functions"

    for func in [curses.baudrate, curses.beep, curses.can_change_color,
                 curses.cbreak, curses.def_prog_mode, curses.doupdate,
                 curses.filter, curses.flash, curses.flushinp,
                 curses.has_colors, curses.has_ic, curses.has_il,
                 curses.isendwin, curses.killchar, curses.longname,
                 curses.nocbreak, curses.noecho, curses.nonl,
                 curses.noqiflush, curses.noraw,
                 curses.reset_prog_mode, curses.termattrs,
                 curses.termname, curses.erasechar, curses.getsyx]:
        func()

    # Functions that actually need arguments
    if curses.tigetstr("cnorm"):
        curses.curs_set(1)
    curses.delay_output(1)
    curses.echo() ; curses.echo(1)

    f = tempfile.TemporaryFile()
    stdscr.putwin(f)
    f.seek(0)
    curses.getwin(f)
    f.close()

    curses.halfdelay(1)
    curses.intrflush(1)
    curses.meta(1)
    curses.napms(100)
    curses.newpad(50,50)
    win = curses.newwin(5,5)
    win = curses.newwin(5,5, 1,1)
    curses.nl() ; curses.nl(1)
    curses.putp('abc')
    curses.qiflush()
    curses.raw() ; curses.raw(1)
    curses.setsyx(5,5)
    curses.tigetflag('hc')
    curses.tigetnum('co')
    curses.tigetstr('cr')
    curses.tparm('cr')
    curses.typeahead(sys.__stdin__.fileno())
    curses.unctrl('a')
    curses.ungetch('a')
    curses.use_env(1)

    # Functions only available on a few platforms
    if curses.has_colors():
        curses.start_color()
        curses.init_pair(2, 1,1)
        curses.color_content(1)
        curses.color_pair(2)
        curses.pair_content(curses.COLOR_PAIRS - 1)
        curses.pair_number(0)

        if hasattr(curses, 'use_default_colors'):
            curses.use_default_colors()

    if hasattr(curses, 'keyname'):
        curses.keyname(13)

    if hasattr(curses, 'has_key'):
        curses.has_key(13)

    if hasattr(curses, 'getmouse'):
        (availmask, oldmask) = curses.mousemask(curses.BUTTON1_PRESSED)
        # availmask indicates that mouse stuff not available.
        if availmask != 0:
            curses.mouseinterval(10)
            # just verify these don't cause errors
            m = curses.getmouse()
            curses.ungetmouse(*m)
コード例 #17
0
def printf(string, end='\n'):
    window = curses.getwin()
    pos = curses.getsyx()
    window.addstr(pos[0], pos[1], string + end)
    window.refresh()
コード例 #18
0
#