The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
Password Input
Discuss Password Input in the Python Programming forum on Dev Shed. Password Input Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 29th, 2012, 02:49 PM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 18
Time spent in forums: 14 h 30 m 46 sec
Reputation Power: 0
|
|
|
Password Input
I'm currently doing my coursework for computing, and currently I'm making a registration section.
What I'm struggling with is getting the input entry to show Astrix's or circles.
I'm using the module graphics.
Code:
from graphics import *
import urllib.request, re
def Login():
LoginScreen = GraphWin("Login",300,100)
file = open("users.csv","r")
readfile = file.read()
UsernameLabel = Text(Point(45,25),"Username: ")
UsernameLabel.draw(LoginScreen)
UsernameText = Entry(Point(158,25),16)
UsernameText.draw(LoginScreen)
username = ''
LoginScreen.getMouse()
LoginScreen.close()
def Register():
RegisterScreen = GraphWin("Register",300,150)
UsernameRegLabel = Text(Point(45,25),"Username: ")
UsernameRegLabel.draw(RegisterScreen)
UsernameRegText = Entry(Point(158,25),16)
UsernameRegText.draw(RegisterScreen)
PasswordRegLabel = Text(Point(45,50),"Password: ")
PasswordRegLabel.draw(RegisterScreen)
PasswordRegText = Entry(Point(158,50),16)
PasswordRegText.draw(RegisterScreen)
RegisterScreen.getMouse()
RegisterScreen.close()
def GetMouse():
p = MainWin.getMouse()
x = p.getX()
y = p.getY()
print(x)
print(y)
if x>=197 and x<=260:
if y>=230 and y<=250:
Login()
if x>=197 and x<=297:
if y>=260 and y<=285:
Register()
def DrawBackground():
return
def DrawMenuItems():
Main = Text(Point(300,200),"Main Menu")
Main.setSize(32)
Main.draw(MainWin)
Login = Text(Point(228,240),"Login")
Login.setSize(20)
Login.draw(MainWin)
Register = Text(Point(245,270),"Register")
Register.setSize(20)
Register.draw(MainWin)
MainWin = GraphWin("Fantasy Football",600,600)
DrawBackground()
DrawMenuItems()
while True:
GetMouse()
The bit I'm struggling with is
Code:
PasswordRegText = Entry(Point(158,50),16)
PasswordRegText.draw(RegisterScreen)
How do I get it to show circles or Asterixs?
|

November 29th, 2012, 04:20 PM
|
 |
Contributing User
|
|
|
|
|
asterisk.
Use this symbol:
⍟
In base 10 the unicode number is 9055.
__________________
[code] Code tags[/code] are essential for python code!
|

November 29th, 2012, 07:38 PM
|
|
Contributing User
|
|
Join Date: May 2009
Posts: 294
  
Time spent in forums: 3 Days 18 h 55 m 26 sec
Reputation Power: 7
|
|
If you want * in the box you can use setText. If you want each character entered to show as an asterisk, I don't think the graphics module can do that. Look at the "show=" option in Tkinter's entry box.
Code:
from Tkinter import *
class PasswordGetter:
def __init__(self):
self.root = Tk()
frame = Frame(self.root)
lbl = Label(frame, text="Username ")
lbl.grid(row=0, column=0, stick=N+E+S+W)
self.user_name = StringVar()
self.username_entry = Entry(frame, width=20, \
textvariable=self.user_name)
self.username_entry.grid(row=0, column=1, stick=N+E+S+W)
lbl = Label(frame, text="Password ")
lbl.grid(row=1, column=0, stick=N+E+S+W)
self.passw = StringVar()
self.password_entry = Entry(frame, show="*", width=20, textvariable=self.passw
self.password_entry.grid(row=1, column=1, stick=N+E+S+W)
login_button = Button(text="Login",
command=self.buttonCallback)
login_button = Button(text="Login",
command=self.buttonCallback)
login_button.grid(row=2, columnspan=2, stick=N+E+S+W)
frame.grid(row=0, padx=2, pady=2, stick=N+E+S+W)
self.root.mainloop()
def buttonCallback(self):
print self.user_name.get(), self.passw.get()
self.root.destroy()
if __name__ == "__main__":
pg = PasswordGetter()
|

November 29th, 2012, 07:41 PM
|
|
Contributing User
|
|
Join Date: May 2009
Posts: 294
  
Time spent in forums: 3 Days 18 h 55 m 26 sec
Reputation Power: 7
|
|
You can use setText to set the text shown in an Entry box. If you want each character entered to display as an * I don't think the Graphics module can do that. Look at the "show=" option in the Tkinter entry box.
Code:
class PasswordGetter:
def __init__(self):
self.root = Tk()
frame = Frame(self.root)
lbl = Label(frame, text="Username ")
lbl.grid(row=0, column=0, stick=N+E+S+W)
self.user_name = StringVar()
self.username_entry = Entry(frame, width=20, \
textvariable=self.user_name)
self.username_entry.grid(row=0, column=1, stick=N+E+S+W)
lbl = Label(frame, text="Password ")
lbl.grid(row=1, column=0, stick=N+E+S+W)
self.passw = StringVar()
self.password_entry = Entry(frame, show="*", width=20, textvariable=self.passw)
self.password_entry.grid(row=1, column=1, stick=N+E+S+W)
login_button = Button(text="Login",
command=self.buttonCallback)
login_button.grid(row=2, columnspan=2, stick=N+E+S+W)
frame.grid(row=0, padx=2, pady=2, stick=N+E+S+W)
self.root.mainloop()
def buttonCallback(self):
print self.user_name.get(), self.passw.get()
self.root.destroy()
if __name__ == "__main__":
pg = PasswordGetter()
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|