CSSG-Labs / PyNote

Text Editor Written in Python
GNU General Public License v3.0
3 stars 4 forks source link

Custom prompt generator #18

Closed AdamLaine closed 2 years ago

AdamLaine commented 2 years ago

@PatrickBruso Looking at the issues listed now, I propose to create a custom prompt generator (just an inherited customizable prompt class). Reasons:

  1. Faster and easier prompt creation in the issues (particularly #17 and #14) and for the possible future issues
  2. In case that in the future there will be need to customize components it will be easier (one customization instead of several) Example of intended usage: class CustomPrompt(question, listOfOptions) neededPrompt = CustomPrompt("File was not saved. Save it?", ["Save", "Don't save", "Cancel"]) Tell me what do you think and if I have the green light
PatrickBruso commented 2 years ago

@SamReiCooper I agree, this seems like a useful class to have. I was thinking more about the "save" vs. "save as" issue and I think we need to add some type of state status indicator to call to see if an item needs to be saved via "save" or "save as", perhaps something as simple as a global variable that has two states (needs save/needs save as) and then another variable that can hold the file location for items that just need to be saved back to that location. We could even combine the two into just check whether file_location exists and, if so, use "Save", and if not, use "Save as". Not sure if this would be useful to add into the CustomPrompt class or the Application class, so I'd be happy to hear your thoughts.

PatrickBruso commented 2 years ago

I wonder whether it makes sense to code the functions first (Save, New, Open) and then we can link them all to the CustomPrompt class. That class could be fed whether a file location currently exists, and return the correct prompt based on that trigger.

For example, we could just have the "New" file menu item create a blank text box, and then we can add a call to CustomPrompt after that's finished. Similarly, I could code the "Open" file menu to just file dialog for a file, check the file type, and load the text into the window. Then later we can connect the CustomPrompt to make sure that work is saved before a new file is opened, and add the file location trigger. Just want to avoid having people work on issues that may overlap. Happy to hear everyone's thoughts.

AdamLaine commented 2 years ago

@PatrickBruso I also thought about it. Best solution I see as you said is to have a path variable (can be filled by open and new) which is None by default (if not filled) and some path otherwise. If it is None "save as" shall be called automatically, otherwise "save" (at least it seems to me as the most logical and minimalistic approach). Better to put it into the Application as custom prompt can be used not only for the save/not save in my opinion. And answering the second comment. I suggest writing CustomPrompt first or contemporarily as it can be used with the "Open", etc actions. Maybe to show you better the idea I will write it and I will write also a testing prototype to show what I intend to do and we can decide on how to better integrate it with the other code

PatrickBruso commented 2 years ago

@SamReiCooper Sounds good, I don't think it will be an issue since it's a separate class. There won't be any overlap with the functions being written in the Application class.

PatrickBruso commented 2 years ago

Closed via PR #24