Skip to content

Instantly share code, notes, and snippets.

@sdressler
Created April 24, 2013 08:50
Show Gist options
  • Save sdressler/5450705 to your computer and use it in GitHub Desktop.
Save sdressler/5450705 to your computer and use it in GitHub Desktop.
npyscreen form with status line
import npyscreen, curses
class StatusWidget(npyscreen.wgwidget.Widget):
def update(self, clear=True):
if clear == True:
self.clear()
self.status = npyscreen.Textfield(self.parent, rely=self.rely, relx=0, editable=1)
def set_status(self, value):
self.status.value = value
self.status.update()
class MainWidget(npyscreen.MultiLine):
def set_values(self, values):
self.values = values
class MainForm(npyscreen.FormBaseNew):
DEFAULT_X_OFFSET = 0
BLANK_LINES_BASE = 0
BLANK_COLUMNS_RIGHT = 0
FRAMED = False
def draw_form(self):
pass
def create(self):
MAX_X = self.columns
MAX_Y = self.lines
self.add(MainWidget, rely = 0, max_height = -2)
Status = self.add(StatusWidget, 'Status', rely = MAX_Y - 1)
Status.set_status("New status")
class MailerAppManaged(npyscreen.NPSAppManaged):
def onStart(self):
self.addForm('MAIN', MainForm)
if __name__ == '__main__':
MailerApp = MailerAppManaged()
MailerApp.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment