PySimpleSQL / pysimplesql

SQLite3 binding for PySimpleGUI
GNU Lesser General Public License v3.0
45 stars 16 forks source link

New Settings or Behavior class for form/dataset init variables #211

Closed ssweber closed 1 year ago

ssweber commented 1 year ago

Instead of overloading the Form init with a ton of arguments, I'm thinking that we should have a Settings or Behavior for all the different settings. Then we can have one set_settings, or set_behavior, that acts like the themepack/languagepack.

app_behavior = Behavior('prompt_save' : ss.AUTOSAVE_MODE, "save_quiet"=True} frm = ss.Form(driver, bind_window=window, behavior=app_behavior}

or after its already init:

frm.set_behavior(app_behavior)

List would be: prompt_save save_quiet update_cascade delete_cascade confirm_duplicate duplicate_children confirm_delete force_save

PySimpleSQL commented 1 year ago

Yeah, I've thought about this too a few times. I've been kind of torn, only because I was trying to provide an interface that is somewhat similar to PySimpleGUI, since it's a prerequisite for the whole project. I'm not a huge fan of huge init parameter sets either.

A work around I often use is to define a dict of the parameters and dump them into the init with ** like with the connection parameters for the remote databases. Maybe this would be the cleanest approach for examples that make the init function overly large?

On Sun, Mar 26, 2023, 1:32 PM ssweber @.***> wrote:

Instead of overloading the Form init with a ton of arguments, I'm thinking that we should have a Settings or Behavior for all the different settings. Then we can have one set_settings, or set_behavior, that acts like the themepack/languagepack.

app_behavior = Behavior('prompt_save' : ss.AUTOSAVE_MODE, "save_quiet"=True} frm = ss.Form(driver, bind_window=window, behavior=app_behavior}

or after its already init:

frm.set_behavior(app_behavior)

List would be: prompt_save save_quiet update_cascade delete_cascade confirm_duplicate duplicate_children confirm_delete force_save

— Reply to this email directly, view it on GitHub https://github.com/PySimpleSQL/pysimplesql/issues/211, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQX2REXME4JS76CFQQ6DTQLW6CDUDANCNFSM6AAAAAAWIKWFEM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ssweber commented 1 year ago

I’ll take a look at how you do it with the connections param, when I get around to the confirm_delete, confirm_duplicate

ssweber commented 1 year ago

I’ll just add to the init section for now then. You’re right, pysimplegui doesn’t shy away from a ton of args!