Skip to content

Instantly share code, notes, and snippets.

@jhagberg
Created April 14, 2019 15:52
Show Gist options
  • Save jhagberg/4286a4e1d4104f0d4fefac0e42ac339a to your computer and use it in GitHub Desktop.
Save jhagberg/4286a4e1d4104f0d4fefac0e42ac339a to your computer and use it in GitHub Desktop.
npyscreen BufferPager move from Widget
#!/usr/bin/env python
# encoding: utf-8
"""
ExampleManaged.py
Created by Nicholas Cole on 2007-02-22.
"""
import npyscreen, curses
class MyTestApp(npyscreen.NPSAppManaged):
def onStart(self):
self.registerForm("MAIN", MainForm())
class MainForm(npyscreen.Form):
def create(self):
self.add(npyscreen.TitleText, name = "Text:", value= "Press Escape to quit application" )
self.box1= self.add(npyscreen.BoxBasic, name = "Basic Box:", max_width=30, relx=2, max_height=3)
self.box1.footer = "This is a footer"
self.t3 = self.add(npyscreen.BoxTitle, name="Box Title2:", max_height=6,
scroll_exit = True,
contained_widget_arguments={
'color': "WARNING",
'widgets_inherit_color': True,}
)
self.t2 = self.add(npyscreen.BoxTitle, name="Box Title:", max_height=6)
self.SerBuff = self.add(SerialLog, name="Box Title:", max_height=6,editable=True)
self.SerBuff.entry_widget.buffer(["DEG","FISTEL","DEG"])
self.t2.entry_widget.scroll_exit = True
self.t2.values = ["Hello",
"This is a Test",
"This is another test",
"And here is another line",
"And here is another line, which is really very long. abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
"And one more."]
self.t3.values = self.t2.values
self.how_exited_handers[npyscreen.wgwidget.EXITED_ESCAPE] = self.exit_application
def exit_application(self):
curses.beep()
self.parentApp.setNextForm(None)
self.editing = False
class SerialLog(npyscreen.BoxTitle):
_contained_widget = npyscreen.BufferPager
def main():
TA = MyTestApp()
TA.run()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment