git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GUI, Python2.7- how to build a loop with a button + textbox


On Tue, 11 Sep 2018 19:51:01 -0700 (PDT), alon.najman at gmail.com wrote:
> hi,
>
> on python 2.7 how do I build a loop with a button + textbox?
>
> for example:
>
> I want the user to enter is name and then press "ok" button, I want
> his name to be printed 5 times.

Tested on Python 3.5.3:

import browsergui as bg

def button_clicked():
    for i in range(5):
        print(text_field.value)
                       
text_field = bg.TextField()
bg.GUI(text_field, bg.Button("OK", callback=button_clicked)).run(quiet=True)

If you don't have browsergui, "pip install browsergui".

-- 
To email me, substitute nowhere->runbox, invalid->com.