0

Soo, How can I have text display after an input()?

I'll explain with an example:

import os

docname = input(f"Where do you wanna save your document? {os.path.dirname(os.path.realpath(__file__))\\images\\")

As user is typing, the .pdf extension is after what they typed (am not native English)

Where do you wanna save your document? C:\Users\Public\Downloads\project\(here user can type).pdf

(I don't worry about the extention; docname = docname + ".pdf"

I saw this question, but that doesnt answer my question (This isn't a duplicate of that, because that doesnt appear as I type). Here's how far i've came:

text = f"File destination: {os.path.dirname(os.path.realpath(__file__))}\\images\\"
while True:
    answer = input(text)
    fileExtension = ".pdf"
    while not answer:
        pass
        # print(f"\33[1A\33[{len(fileExtension)}C {fileExtension}")
        # print("\033[A\033[A")
    else:
        break

The main problems are that:

  1. This doesnt run lol
  2. I can't (or don't know how to) identify the length of characters as user is typing. Also, I dunno if I would need it, but it's probably needed to determine if it has to print(f"\33[1A\33[{len(input)}]C)
  3. The while loop doesn't appear as the input is running. If I would do more research, I maybe will figure out how to run 2 lines at the same time, but then there's gonna be a way more simple answer.
  4. Even if I had all of these together, would it run at all? Or is the cursor jumping left and right without any possible input
tygo
  • 23
  • 4
  • Can you explain clearly what you trying to do? – stofu Sep 18 '22 at 13:40
  • I'm trying to download jpg's (```requests```), merge them into a pdf (```Pillow```) and download it. I'm done with everything, but this helps specifying the destination _user_ wants to the pdf to – tygo Sep 18 '22 at 13:53
  • No, I thought of every way I could come up with in using that, and I think I _can_ use it, but the problem is; I don't know how I could implement it. I want the extension to appear _as the user types_, which I don't know how to succeed. – tygo Sep 18 '22 at 15:32

0 Answers0