GUI
This module contains the implementation of the main GUI for the application.
It includes classes for the main window, buttons, and other GUI components, as well as methods for handling user input and updating the GUI.
image1dir
module-attribute
¶
image1dir: str = join(image_directory, 'Anilist-Manga-Updater-Logo2.png')
AccessTokenThread
¶
Bases: Thread
A class that extends the threading.Thread class in Python. This class is used to create a separate thread for obtaining the access token from the Anilist API.
ATTRIBUTE | DESCRIPTION |
---|---|
stop |
bool A flag used to stop the thread. It is initially set to False.
|
METHOD | DESCRIPTION |
---|---|
run |
Overrides the run method of threading.Thread. It checks if the global 'app' variable is None. If it is, it logs an error and returns. Otherwise, it calls the Get_Access_Token function with 'app' as the argument. |
stop_thread |
Sets the stop flag to True, indicating that the thread should stop running. |
The stop flag is initially set to False, indicating that the thread should not be stopped.
Source code in AnilistMangaUpdater/Main/GUI.py
run
¶
Run the Get_Access_Token function in the thread.
This method is called when the thread's start() method is invoked. It checks if the global 'app' variable is None. If it is, it logs an error and returns. Otherwise, it calls the Get_Access_Token function with 'app' as the argument.
Source code in AnilistMangaUpdater/Main/GUI.py
stop_thread
¶
Set the stop flag to True to stop the thread.
This method can be called to stop the thread. It sets the stop flag to True, which indicates that the thread should stop running.
Source code in AnilistMangaUpdater/Main/GUI.py
App
¶
Bases: CTk
Source code in AnilistMangaUpdater/Main/GUI.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 |
|
access_token_button
instance-attribute
¶
access_token_button = CTkButton(sidebar_frame, command=access_token_button_clicked, text='Get Access Token')
access_token_button_tooltip
instance-attribute
¶
access_token_button_tooltip = CTkToolTip(access_token_button, 'Opens a dialog to get the access token.\nThis may need to be refreshed in the future.')
alt_titles_button
instance-attribute
¶
alt_titles_button = CTkButton(sidebar_frame, command=lambda: manage_alternative_titles(), text='Manage Alt Titles')
api_button
instance-attribute
¶
api_button_tooltip
instance-attribute
¶
api_button_tooltip = CTkToolTip(api_button, "Opens a dialog to set the API values.\nThis is for the API's Client and Secret ID's")
appearance_mode_label
instance-attribute
¶
appearance_mode_optionemenu
instance-attribute
¶
appearance_mode_optionemenu = CTkOptionMenu(sidebar_frame, values=['Light', 'Dark', 'System'], command=change_appearance_mode_event)
appearance_mode_optionemenu_tooltip
instance-attribute
¶
appearance_mode_optionemenu_tooltip = CTkToolTip(appearance_mode_optionemenu, 'Changes the appearance mode of the application.')
browse_button
instance-attribute
¶
browse_button = CTkButton(master=self, fg_color='transparent', border_width=2, text_color=('gray10', '#DCE4EE'), text='Browse', command=lambda: browse_file(file_path_textbox, False))
browse_button_tooltip
instance-attribute
¶
browse_button_tooltip = CTkToolTip(browse_button, 'Opens a file dialog to select the Kenmei export file.')
exit_button
instance-attribute
¶
exit_button = CTkButton(sidebar_frame, command=on_close, text='Exit')
exit_button_tooltip
instance-attribute
¶
exit_button_tooltip = CTkToolTip(exit_button, 'Exits the application.\nPlease use this to exit program.\nIt is possible that the application will still run if you just close the window rather than use this button.')
file_path_textbox
instance-attribute
¶
file_path_textbox_tooltip
instance-attribute
¶
file_path_textbox_tooltip = CTkToolTip(file_path_textbox, 'Displays the path of the Kenmei export file.')
month_button
instance-attribute
¶
month_button_tooltip
instance-attribute
¶
month_button_tooltip = CTkToolTip(month_button, 'Opens a dialog to set the number of months.\nThis checks when the last time you read a chapter was and if it was after the number of months you set.\nIt will change the status to Paused.\nIf you want the program to ignore this set this to 0')
previous_browse_button
instance-attribute
¶
previous_browse_button = CTkButton(master=self, fg_color='transparent', border_width=2, text_color=('gray10', '#DCE4EE'), text='Browse', command=lambda: browse_file(previous_file_path_textbox, True))
previous_browse_button_tooltip
instance-attribute
¶
previous_browse_button_tooltip = CTkToolTip(previous_browse_button, 'Opens a file dialog to select the previous Kenmei export file. (Optional)')
previous_file_path_textbox
instance-attribute
¶
previous_file_path_textbox_tooltip
instance-attribute
¶
previous_file_path_textbox_tooltip = CTkToolTip(previous_file_path_textbox, 'Displays the path of the previous Kenmei export file. (Optional)')
private_button
instance-attribute
¶
private_button_tooltip
instance-attribute
¶
private_button_tooltip = CTkToolTip(private_button, 'Opens a dialog to set the private value.\nThis is for if you want to set the manga that you update on here to private on Anilist.\nMeaning it will not show up as activity or on your list for other users.')
progress_bar_tooltip
instance-attribute
¶
progress_bar_tooltip = CTkToolTip(progress_bar, f'{round(progress * 100, 1)}%')
scaling_label
instance-attribute
¶
scaling_optionemenu
instance-attribute
¶
scaling_optionemenu = CTkOptionMenu(sidebar_frame, values=['80%', '90%', '100%', '110%', '120%'], command=change_scaling_event)
scaling_optionemenu_tooltip
instance-attribute
¶
scaling_optionemenu_tooltip = CTkToolTip(scaling_optionemenu, 'Changes the UI scaling of the application.\nYou may need to resize window to fit the new scaling.')
start_button
instance-attribute
¶
start_button = CTkButton(sidebar_frame, command=start_button_clicked, text='Start', font=CTkFont(size=18))
start_button_tooltip
instance-attribute
¶
start_button_tooltip = CTkToolTip(start_button, 'Starts the program.\nThe only way to stop this is to exit the AnilistMangaUpdater with the exit button.')
status_label
instance-attribute
¶
status_label = CTkLabel(self, text=f'Status: {progress_status[:37]}...' if len(progress_status) > 40 else progress_status)
time_remaining_label
instance-attribute
¶
time_taken_label
instance-attribute
¶
title_label
instance-attribute
¶
title_label = CTkLabel(sidebar_frame, text='Anilist Manga\nUpdater', font=CTkFont(size=22, weight='bold'))
access_token_button_clicked
¶
Handles the event when the access token button is clicked.
This method is triggered when the user clicks on the access token button. It performs the following steps:
- Retrieves the current configuration of the application.
- Pauses the execution for 2 seconds.
- Creates a new thread for obtaining the access token from the Anilist API.
- Starts the newly created thread.
- Opens an input dialog for the user to enter the access token.
- Waits for the access token thread to finish.
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in AnilistMangaUpdater/Main/GUI.py
browse_file
¶
Opens a file dialog for the user to select a file, and updates the entry widget with the selected file path.
This method prompts the user to select a file through a file dialog. The selected file path is then inserted into the provided entry widget and stored in the appropriate variable. If the user cancels the file dialog, the text of the entry widget is restored to its previous state.
PARAMETER | DESCRIPTION |
---|---|
entry_widget |
The entry widget to be updated with
TYPE:
|
is_previous |
A flag indicating whether the selected file is a previous Kenmei
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in AnilistMangaUpdater/Main/GUI.py
get_action
¶
Get the action from the user.
Source code in AnilistMangaUpdater/Main/GUI.py
get_original_title
¶
Prompts the user to select an original title from the alternative titles dictionary.
This method displays a list of original titles to the user and prompts them to select one. The user's selection is returned. If the user cancels the dialog or enters an invalid selection, the method returns None.
PARAMETER | DESCRIPTION |
---|---|
alt_titles_dict |
The dictionary containing the original titles as keys and alternative
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The original title selected by the user, if a valid selection was made.
TYPE:
|
None
|
If the user cancelled the dialog or made an invalid selection.
TYPE:
|
Source code in AnilistMangaUpdater/Main/GUI.py
manage_alternative_titles
¶
Manages alternative titles in the application.
This method allows the user to add, edit, or delete alternative titles. The user interacts with the method through a series of dialog boxes and terminal prompts. The method retrieves the current alternative titles from a file, prompts the user to select an action (add, edit, or delete), and performs the selected action.
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in AnilistMangaUpdater/Main/GUI.py
month_button_clicked
¶
Handles the event when the month button is clicked.
This method is triggered when the user clicks on the month button. It performs the following steps:
- Opens an input dialog for the user to enter the number of months.
- If the user input is a digit, it loads the configuration, updates the number of months in the configuration, and saves it.
- If the configuration is not found, it displays an error message and updates the terminal.
- If the user input is not a digit, it displays an error message and updates the terminal.
Parameters: None
Returns: None
Source code in AnilistMangaUpdater/Main/GUI.py
open_input_dialog_event
¶
Opens input dialogs for the client ID and secret ID.
This method prompts the user to input the client ID and secret ID through input dialogs. If the user cancels either dialog, a cancellation message is updated in the terminal. If the user enters both IDs, a configuration file is created and saved.
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in AnilistMangaUpdater/Main/GUI.py
open_token_dialog_event
¶
Opens an input dialog for the user to enter the access token.
This method prompts the user to input the access token through an input dialog. If the user cancels the dialog, an error message is displayed and the terminal is updated with a cancellation message. If the user enters the access token, the method loads the configuration file, adds the access token to it, and saves the updated configuration file. If the thread for obtaining the access token is running, it is stopped.
RETURNS | DESCRIPTION |
---|---|
None
|
None |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the user cancels the input dialog. |
Source code in AnilistMangaUpdater/Main/GUI.py
private_button_clicked
¶
Handles the event when the private button is clicked.
This method is triggered when the user clicks on the private button. It performs the following steps:
- Opens an input dialog for the user to enter the private value.
- If the user input is "yes" or "no", it loads the configuration, updates the private value in the configuration, and saves it.
- If the configuration is not found, it displays an error message and updates the terminal.
- If the user input is not "yes" or "no", it displays an error message and updates the terminal.
- If the user cancels the dialog, it displays an error message and updates the terminal.
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in AnilistMangaUpdater/Main/GUI.py
start_button_clicked
¶
Handles the event when the start button is clicked.
This method is triggered when the user clicks on the start button. It performs the following steps:
1. Checks if the program thread is already running. If it is, it returns immediately.
2. If the program thread is not running, it imports the AnilistMangaUpdater class.
3. Creates a new thread for the program.
4. Starts the newly created thread.
5. Sets the start time to the current time.
6. Updates the time taken label.
7. Updates the progress bar.
8. Resets the progress to 0.
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in AnilistMangaUpdater/Main/GUI.py
update_estimated_time_remaining
¶
Updates the estimated time remaining label in the GUI.
This method converts the estimated time remaining from seconds to a time format (hours, minutes, and seconds), updates the time remaining label, and schedules itself to be called again after 1 second if there is still time remaining.
If the estimated time remaining is less than 0, it is set to 0. If there is still time remaining, and the function is already scheduled, the scheduled function is cancelled. Then, this function is scheduled to be called again after 1 second.
PARAMETER | DESCRIPTION |
---|---|
estimated_time_remaining |
The estimated time remaining in seconds.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in AnilistMangaUpdater/Main/GUI.py
update_progress_and_status
¶
update_progress_and_status(status: str, program_progress: Optional[Union[float, None]] = None) -> None
Updates the progress and status of the program.
This method updates the global variables progress
and progress_status
that are used to track the progress
and status of the program. If the program_progress
parameter is provided and is different from the current
progress
, it updates the progress and status labels in the GUI.
PARAMETER | DESCRIPTION |
---|---|
status |
The new status of the program. program_progress (float, optional): The new progress
TYPE:
|
program_progress |
The new progress of the program. If not provided, the current global.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in AnilistMangaUpdater/Main/GUI.py
update_progress_bar
¶
Updates the progress bar, status label, and time taken label in the GUI.
This method is scheduled to be called every 100 milliseconds. If the program thread is running, it updates the progress and status, as well as the time taken label. If the program thread is not running, it logs a warning and stops the function.
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in AnilistMangaUpdater/Main/GUI.py
update_terminal
¶
Updates the terminal in the GUI with the provided text.
This method first checks if the scrollbar is at the bottom of the terminal. If it is, the method will automatically scroll to the end after inserting the text. The terminal is temporarily enabled for the insertion of the text and then disabled again to prevent manual edits.
PARAMETER | DESCRIPTION |
---|---|
text |
The text to be inserted into the terminal.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in AnilistMangaUpdater/Main/GUI.py
add_alternative_title
¶
Adds an alternative title to the alternative titles dictionary.
This function prompts the user to input an original title and its corresponding alternative title. If the user provides valid inputs, it updates the alternative titles dictionary with the new pair and saves it to a file.
PARAMETER | DESCRIPTION |
---|---|
alt_titles_dict |
The dictionary containing the original titles as keys and alternative titles as values.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in AnilistMangaUpdater/Main/GUI.py
change_appearance_mode_event
¶
Changes the appearance mode of the application.
This function changes the appearance mode of the application based on the input parameter. It logs the new appearance mode and the successful change of the appearance mode.
PARAMETER | DESCRIPTION |
---|---|
new_appearance_mode |
The new appearance mode to be set. This should be a string representing
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in AnilistMangaUpdater/Main/GUI.py
change_scaling_event
¶
Changes the UI scaling of the application.
This function changes the UI scaling of the application based on the input parameter. It logs the new UI scaling and the successful change of the UI scaling.
PARAMETER | DESCRIPTION |
---|---|
new_scaling |
The new UI scaling to be set. This should be a string representing the desired UI
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in AnilistMangaUpdater/Main/GUI.py
delete_alternative_title
¶
Deletes an alternative title from the alternative titles dictionary.
This function removes the alternative title associated with the given original title from the alternative titles dictionary and saves the updated dictionary to a file.
PARAMETER | DESCRIPTION |
---|---|
alt_titles_dict |
The dictionary containing the original titles as keys and alternative titles as values.
TYPE:
|
original_title |
The original title for which the alternative title is to be deleted.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in AnilistMangaUpdater/Main/GUI.py
edit_alternative_title
¶
Edits an alternative title in the alternative titles dictionary.
This function prompts the user to input a new alternative title for a given original title. If the user provides a valid new alternative title, it updates the alternative titles dictionary and saves it to a file.
PARAMETER | DESCRIPTION |
---|---|
alt_titles_dict |
The dictionary containing the original titles as keys and alternative titles as values.
TYPE:
|
original_title |
The original title for which the alternative title is to be edited.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in AnilistMangaUpdater/Main/GUI.py
on_close
¶
Handles the event when the application is closed.
This function is triggered when the application is being closed. It logs the closing event and then terminates the application.
RETURNS | DESCRIPTION |
---|---|
None
|
None |