Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with the input
#1
Hello everyone!

I'm making a script with allows my users to visualize what they are typing.
I need to ask them to write down their emails and I'm having a problem with visualizing the at sign: @

I tried
if ‘@’ in keys:
…email.text = email.text+ ‘@’
and
if ‘At’ in keys:
…email.text = email.text+ ‘@’
but it is not working...
Reply
#2
not clear what you are having problem with

>>> user = 'marios'
>>> user + '@'
'marios@'
or better - using f-strings (string-formatting)

>>> email = f'{user}@python-forum.io'
>>> email
'[email protected]'
please post minimal reproducible example. If you get any traceback - post it in full, in error tags
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Thanks a lot for your reply!

I have a code element which allows my users to type something on the keyboard and see what they are typing on the screen.

keys = event.getKeys()
if len(keys):
    if 'space' in keys:
        some.text = some.text + ' '
    elif 'backspace' in keys:
        some.text = some.text[:-1]
    elif 'lshift' in keys or 'rshift' in keys:
        modify = True
    else:
        if modify:
            some.text = some.text + keys[0].upper()
            modify = False
        else:
            some.text = some.text + keys[0]
I need to modify it so they can type and see on the screen their emails (and not just letters or numbers). I try adding those two lines in my code:

    elif 'at' in keys:
        age.text = age.text + '@'
But although I do not get any error message, if I try to type the @, it is not visualized on the screen. So I wonder how can I correctly code it?
Reply
#4
Sorry, but really it's not clear what you are doing. is it GUI? Or webapp? Or something else? What is code element? What is event? What exactly see what they are typing on the screen should mean - i.e. normally when you take user input user can see what they type? Where do you display anything? What OS, what python version and so on and so on....
Please, provide minimal runable example that we can run and reproduce the problem
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
I'm working with Psychopy (https://www.psychopy.org/), it's a code element in PsychoPy
The example of this code element can be found here:
https://gitlab.pavlovia.org/demos/textinput
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  problem in using input command akbarza 4 1,103 Oct-19-2023, 03:27 PM
Last Post: popejose
  problem in entering address of a file in input akbarza 0 648 Oct-18-2023, 08:16 AM
Last Post: akbarza
  Problem with input after function luilong 10 4,075 Dec-04-2021, 12:16 AM
Last Post: luilong
  Problem restricting user input in my rock paper scissors game ashergreen 6 4,590 Mar-25-2021, 03:54 AM
Last Post: deanhystad
  single input infinite output problem Chase91 2 1,935 Sep-23-2020, 10:01 PM
Last Post: Chase91
  Problem using input in Dictionary.. Help roseojha 1 1,776 Aug-25-2019, 08:51 AM
Last Post: ThomasL
  simple string & input problem kungshamji 5 3,647 Jun-23-2019, 03:54 PM
Last Post: kungshamji

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020