Skip to content

Instantly share code, notes, and snippets.

@vtr0n
Last active April 21, 2018 07:39
Show Gist options
  • Save vtr0n/29341ee01efb317febc2cc69c34c9394 to your computer and use it in GitHub Desktop.
Save vtr0n/29341ee01efb317febc2cc69c34c9394 to your computer and use it in GitHub Desktop.
Npyscreen example 1
#!/usr/bin/env python3
import npyscreen
class App(npyscreen.StandardApp):
def onStart(self):
self.addForm("MAIN", MainForm, name="Hello Medium!")
class MainForm(npyscreen.ActionForm):
# Constructor
def create(self):
# Add the TitleText widget to the form
self.title = self.add(npyscreen.TitleText, name="TitleText", value="Hello World!")
# Override method that triggers when you click the "ok"
def on_ok(self):
self.parentApp.setNextForm(None)
# Override method that triggers when you click the "cancel"
def on_cancel(self):
self.title.value = "Hello World!"
MyApp = App()
MyApp.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment