# How do i make a username input interface (python)?

**URL:** <https://discourse.processing.org/t/how-do-i-make-a-username-input-interface-python/15832>\
**Category:** Processing.py\
**Created:** [November 26, 2019, 12:44pm UTC](https://discourse.processing.org/t/how-do-i-make-a-username-input-interface-python/15832 "2019-11-26T12:44:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![esaem](https://avatars.discourse-cdn.com/v4/letter/e/f6c823/32.png) [@esaem](https://discourse.processing.org/u/esaem)\
**Post date:** [November 26, 2019, 12:44pm UTC](https://discourse.processing.org/t/how-do-i-make-a-username-input-interface-python/15832/1 "2019-11-26T12:44:45Z")

</div>

So i’m making a game in python processing and i need to have people input their names so it get’s attached to player 1 or player 2 etc…

 ![Naamloos](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/1aa54bf8060ec2ddfa975f74b7d9433897492aa2.png)

---

<div class="post-metadata">

**Author:** ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)\
**Post date:** [November 26, 2019, 12:54pm UTC](https://discourse.processing.org/t/how-do-i-make-a-username-input-interface-python/15832/2 "2019-11-26T12:54:01Z")

</div>

```auto
def setup():
    name = input('enter your name')
    println('hi ' + str(name))
 
def input(name=''):
    from javax.swing import JOptionPane
    return JOptionPane.showInputDialog(frame, name)

```

---

<div class="post-metadata">

**Author:** ![esaem](https://avatars.discourse-cdn.com/v4/letter/e/f6c823/32.png) [@esaem](https://discourse.processing.org/u/esaem)\
**Post date:** [November 26, 2019, 1:32pm UTC](https://discourse.processing.org/t/how-do-i-make-a-username-input-interface-python/15832/3 "2019-11-26T13:32:29Z")

</div>

Hey, i mean like it as shown in the image.

---

<div class="post-metadata">

**Author:** ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)\
**Post date:** [November 26, 2019, 3:25pm UTC](https://discourse.processing.org/t/how-do-i-make-a-username-input-interface-python/15832/4 "2019-11-26T15:25:04Z")

</div>

You can take a look at this, if you want the Textfield to be part of the sketch :

> **[Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussion/20882/very-basic-question-how-to-create-an-input-text-box)**
>
> Processing is an electronic sketchbook, a language and a worldwide community. This is its forum.

Or you can use JTextField, which is a lot simpler, but will open an external JFrame window to set your Input.

Something like this :

```auto
void setup() {

}

void draw() {

}

void askNames() {
   JFrame nameFrame = new JFrame();
   nameFrame.setTitle(„Input Names“);

   JPanel name1Panel = new JPanel();
   JPanel name2Panel = new JPanel();
   
   JLabel name1Label = new JLabel(„Name1“);

   JLabel name2Label = new JLabel(„Name2“);

   JTextField name1TextField = new JTextField(„Name 1“, 15);
   JTextField name2TextField = new JTextField(„Name 2“, 15);

   name1Panel.add(name1Label);
   name2Panel.add(name2Label);

   name1Panel.add(name1TextField);
   name2Panel.add(name2TextField);

   nameFrame.add(name1Panel);
   nameFrame.add(name2Panel);

   nameFrame.setVisible();
}

```

---

<div class="post-metadata">

**Author:** ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)\
**Post date:** [November 26, 2019, 7:52pm UTC](https://discourse.processing.org/t/how-do-i-make-a-username-input-interface-python/15832/5 "2019-11-26T19:52:09Z")

</div>

[ControlP5](https://tabreturn.github.io/code/processing/python/2019/03/19/processing.py_in_ten_lessons-7.5-_controlp5.html) is one option. Guido might be another.
