1

I was shown this cool technique earlier this evening thanks to another member on stackoverflow. I am a beginner at python, so most of my learning is done through reading this book I have and editing code to see how it would work.

I'm trying to design this for the bottom of the menu:

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X  TASK1  X  TASK2  X  TASK3  X  TASK4  X  TASK5  X
X   [ ]   X   [ ]   X   [ ]   X   [ ]   X   [ ]   X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

So you basically see this:

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X                                                 X
X          TASK MANAGER - TASK SELECTION          X
X                                                 X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X                                                 X
X                 READY TO START?                 X
X              ---------------------              X
X                PRESS THE 'ENTER'                X
X                  KEY TO BEGIN!                  X
X              ---------------------              X
X                                                 X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X  TASK1  X  TASK2  X  TASK3  X  TASK4  X  TASK5  X
X   [ ]   X   [ ]   X   [ ]   X   [ ]   X   [ ]   X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The purpose of the bottom part would be that if you select say task 2, it would then just print a function for whichever is selected...so it would be (if task 2 selected):

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X                                                 X
X          TASK MANAGER - TASK SELECTION          X
X                                                 X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X                                                 X
X                 READY TO START?                 X
X              ---------------------              X
X                PRESS THE 'ENTER'                X
X                  KEY TO BEGIN!                  X
X              ---------------------              X
X                                                 X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X  TASK1  X  TASK2  X  TASK3  X  TASK4  X  TASK5  X
X   [ ]   X   [X]   X   [ ]   X   [ ]   X   [ ]   X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Here is the current code:

def printLine (text = ''):
    print('X {: ^47} X'.format(text))

def printSelTitle (text = '', title = None):
    print('X{: ^9}'.format(text)),

def printSelCheck (text = '', title = None):
    print('X   [ ]   X'.format(text)),

def printBorder (title = None):
    print('X' * 51)

def printBox (*lines, title = None, showBottomBorder = False):
    printBorder(title)
    printLine()
    for line in lines:
        printLine(line)
    printLine()
    if showBottomBorder:
        printBorder()

printBox('TASK MANAGER - TASK SELECTION')
printBox('READY TO START?', '-' * 21, "PRESS THE 'ENTER'",\
         'KEY TO BEGIN!', '-' * 21, showBottomBorder = True)
printSelTitle('TASK1') and printSelTitle('TASK2')
printSelCheck()
printBorder()

printSelTitle('TASK3')
printSelTitle('TASK4')
printSelTitle('TASK5')

Here is what the current code looks like:

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X                                                 X
X          TASK MANAGER - TASK SELECTION          X
X                                                 X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X                                                 X
X                 READY TO START?                 X
X              ---------------------              X
X                PRESS THE 'ENTER'                X
X                  KEY TO BEGIN!                  X
X              ---------------------              X
X                                                 X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X  TASK1  
X   [ ]   X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X  TASK3  
X  TASK4  
X  TASK5

Any thoughts? Thanks in advance for any help.

Best,

Steven

2 Answers 2

3

If you want no newline after print, don't use print(aasd), (this is tuple construction), but print('123', end='')

Printing syntax differences: Python 2.x:

print "1", # special syntax for print statement
print "2"

Puthon 3:

print("1", end="") # actually returns None (print() is a function)
print("2")

Result in both cases:12

Python 3 (interactive shell):

>>> a = print('123')
123
>>> repr(a)
'None'
>>> a = print('123'),
123 # newline presents
>>> repr(a)
'(None,)' # result is tuple constructed by comma
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. That helped me figure something out.
0

Here is the Code:

def printLine (text = ''):
    print('X {: ^47} X'.format(text))

def printSelTitle (text = '', title = None):
    print('X{: ^9}'.format(text), end = ""),

def printSelCheck (text = '', title = None):
    print('X   [ ]   '.format(text), end = "")

def printBorder (title = None):
    print('X' * 51)

def printBox (*lines, title = None, showBottomBorder = False):
    printBorder(title)
    printLine()
    for line in lines:
        printLine(line)
    printLine()
    if showBottomBorder:
        printBorder()

printBox('TASK MANAGER - TASK SELECTION')
printBox('READY TO START?', '-' * 21, "PRESS THE 'ENTER'",\
         'KEY TO BEGIN!', '-' * 21, showBottomBorder = True)
printSelTitle('TASK1'), printSelTitle('TASK2'),\
        printSelTitle('TASK3'), printSelTitle('TASK4'),\
        printSelTitle('TASK5'), print("X")
printSelCheck(), printSelCheck(), printSelCheck(),\
                 printSelCheck(), printSelCheck(), print("X")
printBorder() 

Here is what it looks like:

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X                                                 X
X          TASK MANAGER - TASK SELECTION          X
X                                                 X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X                                                 X
X                 READY TO START?                 X
X              ---------------------              X
X                PRESS THE 'ENTER'                X
X                  KEY TO BEGIN!                  X
X              ---------------------              X
X                                                 X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X  TASK1  X  TASK2  X  TASK3  X  TASK4  X  TASK5  X
X   [ ]   X   [ ]   X   [ ]   X   [ ]   X   [ ]   X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Still trying to layout how I would make the 'X' on select....but I'll look further into it.

3 Comments

def printSelCheck(text = '', title = None): \\ print('X [{0}] '.format(text), end = "")
Thanks! What do I read up on how to effect the result of {0}?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.