1

On simplegui I want there to be an input box called login_gui that puts the data from the input into the variable login_variable, not into a defined function.

import simplegui
frame = simplegui.create_frame("screen", 500, 500)
login_gui = frame.add_input("Login?", login_variable, 20)
 ..something with login_variable

Is there any way to do this, or is it only with defined functions that this works?

L0neGamer
  • 275
  • 3
  • 13

3 Answers3

1

I don't know. But using tkinter or pyside is very simple and then you have all options avaliable.

updated with an example

Basically pyside is better, but tkinter works out of the box. If you just want a simple gui, just use tkinter

from Tkinter import *

def go():
    print E1.get()
top = Tk()
L1 = Label(top, text="User Name")
L1.pack()
E1 = Entry(top, bd =5)
E1.pack()

But = Button(top, text="go", command=go)
But.pack()
top.mainloop()
Svend Feldt
  • 758
  • 4
  • 17
  • This question is specifically about how to do something with SimpleGui. Suggesting alternate toolkits isn't very helpful. – Bryan Oakley Feb 03 '14 at 16:08
  • I disagree. The asker of the question might not know that other and potential better tools are avaliable. I would be happy if someone pointed me to a better tool. I use Python because it's a better tool that Windows bat files. .. – Svend Feldt Feb 03 '14 at 16:41
  • @Cyrex could you provide links to the documentation of both? I can't find the Tkinter one and I don't fully understand the Pyside one yet – L0neGamer Feb 03 '14 at 16:51
  • Added tkinter example – Svend Feldt Feb 03 '14 at 18:35
0

You can retrieve the input string by calling the get_text() method of the variable that is assigned to the input field.

login_variable = login_gui.get_text()

Please note that you will still have to define an input handler function somewhere, but can leave it blank (and do not name it login_variable as you're using it to store the input text)

def input_handler(input):
     pass

login_gui = frame.add_input("Login?", input_handler, 20)

Source: SimpleGui documentation.

Islay
  • 478
  • 4
  • 17
0

you can just call the box with name and use it

name = enterbox("Enter the company name:", "Name") msgbox("Hello " + name) # will show what you entered

Salwa
  • 81
  • 9