├── .idea ├── .gitignore ├── misc.xml ├── inspectionProfiles │ ├── profiles_settings.xml │ └── Project_Default.xml ├── modules.xml └── RandomUserGenerator.iml ├── app_icon.ico ├── app_icons ├── call.png ├── copy.png ├── email.png ├── anonymous.png ├── birthday.png ├── location.png ├── password.png ├── full_name_bg.png ├── create_button.png ├── others_data_bg.png └── download_button.png ├── README.md └── main.py /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muhammedmustafageldi/RandomUserGenerator/HEAD/app_icon.ico -------------------------------------------------------------------------------- /app_icons/call.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muhammedmustafageldi/RandomUserGenerator/HEAD/app_icons/call.png -------------------------------------------------------------------------------- /app_icons/copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muhammedmustafageldi/RandomUserGenerator/HEAD/app_icons/copy.png -------------------------------------------------------------------------------- /app_icons/email.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muhammedmustafageldi/RandomUserGenerator/HEAD/app_icons/email.png -------------------------------------------------------------------------------- /app_icons/anonymous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muhammedmustafageldi/RandomUserGenerator/HEAD/app_icons/anonymous.png -------------------------------------------------------------------------------- /app_icons/birthday.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muhammedmustafageldi/RandomUserGenerator/HEAD/app_icons/birthday.png -------------------------------------------------------------------------------- /app_icons/location.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muhammedmustafageldi/RandomUserGenerator/HEAD/app_icons/location.png -------------------------------------------------------------------------------- /app_icons/password.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muhammedmustafageldi/RandomUserGenerator/HEAD/app_icons/password.png -------------------------------------------------------------------------------- /app_icons/full_name_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muhammedmustafageldi/RandomUserGenerator/HEAD/app_icons/full_name_bg.png -------------------------------------------------------------------------------- /app_icons/create_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muhammedmustafageldi/RandomUserGenerator/HEAD/app_icons/create_button.png -------------------------------------------------------------------------------- /app_icons/others_data_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muhammedmustafageldi/RandomUserGenerator/HEAD/app_icons/others_data_bg.png -------------------------------------------------------------------------------- /app_icons/download_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muhammedmustafageldi/RandomUserGenerator/HEAD/app_icons/download_button.png -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/RandomUserGenerator.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Random User Generator 🧑 2 | 3 | Random user generator takes data from the 'randomuser.me' api and displays the profile photo, name, surname, email, birthday, address, phone number and password information to the user in an interface with the help of tkinter. If the user wants, he can copy this data with a single button and save his profile photo to his computer with a single button. 4 | 5 | ## Features 6 | 7 | - Generate random user information. 8 | - Copy the generated information with a single button. 9 | - Save the profile photo created with a single button on the computer. 10 | 11 | ## Requirements 12 | 13 | - Python 3.x 14 | - Tkinter library (part of the Python standard library) 15 | - Pillow (also known as PIL, required for image processing) 16 | - Requests (required to make api requests) 17 | 18 | To install the requirements: 19 | 20 | ``` 21 | pip install pillow 22 | ``` 23 | 24 | ## USAGE 25 | 26 | 1. Download or clone the project to your computer. 27 | 2. Open a terminal and navigate to the project directory. 28 | 3. Run the command `python main.py` in the terminal to launch the application. 29 | 4. Press the generate button in the pop-up window to create a random user profile. 30 | 31 | ## SCREENSHOT 32 | 33 | ![Interface](https://github.com/muhammedmustafageldi/My-ScreenShots-Files/blob/main/Screnshots/RandomUserGenerator/randomgenerate1.png) 34 | 35 | ![Generate1](https://github.com/muhammedmustafageldi/My-ScreenShots-Files/blob/main/Screnshots/RandomUserGenerator/randomgenerate2.png) 36 | 37 | ![Generate2](https://github.com/muhammedmustafageldi/My-ScreenShots-Files/blob/main/Screnshots/RandomUserGenerator/randomgenerate3.png) 38 | 39 | ## CONTRIBUTION 40 | 41 | We welcome all contributions! Here's how you can contribute: 42 | 43 | 1. Fork the repository (click the "Fork" button in the upper right corner) 44 | 2. Create a new branch (`git checkout -b new-feature`) 45 | 3. Make your changes and commit them (`git commit -am 'Added a new feature'`) 46 | 4. Push your branch to your forked repository (`git push origin new-feature`) 47 | 5. Create a Pull Request! 48 | 3. Make your changes and commit them (`git commit -am 'Added a new feature'`) 49 | 4. Push your branch to your forked repository (`git push origin new-feature`) 50 | 5. Create a Pull Request! 51 | 52 | 53 | > # *Thank you for viewing my project.Don't forget to star if you liked it.* 🙃 54 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from tkinter import * 3 | from PIL import Image, ImageTk 4 | import pyperclip 5 | from tkinter import filedialog 6 | from datetime import datetime 7 | from tkinter import messagebox 8 | from io import BytesIO 9 | 10 | root = Tk() 11 | 12 | my_orange_color = '#e1830e' 13 | my_white_color = '#dee1ec' 14 | my_dark_color = '#5e6175' 15 | my_light_color = '#bdc3d4' 16 | 17 | full_name_variable = StringVar() 18 | email_variable = StringVar() 19 | birthday_variable = StringVar() 20 | location_variable = StringVar() 21 | phone_variable = StringVar() 22 | password_variable = StringVar() 23 | 24 | 25 | def window_settings(): 26 | root.title(string='Random User Generator') 27 | root.iconbitmap('app_icon.ico') 28 | root.geometry('1200x720+300+200') 29 | root.config(background=my_dark_color) 30 | root.resizable(False, False) 31 | 32 | 33 | def create_top_frame(): 34 | top_frame = Frame(root, bg=my_light_color, height=65) 35 | top_frame.pack(fill='x') 36 | 37 | app_image = Image.open('app_icon.ico') 38 | resized_app_icon = app_image.resize((65, 65), Image.LANCZOS) 39 | app_icon = ImageTk.PhotoImage(resized_app_icon) 40 | 41 | label_app_icon = Label(top_frame, image=app_icon, bg=my_light_color) 42 | label_app_icon.image = app_icon 43 | label_app_icon.grid(row=0, column=0) 44 | 45 | label_app_name = Label(top_frame, text='Random User Generator', bg=my_light_color, fg='white', 46 | font=('poppins', 25, 'bold')) 47 | label_app_name.grid(row=0, column=1, padx=10) 48 | 49 | top_frame.columnconfigure(2, weight=1) 50 | 51 | label_brand = Label(top_frame, text='Created by\nSwanky', bg=my_light_color, fg=my_orange_color, 52 | font=('poppins', 10, 'bold')) 53 | label_brand.grid(row=0, column=2, padx=10, sticky="e") 54 | 55 | 56 | def create_widgets(): 57 | # User profile image 58 | test_img = create_image_with_path(path='app_icons/anonymous.png', x=128, y=128) 59 | 60 | label_user_img = Label(root, image=test_img) 61 | label_user_img.image = test_img 62 | label_user_img.pack(padx=10, pady=10) 63 | 64 | download_image = create_image_with_path('app_icons/download_button.png', 202, 40) 65 | download_button = Button(root, image=download_image, background=my_dark_color, borderwidth=0, 66 | activebackground=my_dark_color, cursor='hand2') 67 | download_button.image = download_image 68 | 69 | # Name and surname 70 | name_img = create_image_with_path(path='app_icons/full_name_bg.png', x=300, y=50) 71 | label_name_bg = Label(root, image=name_img, background=my_dark_color) 72 | label_name_bg.image = name_img 73 | label_name_bg.pack() 74 | 75 | full_name_variable.set('...') 76 | label_name = Label(label_name_bg, width=20, justify='center', textvariable=full_name_variable, 77 | font=('poppins', 15, 'bold'), background=my_light_color, foreground='white') 78 | label_name.pack(side='left') 79 | 80 | copy_name_image = create_image_with_path('app_icons/copy.png', x=26, y=26) 81 | copy_name_button = Button(label_name_bg, image=copy_name_image, borderwidth=0, background=my_light_color, 82 | activebackground=my_light_color, cursor='hand2', 83 | command=lambda: pyperclip.copy(full_name_variable.get())) 84 | copy_name_button.image = copy_name_image 85 | copy_name_button.pack(side='right') 86 | 87 | divider = Canvas(root, height=1, bg=my_light_color) 88 | divider.pack(fill="x", pady=10) 89 | 90 | # Other datas 91 | email_img = create_image_with_path('app_icons/email.png', x=32, y=32) 92 | create_frame_and_label(label_icon=email_img, label_variable=email_variable) 93 | 94 | birthday_img = create_image_with_path('app_icons/birthday.png', x=32, y=32) 95 | create_frame_and_label(label_icon=birthday_img, label_variable=birthday_variable) 96 | 97 | location_img = create_image_with_path('app_icons/location.png', x=32, y=32) 98 | create_frame_and_label(label_icon=location_img, label_variable=location_variable) 99 | 100 | call_img = create_image_with_path('app_icons/call.png', x=32, y=32) 101 | create_frame_and_label(label_icon=call_img, label_variable=phone_variable) 102 | 103 | password_img = create_image_with_path('app_icons/password.png', x=32, y=32) 104 | create_frame_and_label(label_icon=password_img, label_variable=password_variable) 105 | 106 | generate_bg = create_image_with_path(path='app_icons/create_button.png', x=344, y=57) 107 | generate_button = Button(root, image=generate_bg, background=my_dark_color, borderwidth=0, cursor='hand2', 108 | activebackground=my_dark_color, 109 | command=lambda: put_data_widgets(photo_label=label_user_img, 110 | download_button=download_button)) 111 | generate_button.image = generate_bg 112 | generate_button.pack(pady=20) 113 | 114 | 115 | def create_frame_and_label(label_icon, label_variable): 116 | copy_image = Image.open('app_icons/copy.png') 117 | copy_icon = ImageTk.PhotoImage(copy_image.resize((32, 32), Image.LANCZOS)) 118 | 119 | frame = Frame(root, bg=my_light_color, borderwidth=2, ) 120 | frame.pack(pady=5) 121 | 122 | label_variable.set('...') 123 | 124 | label = Label(frame, justify='left', font=('poppins', 13, 'bold'), background=my_light_color, foreground='white', 125 | bg=my_dark_color, textvariable=label_variable, padx=7, 126 | image=label_icon, compound=LEFT, width=350, anchor='w') 127 | label.image = label_icon 128 | label.grid(row=0, column=0) 129 | 130 | copy_button = Button(frame, image=copy_icon, borderwidth=0, background=my_light_color, 131 | activebackground=my_light_color, 132 | cursor='hand2', command=lambda: pyperclip.copy(label_variable.get())) 133 | copy_button.image = copy_icon 134 | copy_button.grid(row=0, column=1, padx=10) 135 | 136 | 137 | def create_image_with_path(path, x, y): 138 | opened_image = Image.open(path) 139 | return ImageTk.PhotoImage(opened_image.resize((x, y), Image.LANCZOS)) 140 | 141 | 142 | def get_user_data(): 143 | url = 'https://randomuser.me/api/' 144 | response = requests.get(url) 145 | 146 | if response.status_code == 200: 147 | data = response.json() 148 | result = data['results'] 149 | user_details = result[0] 150 | 151 | name = user_details['name'] 152 | first_name = name['first'] 153 | surname = name['last'] 154 | 155 | email = user_details['email'] 156 | 157 | dob = user_details['dob']['date'] 158 | birthday = format_date(dob) 159 | 160 | # Location 161 | street_number = user_details['location']['street']['number'] 162 | street_name = user_details['location']['street']['name'] 163 | city = user_details['location']['city'] 164 | country = user_details['location']['country'] 165 | 166 | full_street = f"{street_number} {street_name} {city}/{country}" 167 | 168 | phone = user_details['phone'] 169 | password = user_details['login']['password'] 170 | photo = user_details['picture']['large'] 171 | 172 | user_desc = { 173 | 'full_name': first_name + ' ' + surname, 174 | 'email': email, 175 | 'birthday': birthday, 176 | 'full_street': full_street, 177 | 'phone': phone, 178 | 'password': password, 179 | 'photo': photo 180 | } 181 | return user_desc 182 | else: 183 | messagebox.showerror(title='Error', message=f'Error. Request failed. HTTP code: {response.status_code}') 184 | 185 | 186 | def put_data_widgets(photo_label, download_button): 187 | data_dict = get_user_data() 188 | if data_dict: 189 | fullname = data_dict.get('full_name') 190 | email = data_dict.get('email') 191 | birthday = data_dict.get('birthday') 192 | full_street = data_dict.get('full_street') 193 | phone = data_dict.get('phone') 194 | password = data_dict.get('password') 195 | photo = data_dict.get('photo') 196 | 197 | full_name_variable.set(fullname) 198 | email_variable.set(email) 199 | birthday_variable.set(birthday) 200 | location_variable.set(full_street) 201 | phone_variable.set(phone) 202 | password_variable.set(password) 203 | 204 | # Download user picture 205 | image_data = get_image_from_url(url=photo) 206 | if image_data: 207 | image_as_bytes = BytesIO(image_data) 208 | image = Image.open(image_as_bytes) 209 | photo_image = ImageTk.PhotoImage(image.resize((128, 128), Image.LANCZOS)) 210 | photo_label.config(image=photo_image) 211 | photo_label.image = photo_image 212 | download_button.pack() 213 | download_button.config(command=lambda: save_image(image_data)) 214 | else: 215 | messagebox.showwarning(title='Image error', message='There was an error uploading the photo') 216 | 217 | 218 | def save_image(image_data): 219 | file_path = filedialog.asksaveasfilename(defaultextension='.jpg', filetypes=[("JPEG files", "*.jpg")], 220 | initialfile='profile.jpg') 221 | if file_path: 222 | try: 223 | with open(file_path, 'wb') as file: 224 | file.write(image_data) 225 | messagebox.showinfo('Save', message='Save is success.') 226 | except Exception as e: 227 | print(str(e)) 228 | 229 | 230 | def get_image_from_url(url): 231 | try: 232 | picture_response = requests.get(url) 233 | if picture_response.status_code == 200: 234 | image_data = picture_response.content 235 | return image_data 236 | else: 237 | return None 238 | except Exception as e: 239 | print('Exception of the picture.', str(e)) 240 | return None 241 | 242 | 243 | def format_date(api_date): 244 | date_object = datetime.strptime(api_date, "%Y-%m-%dT%H:%M:%S.%fZ") 245 | just_date = date_object.strftime("%d-%m-%Y") 246 | return just_date 247 | 248 | 249 | window_settings() 250 | create_top_frame() 251 | create_widgets() 252 | 253 | root.mainloop() 254 | --------------------------------------------------------------------------------