Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Progress bar for File/Save Project functionality , replacing busy cursor #735

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Abo-Omar-74
Copy link

Overview:

This pull request introduces significant improvements to the File/Save Project functionality by replacing the busy cursor with a dynamic progress bar dialog. The progress bar dialog provides users with informative feedback on the status of the save operation, enhancing the overall user experience.
Solving part of this issue #707

Changes Made:

  • Added ProgressBarHandler Class:

    • Implemented a new class called ProgressBarHandler, which inherits from wx.ProgressDialog.
    • This class encapsulates the functionality of the progress bar dialog.
  • Implemented Functions:

    • wasCancelled: Checks whether the progress dialog was cancelled by the user.
    • update: Updates the progress dialog with the current progress value.
    • close: Closes the progress dialog.
    • pulse: Provides visual feedback to indicate ongoing activity.
  • Utilized Pubsub for Communication:

    • Integrated Pubsub for efficient communication between the SaveProject function and the ProgressBarHandler class.
    • Subscribed to Pubsub messages within the ProgressBarHandler class to handle updates and closing of the progress bar dialog.
    • Utilized Pubsub to send messages from the SaveProject function to update the progress bar dialog with relevant information.

Future Use:

  • Base Class for Progress Bar Handling:
    • The ProgressBarHandler class serves as a foundational component for managing progress bar functionality in future enhancements.
    • Its modular design allows for customization and adaptation to various functionalities that may benefit from progress bar feedback and solve the full issue Add progress bar to load and save files #707 here.

video while testing

Screenshots:

Screenshot 2024-04-01 171147

@Abo-Omar-74
Copy link
Author

Abo-Omar-74 commented Apr 1, 2024

It appears that I have removed 25 line from invesalius/control.py but actually all I have removed is 2 lines
which are :

  • line no : 370 Publisher.sendMessage('Begin busy cursor')
  • line no : 397 Publisher.sendMessage('End busy cursor')

and added line for Publisher.sendMessage related calls for updating and closing the Progress bar

I think this happen because of the indentation of Try Except that I have added to close the dialog if anything wrong occurred .

@vhosouza
Copy link
Member

@Abo-Omar-74 thanks for the PR! This is a nice feature. However, due to recent changes to the dialogs.py module, your code has conflicts. Can you rebase it and then I will review it, please?

@Abo-Omar-74 Abo-Omar-74 force-pushed the Feature-Add-Progress-Bar-for-Open-Project-Functionality branch from 3764633 to 470e679 Compare April 26, 2024 21:54
@Abo-Omar-74
Copy link
Author

@Abo-Omar-74 thanks for the PR! This is a nice feature. However, due to recent changes to the dialogs.py module, your code has conflicts. Can you rebase it and then I will review it, please?

@vhosouza Thanks for reaching out! I have resolved the conflict. I eagerly await your review.

Copy link
Member

@vhosouza vhosouza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Abo-Omar-74, thanks again for the adjustments. I tested and it's almost working fine. Just a couple of changes requested:

  • Fix wasCanceled method naming
  • Fix the "Cancel" behavior

Publisher.subscribe(self.update, "Update Progress bar")
Publisher.subscribe(self.close, "Close Progress bar")

def wasCancelled(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to follow the same lower case standard as the other methods.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I tested in MacOS and as the progress bar starts, the busy cursor also starts and it prevents from clicking the button Cancel, which means that the saving was not canceled. This behavior needs to be fixed.

@vhosouza
Copy link
Member

Also, in MacOS Sonoma, when the Progress Bar starts, the icon of invesalius is changed to a "folder" and after the bar is closed, the icon remains a folder. Any idea on how this can be fixed?

image

@Abo-Omar-74 Abo-Omar-74 force-pushed the Feature-Add-Progress-Bar-for-Open-Project-Functionality branch from 470e679 to ca7828f Compare June 10, 2024 23:25
@Abo-Omar-74
Copy link
Author

Code Modifications

@vhosouza , I am writing to provide an update regarding the recent code modifications in response to your feedback :

  1. Renamed the function wasCancelled to was_cancelled as requested.

  2. Disabled the cancel button due to the absence of an interrupt mechanism for the current saving functionality. This solution is still better than the current solution of the problem as it uses progress bar instead of a busy cursor, aiming for enhanced user experience.

  3. In my attempt to address the interruption issue, I experimented with binding the cancel button event wx.EVT_CLOSE to a function named interrupt. This function raises an exception, which is subsequently caught by the try except block within the SaveProject function in invesalius/control.py.

I will continue to refine the interrupt mechanism to ensure smooth operation and will keep you updated on any progress or further insights.

Thank you for your guidance and support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants