| 160 | |
| 161 | |
| 162 | def upload_logo(): |
| 163 | global loaded_image, logo, logo_path, text_label |
| 164 | |
| 165 | if text_label is not None: |
| 166 | CTkMessagebox( |
| 167 | title="Text In Use", message="You are using text. Can't use logo." |
| 168 | ) |
| 169 | return |
| 170 | |
| 171 | if logo is not None: |
| 172 | image_canvas.delete(logo) |
| 173 | if loaded_image: |
| 174 | logo_path = filedialog.askopenfilename( |
| 175 | filetypes=[("Image files", "*.jpg *.jpeg *.png *.bmp")], |
| 176 | ) |
| 177 | if logo_path: |
| 178 | logo_image = Image.open(logo_path).convert("RGBA") |
| 179 | resize = logo_image.resize((160, 150)) |
| 180 | logo_photo = ImageTk.PhotoImage(resize) |
| 181 | logo = image_canvas.create_image(0, 0, anchor="nw", image=logo_photo) |
| 182 | image_canvas.tag_bind(logo, "<B1-Motion>", move_logo) |
| 183 | |
| 184 | image_canvas.logo_photo = logo_photo |
| 185 | |
| 186 | else: |
| 187 | CTkMessagebox( |
| 188 | title="Image Field Empty", |
| 189 | message="Image field empty. Click on the open image button to add the image to the canvas.", |
| 190 | icon="cancel", |
| 191 | ) |
| 192 | |
| 193 | |
| 194 | # ---------------------------- TODO SAVE FUNCTION --------------- |