User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » Python question Page [1]  
Spontaneous
All American
27372 Posts
user info
edit post

Trying to make an app for work that sends User IDs and Passwords from our server. Would like the ability to click on a "Submit" button or to just press enter at the e-mail field.

This code does not work:


def MakeEmail():
usernameID = UIDName.get()
passwordID = PWName.get()
emailAddress = EMailName.get()

...

EMailText = StringVar()
EMailText.set("E-Mail Address")
EMail1 = Label(app, textvariable=EMailText, height=4)
EMail1.pack()


EMail = StringVar(None)
EMailName = Entry(app, textvariable=EMail, width=50)
EMailName.bind("", MakeEmail)
EMailName.pack()


button1 = Button(app, text="Submit", width=20, command=MakeEmail)
button1.pack(side='bottom',padx=15,pady=15)


app.mainloop()


Bind sends one argument while command sends none. How do I reconcile this?

5/23/2012 5:40:43 PM

ctnz71
All American
7207 Posts
user info
edit post

unplug power cord and plug it back in?

5/23/2012 6:14:01 PM

lewisje
All American
9196 Posts
user info
edit post

You should use the code tags to enforce indentation:

def MakeEmail():
usernameID = UIDName.get()
passwordID = PWName.get()
emailAddress = EMailName.get()

...

EMailText = StringVar()
EMailText.set("E-Mail Address")
EMail1 = Label(app, textvariable=EMailText, height=4)
EMail1.pack()


EMail = StringVar(None)
EMailName = Entry(app, textvariable=EMail, width=50)
EMailName.bind("", MakeEmail)
EMailName.pack()


button1 = Button(app, text="Submit", width=20, command=MakeEmail)
button1.pack(side='bottom',padx=15,pady=15)


app.mainloop()
At least I think this is what you meant.

Anyway, what frameworks or libraries (if any) are you using?

5/23/2012 7:17:36 PM

Spontaneous
All American
27372 Posts
user info
edit post

Fuck, I'm retarded.

Tkinter.

5/25/2012 4:16:55 PM

CapnObvious
All American
5057 Posts
user info
edit post

I've just started some work with Tkinter myself. I'm still new with some of the terminology, so bare with me if I give some goofy info.

You can use 'lambda' to make certain sections do more. For instance, the button 'command' call can only call a function without arguments by default; however, you can use 'lambda' to get around that. For instance, you could say:


command=lambda: somefunction(arg1, arg2, arg3)

Also, if you are having trouble with calling a functions two ways, but with different parameters, you can use default values:

def SomeFunc(arg1, arg2, arg3="Default"):

So this can be called in the following ways:

SomeFunc(5, 1)
SomeFunc(5, 1, arg3="SomethingElse")
SomeFunc(arg1=5, arg2=1, arg3="SomethingElse")

Hopefully I didn't misunderstand you.

[Edited on May 29, 2012 at 11:54 AM. Reason : ]

5/29/2012 11:52:59 AM

 Message Boards » Tech Talk » Python question Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.38 - our disclaimer.