Python curses.doupdate() Examples

The following are 12 code examples of curses.doupdate(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module curses , or try the search function .
Example #1
Source File: fm_cli.py    From baidufm-py with MIT License 5 votes vote down vote up
def setup_and_draw_screen(self):
        self.max_y, self.max_x = self.stdscr.getmaxyx()
        self.head_win = curses.newwin(1, self.max_x, 0, 0)
        self.body_win = curses.newwin(self.max_y - 2, self.max_x, 1, 0)
        self.footer_win = curses.newwin(1, self.max_x, self.max_y - 1, 0)
        self.login_win = curses.newwin(self.max_y - 2, self.max_x, 1, 0)

        self.init_head()
        self.init_body()
        self.init_footer()

        self.footer.set_screen(self.footer_win)
        self.body_win.keypad(1)
        curses.doupdate() 
Example #2
Source File: pytrader.py    From pytrader with MIT License 5 votes vote down vote up
def __del__(self):
        del self.panel
        del self.win
        curses.panel.update_panels()
        curses.doupdate() 
Example #3
Source File: pytrader.py    From pytrader with MIT License 5 votes vote down vote up
def done_paint(self):
        """update the sreen after paint operations, this will invoke all
        necessary stuff to refresh all (possibly overlapping) windows in
        the right order and then push it to the screen"""
        curses.panel.update_panels()
        curses.doupdate() 
Example #4
Source File: terminal.py    From ttrv with MIT License 5 votes vote down vote up
def suspend():
        """
        Suspend curses in order to open another subprocess in the terminal.
        """

        try:
            curses.endwin()
            yield
        finally:
            curses.doupdate() 
Example #5
Source File: curseradio.py    From curseradio with MIT License 5 votes vote down vote up
def display(self, msg=None):
        """
        Redraw the screen, possibly showing a message on the bottom row.
        """
        self.screen.clear()

        width0 = 6*(self.maxx - 10)//10
        width1 = 4*(self.maxx - 10)//10

        showobjs = self.flat[self.top:self.top+self.maxy-1]
        for i, (obj, depth) in enumerate(showobjs):
            text = obj.render()
            style = curses.A_BOLD if i == self.cursor else curses.A_NORMAL
            self.screen.addstr(i, depth*2, text[0][:width0-depth*2], style)
            self.screen.addstr(i, width0+2, text[1][:width1-4])
            self.screen.addstr(i, width0+width1, text[2][:4])
            self.screen.addstr(i, width0+width1+5, text[3][:5])

        if msg is not None:
            self.screen.addstr(self.maxy-1, 0,
                               msg[:self.maxx-1], curses.A_BOLD)
        else:
            self.screen.addstr(self.maxy-1, 0,
                               self.status[:self.maxx-1], curses.A_BOLD)

        self.screen.refresh()
        curses.doupdate() 
Example #6
Source File: cli.py    From SecureChat with MIT License 5 votes vote down vote up
def refresh_chat(self):
        """
        Refresh only the chat box.
        """
        self.chat_container.noutrefresh()
        self.chat_win.noutrefresh()
        curses.doupdate() 
Example #7
Source File: cli.py    From SecureChat with MIT License 5 votes vote down vote up
def refresh_prompt(self):
        """
        Refresh only the input prompt.
        """
        self.prompt_win.noutrefresh()
        curses.doupdate() 
Example #8
Source File: cli.py    From SecureChat with MIT License 5 votes vote down vote up
def refresh_all(self):
        """
        Refresh everything in the interface.
        """
        self.stdscr.noutrefresh()
        self.chat_container.noutrefresh()
        self.chat_win.noutrefresh()
        self.prompt_win.noutrefresh()
        curses.doupdate() 
Example #9
Source File: zktop.py    From python-scripts with GNU General Public License v3.0 5 votes vote down vote up
def resize(self, uis):
        curses.endwin()
        curses.doupdate()

        global mainwin
        mainwin.refresh()
        maxy, maxx = mainwin.getmaxyx()

        for ui in uis:
            ui.resize(maxy, maxx) 
Example #10
Source File: terminal.py    From rtv with MIT License 5 votes vote down vote up
def suspend():
        """
        Suspend curses in order to open another subprocess in the terminal.
        """

        try:
            curses.endwin()
            yield
        finally:
            curses.doupdate() 
Example #11
Source File: cursesgui.py    From ham2mon with GNU General Public License v3.0 4 votes vote down vote up
def main():
    """Test most of the GUI (except lockout processing)

    Initialize and set up screen
    Create windows
    Generate dummy spectrum data
    Update windows with dummy values
    Process keyboard strokes
    """
    # Use the curses.wrapper() to crash cleanly
    # Note the screen object is passed from the wrapper()
    # http://stackoverflow.com/questions/9854511/ppos_ython-curses-dilemma
    # The issue is the debuuger won't work with the wrapper()
    # So enable the next 2 lines and don't pass screen to main()
    screen = curses.initscr()
    curses.start_color()

    # Setup the screen
    setup_screen(screen)

    # Create windows
    specwin = SpectrumWindow(screen)
    chanwin = ChannelWindow(screen)
    lockoutwin = LockoutWindow(screen)
    rxwin = RxWindow(screen)

    while 1:
        # Generate some random spectrum data from -dyanmic_range to 0 dB
        #   then offset_db
        length = 128
        dynamic_range_db = 100
        offset_db = 50
        data = np.power(10, (-dynamic_range_db*np.random.rand(length)/10)\
            + offset_db/10)
        #data = 1E-5*np.ones(length)
        specwin.draw_spectrum(data)

        # Put some dummy values in the channel, lockout, and receiver windows
        chanwin.draw_channels(['144.100', '142.40', '145.00', '144.10',\
        '142.40', '145.00', '144.10', '142.40', '145.00', '144.10', '142.40',\
        '145.00', '142.40', '145.00', '144.10', '142.400', '145.00', '145.00'])
        lockoutwin.draw_channels(['144.100', '142.40', '145.00'])
        rxwin.draw_rx()

        # Update physical screen
        curses.doupdate()

        # Check for keystrokes and process
        keyb = screen.getch()
        specwin.proc_keyb(keyb)
        rxwin.proc_keyb_hard(keyb)
        rxwin.proc_keyb_soft(keyb)

        # Sleep to get about a 10 Hz refresh
        time.sleep(0.1) 
Example #12
Source File: curses_display.py    From anyMesh-Python with MIT License 4 votes vote down vote up
def _get_input(self, wait_tenths):
        # this works around a strange curses bug with window resizing 
        # not being reported correctly with repeated calls to this
        # function without a doupdate call in between
        curses.doupdate() 
        
        key = self._getch(wait_tenths)
        resize = False
        raw = []
        keys = []
        
        while key >= 0:
            raw.append(key)
            if key==KEY_RESIZE: 
                resize = True
            elif key==KEY_MOUSE:
                keys += self._encode_mouse_event()
            else:
                keys.append(key)
            key = self._getch_nodelay()

        processed = []
        
        try:
            while keys:
                run, keys = escape.process_keyqueue(keys, True)
                processed += run
        except escape.MoreInputRequired:
            key = self._getch(self.complete_tenths)
            while key >= 0:
                raw.append(key)
                if key==KEY_RESIZE: 
                    resize = True
                elif key==KEY_MOUSE:
                    keys += self._encode_mouse_event()
                else:
                    keys.append(key)
                key = self._getch_nodelay()
            while keys:
                run, keys = escape.process_keyqueue(keys, False)
                processed += run

        if resize:
            processed.append('window resize')

        return processed, raw