0

So for homework I just had to make an ATM GUI which i did, but i wanted to mess around and make it actually work so that when i selected the number it showed something different.

    print('\t\t\t\t|-------------------------------|')
    print('\t\t\t\t|        LCCS BANK LIMITED      |')
    print('\t\t\t\t|        ATM Main Menu          |')
    print('\t\t\t\t|                               |')
    print('\t\t\t\t|       1. Balance Enquiry      |')
    print('\t\t\t\t|       2. Cash Lodgement       |')
    print('\t\t\t\t|       3. Cash Withdrawal      |')
    print('\t\t\t\t|       4. Cash Transfer        |')
    print('\t\t\t\t|       5. Change PIN           |')
    print('\t\t\t\t|       6. Other Services       |')
    print('\t\t\t\t|                               |')
    print('\t\t\t\t|       7. Exit                 |')
    print('\t\t\t\t|-------------------------------|')
    print('\t\t\t\t|                               |')
    print('\t\t\t\t|   CHOOSE AN OPTION >>         |')
    print('\t\t\t\t|                               |')
    print('\t\t\t\t|-------------------------------|')


print('\t\t\t\t|-------------------------------|')
print('\t\t\t\t|        LCCS BANK LIMITED      |')
print('\t\t\t\t|        ATM Main Menu          |')
print('\t\t\t\t|                               |')
print('\t\t\t\t|       1. Balance Enquiry      |')
print('\t\t\t\t|       2. Cash Lodgement       |')
print('\t\t\t\t|       3. Cash Withdrawal      |')
print('\t\t\t\t|       4. Cash Transfer        |')
print('\t\t\t\t|       5. Change PIN           |')
print('\t\t\t\t|       6. Other Services       |')
print('\t\t\t\t|                               |')
print('\t\t\t\t|       7. Exit                 |')
print('\t\t\t\t|-------------------------------|')
print('\t\t\t\t|                               |')
option = input('\t\t\t\t|   CHOOSE AN OPTION >>         |')
print('\t\t\t\t|                               |')
print('\t\t\t\t|-------------------------------|')

The problem is when I use input before print. I want the choose an option part to be an input but still have the rest of the GUI printed without typing anything yet so that it doesnt look weird. Thats the shell below, im new to python and programming btw any help would be appreciated thanks!, And im sorry if this looks messy or confusing.

            |-------------------------------|
            |        LCCS BANK LIMITED      |
            |        ATM Main Menu          |
            |                               |
            |       1. Balance Enquiry      |
            |       2. Cash Lodgement       |
            |       3. Cash Withdrawal      |
            |       4. Cash Transfer        |
            |       5. Change PIN           |
            |       6. Other Services       |
            |                               |
            |       7. Exit                 |
            |-------------------------------|
            |                               |
            |   CHOOSE AN OPTION >>         |
Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
  • 1
    Such advanced functionalities need the `curses` module (part of Python standard library for Unix-based systems) – Michael Butscher Sep 07 '18 at 23:12
  • Basically, you will need to reposition the cursor back to the place you want input to appear. This gets into some non-trivial code pretty quickly. The [curses](https://docs.python.org/3/library/curses.html) module provides some low-level functionality for that. You can also use an easer library such as [urwid](http://urwid.org/). – Keith Sep 08 '18 at 00:13
  • Thanks guys, I guess asking questions and experimenting will help me learn more, ill watch a video on the curses module – Zoheb Saiyed Sep 08 '18 at 11:06

1 Answers1

0

If I understand the question correctly, you want the cursor to remain after the 'CHOOSE AN OPTION >>' while having the rest print before the user's input? This is possible but also pretty complicated. Here is a similar question to yours, but as you can see, it gets pretty complicated pretty quickly.

If you want to keep it relatively simply, you could do something like follows:

print("""
\t\t\t\t|-------------------------------|
\t\t\t\t|        LCCS BANK LIMITED      |
\t\t\t\t|        ATM Main Menu          |
\t\t\t\t|                               |
\t\t\t\t|       1. Balance Enquiry      |
\t\t\t\t|       2. Cash Lodgement       |
\t\t\t\t|       3. Cash Withdrawal      |
\t\t\t\t|       4. Cash Transfer        |
\t\t\t\t|       5. Change PIN           |
\t\t\t\t|       6. Other Services       |
\t\t\t\t|                               |
\t\t\t\t|       7. Exit                 |
\t\t\t\t|                               |
\t\t\t\t|   CHOOSE AN OPTION >>         |
\t\t\t\t|                               |
\t\t\t\t|-------------------------------|
""")
option = input()

print("""
\t\t\t\t|-------------------------------|
\t\t\t\t|        LCCS BANK LIMITED      |
\t\t\t\t|        ATM Main Menu          |
\t\t\t\t|                               |
\t\t\t\t|       1. Balance Enquiry      |
\t\t\t\t|       2. Cash Lodgement       |
\t\t\t\t|       3. Cash Withdrawal      |
\t\t\t\t|       4. Cash Transfer        |
\t\t\t\t|       5. Change PIN           |
\t\t\t\t|       6. Other Services       |
\t\t\t\t|                               |
\t\t\t\t|       7. Exit                 |
\t\t\t\t|                               |
\t\t\t\t|   CHOOSE AN OPTION >> {0}       |
\t\t\t\t|                               |
\t\t\t\t|-------------------------------|
""".format(option))

which would give the output of:

            |-------------------------------|
            |        LCCS BANK LIMITED      |
            |        ATM Main Menu          |
            |                               |
            |       1. Balance Enquiry      |
            |       2. Cash Lodgement       |
            |       3. Cash Withdrawal      |
            |       4. Cash Transfer        |
            |       5. Change PIN           |
            |       6. Other Services       |
            |                               |
            |       7. Exit                 |
            |                               |
            |   CHOOSE AN OPTION >>         |
            |                               |
            |-------------------------------|

 1
        |-------------------------------|
        |        LCCS BANK LIMITED      |
        |        ATM Main Menu          |
        |                               |
        |       1. Balance Enquiry      |
        |       2. Cash Lodgement       |
        |       3. Cash Withdrawal      |
        |       4. Cash Transfer        |
        |       5. Change PIN           |
        |       6. Other Services       |
        |                               |
        |       7. Exit                 |
        |                               |
        |   CHOOSE AN OPTION >> 1       |
        |                               |
        |-------------------------------|
C. Fennell
  • 992
  • 12
  • 20
  • thanks for the reply, I see used you used 3 quotation marks instead of typing print every single time, ill keep that in mind – Zoheb Saiyed Sep 08 '18 at 11:26