Advertisement
Inksaver

kboard class demo file

Oct 8th, 2020 (edited)
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. '''  This file needs kboard.py: https://pastebin.com/UceAJsaV '''
  2.  
  3. import kboard as kb # shortens the class name to kb
  4.  
  5. def main():
  6.     user_name = kb.get_string("Type your name", True, 3, 6)             # returns user input in Title Case
  7.     user_age = kb.get_integer("How old are you", 5, 120)                # gets an integer between 5 and 120 from the user
  8.     user_height = kb.get_float("How tall are you in metres?", 0.5, 2.5) # gets a float between 0.5 and 2.5 from the user
  9.     user_likes_python = kb.get_boolean("Do you like Python? (y/n)")     # returns True or False from the user
  10.    
  11.     print(f"User name : {user_name}")
  12.     print(f"User age : {user_age}")
  13.     print(f"User height : {user_height}")
  14.     print(f"User likes Python : {user_likes_python}")
  15.     print()
  16.     menu_list = ["Brilliant", "Not bad", "Could do better", "Rubbish"]
  17.     user_choice = kb.menu("What do think of this utility?", menu_list)
  18.     print(f"User thinks this utility is: {menu_list[user_choice]}")
  19.    
  20.     # if running from a console/terminal instead of an IDE to prevent closing.
  21.     kb.get_string("Press Enter to Quit", False, 0, 20) # Used instead of input("Press Enter to Quit")
  22.    
  23. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement