Last active
April 21, 2018 07:39
-
-
Save vtr0n/29341ee01efb317febc2cc69c34c9394 to your computer and use it in GitHub Desktop.
Npyscreen example 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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