cleaning up screen drawing

master
endorphant 2016-05-01 14:10:04 -04:00
parent a931bc09ea
commit 5f3085c337
1 changed files with 34 additions and 24 deletions

View File

@ -1,14 +1,12 @@
#!/usr/bin/python #!/usr/bin/python
#import core
import os import os
import random import random
import tempfile import tempfile
import subprocess import subprocess
import time import time
import core #import core
import chatter import chatter
SOURCE = os.path.join("/home", "endorphant", "projects", "ttbp", "bin") SOURCE = os.path.join("/home", "endorphant", "projects", "ttbp", "bin")
@ -21,28 +19,37 @@ CONFIG = os.path.join(PATH, "config")
DATA = os.path.join(PATH, "entries") DATA = os.path.join(PATH, "entries")
FEEDBACK = os.path.join("/home", "endorphant", "ttbp-mail") FEEDBACK = os.path.join("/home", "endorphant", "ttbp-mail")
BANNER = open(os.path.join(SOURCE, "banner.txt")).read() BANNER = open(os.path.join(SOURCE, "config", "banner.txt")).read()
#CLOSER = "\n\tsee you later, space cowboy..." #CLOSER = "\n\tsee you later, space cowboy..."
SPACER = "\n\n\n" SPACER = "\n\n\n"
INVALID = "\n\nplease pick a number from the list of options!\n\n" INVALID = "please pick a number from the list of options!\n\n"
DUST = "\n\nsorry about the dust, but this part is still under construction. check back later!\n\n" DUST = "sorry about the dust, but this part is still under construction. check back later!\n\n"
##
def redraw(leftover=""):
os.system("clear")
print(BANNER)
print(SPACER)
if leftover:
print("> "+leftover+"\n")
def start(): def start():
os.system("clear") redraw()
print(BANNER)
#print(chatter.say("greet")+", "+chatter.say("friend")) #print(chatter.say("greet")+", "+chatter.say("friend"))
#print("(remember, you can always press ctrl-c to come home)\n") #print("(remember, you can always press ctrl-c to come home)\n")
print("if you don't want to be here at any point, press ctrl-d and it'll all go away.\njust keep in mind that you might lose anything you've started here.\n") print("if you don't want to be here at any point, press ctrl-d and it'll all go away.\njust keep in mind that you might lose anything you've started here.\n")
print(check_init()) print(check_init())
try: try:
redraw()
print(main_menu()) print(main_menu())
except ValueError or SyntaxError: except ValueError or SyntaxError:
print("\n\noh no i didn't understand that") redraw("\n\noh no i didn't understand that")
print(main_menu()) print(main_menu())
except KeyboardInterrupt: except KeyboardInterrupt:
print("\n\neject button fired") redraw("\n\neject button fired")
print(main_menu()) print(main_menu())
def stop(): def stop():
@ -50,13 +57,13 @@ def stop():
def check_init(): def check_init():
if os.path.exists(os.path.join(os.path.expanduser("~"),".ttbp")): if os.path.exists(os.path.join(os.path.expanduser("~"),".ttbp")):
raw_input("welcome back, "+USER+".\n\npress enter to explore your feelings.") raw_input("welcome back, "+USER+".\n\npress enter to explore your feelings.\n\n")
return "" return ""
else: else:
return init() return init()
def init(): def init():
raw_input("i don't recognize you, stranger. let's make friends someday.\n\npress enter to explore some options.") raw_input("i don't recognize you, stranger. let's make friends someday.\n\npress enter to explore some options.\n\n")
return "" return ""
## menus ## menus
@ -73,10 +80,11 @@ def print_menu(menu):
i += 1 i += 1
def main_menu(): def main_menu():
os.system("clear") #os.system("clear")
print(BANNER) #print(BANNER)
#redraw()
menuOptions = ["record feelings", "check out neighbors","send feedback"] menuOptions = ["record feelings", "check out neighbors","send feedback"]
print(SPACER) #print(SPACER)
print("you're at ttbp home now. remember, you can always press ctrl-c to come back here.\n\n") print("you're at ttbp home now. remember, you can always press ctrl-c to come back here.\n\n")
print_menu(menuOptions) print_menu(menuOptions)
#print("how are you feeling today? ") #print("how are you feeling today? ")
@ -84,32 +92,34 @@ def main_menu():
choice = raw_input("\ntell me about your feels (enter 'none' to quit): ") choice = raw_input("\ntell me about your feels (enter 'none' to quit): ")
if choice == '0': if choice == '0':
print(DUST) redraw(DUST)
elif choice == '1': elif choice == '1':
print(DUST) redraw(DUST)
elif choice == '2': elif choice == '2':
print(feedback_menu()) redraw()
feedback_menu()
elif choice == "none": elif choice == "none":
return stop() return stop()
else: else:
print(INVALID) redraw(INVALID)
return main_menu() return main_menu()
def feedback_menu(): def feedback_menu():
print("sends mail to ~endorphant about ttbp\n\n") print("you're about to send mail to ~endorphant about ttbp\n\n")
menuOptions = ["bug report", "feature suggestion", "general feedback"] menuOptions = ["bug report", "feature suggestion", "general comment"]
print(SPACER)
print_menu(menuOptions) print_menu(menuOptions)
choice = raw_input("\npick a category for your feedback: ") choice = raw_input("\npick a category for your feedback: ")
cat = "" cat = ""
if choice in ['0', '1', '2']: if choice in ['0', '1', '2']:
cat = menuOptions[int(choice)] cat = menuOptions[int(choice)]
return send_feedback(cat) raw_input("\ncomposing a "+cat+" to ~endorphant.\n\npress enter to open an external text editor. mail will be sent once you save and quit.\n")
redraw(send_feedback(cat))
return
else: else:
print(INVALID) redraw(INVALID)
return feedback_menu() return feedback_menu()