RSS Forums RSS
Please support our Python advertiser: Programming Forums
Views: 1867 | Replies: 2
Reply
Join Date: Feb 2006
Posts: 43
Reputation: butterflyTee is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
butterflyTee butterflyTee is offline Offline
Light Poster

Help TURN THIS ASSIGNMENT UserID INTO GUI, CAN YOU HELP ME

  #1  
Mar 7th, 2006
Did I do this right and can you please help me. This program uses a GUI to input a user's first and last name,
and construct and display a UserID. Although the program 'runs',
there are several problems with it. Fix each of these problems
in turn:

1) The text and corresponding entry box for 'Last Name' does
not align with those for 'First Name'. Correct this.
2) Provide the code to draw a Rectangle around the 'button'
text object, so that it looks like a button.
3) The program as written always produces the same UserID, 'frodo'.
Change this so the UserID will be the first six letters of the
last name and the first character of the first name, all in
lowercase. For example, if the user entered 'Bilbo' and 'Baggins'
for first and last names, respectively, his UserId would be
'bagginb'. [Hint: you may want to use the lower() function is
the string library for this.]
4) Add the code necessary to change the text of the button text
object to 'Quit' after the UserID has been displayed :o :o


from graphics import * 

def main(): 

win = GraphWin("UserID Assignment", 400, 300) 
win.setCoords(0,0, 4,3) 

# draw the interface 
Text(Point(0.5, 2.5), "First Name").draw(win) 
Text(Point(0.8, 1.7), " Last Name").draw(win) 
fName = Entry(Point(2.0, 2.5), 20) 
fName.setText("") 
fName.draw(win) 
lName = Entry(Point(2.5, 2.0), 20) 
fName.setText("") 
lName.draw(win) 
button = Text(Point(2.0, 1.0), "Get UserID") 
button.draw(win) 

output = Text(Point(2.0, 0.3), \ 
"Enter your name and click 'Get UserID'") 
output.draw(win) 

# wait for mouse click 
win.getMouse() 

# obtain input and construct userid 
first = fName.getText() 
last = lName.getText() 
userid = "frodo" 

# display result 
output.setText("Your UserID is " + userid + ".") 

# all done 
win.getMouse() 
win.close() 

main()
Last edited by vegaseat : Mar 8th, 2006 at 2:21 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2004
Posts: 2,541
Reputation: vegaseat will become famous soon enough vegaseat will become famous soon enough 
Rep Power: 11
Solved Threads: 178
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: TURN THIS ASSIGNMENT UserID INTO GUI, CAN YOU HELP ME

  #2  
Mar 8th, 2006
The module "graphics" is foreign to me. Is this something your teacher has writtten?

Also everything belonging to function main() should be indented properly!

Replace
userid = "frodo"
with
userid = last.lower()[:6] + first.lower()[:1]
May 'the Google' be with you!
Reply With Quote  
Join Date: Apr 2006
Posts: 7
Reputation: mechdriver is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mechdriver mechdriver is offline Offline
Newbie Poster

Re: TURN THIS ASSIGNMENT UserID INTO GUI, CAN YOU HELP ME

  #3  
Apr 3rd, 2006
im only in the 8th grade srry
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:36 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC