lagt til 'cs' for clear screen i hovedmenyen

This commit is contained in:
Trygve Magnus Ræder 2011-03-07 09:01:43 +00:00
parent d7fb30e0c1
commit 4c5404389f
2 changed files with 19 additions and 6 deletions

BIN
data

Binary file not shown.

View File

@ -6,8 +6,10 @@ from sqlalchemy.sql import func
from sqlalchemy import desc from sqlalchemy import desc
import re, sys, os, traceback, signal, readline import re, sys, os, traceback, signal, readline
from helpers import * from helpers import *
import random
random.seed()
exit_commands = ['exit', 'abort', 'quit', 'bye', 'eat flaming death', 'q'] exit_commands = ['exit', 'abort', 'quit', 'bye', 'eat flaming death', 'q']
help_commands = ['help', '?'] help_commands = ['help', '?']
context_commands = ['what', '??'] context_commands = ['what', '??']
@ -168,7 +170,16 @@ class Menu():
result = self.input_str(prompt) result = self.input_str(prompt)
if result == '': if result == '':
print 'Please enter something' print 'Please enter something'
# 'c' i hovedmenyen for å endre farger
elif result == 'c':
os.system('echo -e "\033['+str(random.randint(40,49))+';'+str(random.randint(30,37))+';5m"')
os.system('clear')
return None
# 'cs' i hovedmenyen for å sette standardfarger
elif result == 'cs':
os.system('echo -e "\033[0m"')
os.system('clear')
return None
else: else:
try: try:
choice = int(result) choice = int(result)
@ -389,11 +400,13 @@ it by putting money in the box and using the "Adjust credit" menu.
return None return None
for i in range(len(self.items)): for i in range(len(self.items)):
self.printc(line_format % (i+1, self.item_name(i))) self.printc(line_format % (i+1, self.item_name(i)))
item_i = self.input_choice(len(self.items), prompt=self.prompt)-1 item_i = self.input_choice(len(self.items), prompt=self.prompt)
if self.item_is_submenu(item_i): if item_i==None:
self.items[item_i].execute() return self.execute()
if self.item_is_submenu(item_i-1):
self.items[item_i-1].execute()
else: else:
return self.item_value(item_i) return self.item_value(item_i-1)
class Selector(Menu): class Selector(Menu):