Replace myTkSimpleDialog (Issue #194)
by Chris Satterlee 2 years 3 months
Replace myTkSimpleDialog (Issue #194)

This commit removes the myTkSimpleDialog.py module and replaces it with internal classes and functions. These dialogs now require the specification of the master window that the dialog is associated with.
8b87650d
Use super() for calling __init__ (Issue #193)
by Chris Satterlee 2 years 3 months
Use super() for calling __init__ (Issue #193)

Use super() for calling __init__ of parent class instead of obsolete Python 2 syntax. See Issue #193 and https://stackoverflow.com/a/27134600
d0f8050d
Add support for instances (Issue #192)
by Chris Satterlee 2 years 3 months
Add support for instances (Issue #192)

This commit adds the feature requested in Issue #192.

IV_Swinger2_gui.py
- GraphicalUserInterface class changes:
- __init__:
- Add instance and main_gui creation parameters
- Add attributes:
- self.instance (string)
- Initial value from creation parameter
- Will always be None for the main GUI
- self.main_gui (object)
- Initial value from creation parameter
- Set to self if creation parameter value is None
- self.instance_gui (dict of objects)
- Only exists for main GUI
- Contains
- Initial value is empty dict: {}
- Added to when an instance GUI is launched
- Deleted from when an instance GUI is closed
- Set root to tk.Toplevel() instead of tk.Tk() for instance GUIs
- Pass instance value to set_root_options() method
- Append /inst/{instance} to app_data_dir for instances and pass
that in the creation of the ivs2 object
- Set instance ivs2 object's usb_port property to DISCONNECTED
- Set instance app_dir property to the main GUI's value (for
Windows bug workaround)
- Add derived properties:
- instances
- Sorted list of already-created instances
- usb_ports_in_use
- List of ports used by the main GUI and all instance GUIs
- Change check_app_data_dir() method to take the app_data_dir as a
parameter so it can be called before the creation of the ivs2 object
- Modify set_root_options() method:
- Added instance parameter
- Append instance to title if instance is not None
- In swing_loop() method, change minimum value of delay_ms from 1 to
10 to prevent any GUI from monopolizing the CPU
- Modify start_centered(), start_to_right(), and start_to_left()
methods to tile instance GUIs
- Modify the close_gui() method:
- Add warning if closing the main GUI and instance GUIs are still
open
- Add instance name to dialog that is generated when there are >5
changes to the config file
- When the method is called for an instance GUI, remove the
instance GUI object and delete it from the main GUI's
instance_gui dict
- Modify the run() method:
- Suppress attempting the Arduino handshake if the usb_port property
is DISCONNECTED
- Suppress calling mainloop for instances

- MenuBar class changes:
- Add the instances menu to the MenuBar class
- Call new create_instances_menu() method in __init__
- Add methods:
- create_instances_menu()
- populate_instances_menu()
- depopulate_instances_menu()
- update_instances_menu()
- launch_entry_action()
- launch_instance()
- add_new_instance()
- show_instances_help()
- Add InstancesHelpDialog class
- Suppress creating the Mac Preferences and Help menus for instance
GUIs (because they crash, but are still present from main GUI)
- Modify update_usb_port_menu() method:
- Add call to find_serial_ports before populating the menu
- Disable entries that are in use by other GUIs
- Add DISCONNECTED entry to allow user to disconnect from any USB
port
- Modify select_serial() method:
- Handle value of DISCONNECTED;
- Close the current USB port (if any) by calling the ivs2
object's close_usb() method
- Disable the go button
- Save value in the config file
- Modify run_simulator() method to pass the app_data_dir value in the
creation of the SimulatorDialog object

IV_Swinger2.py:
- Move code to get the default app_data_dir into a global function so
it can be used by GUI
- Resurrect the extended PrintAndLog class.
- Add instance variable for log_file_name to allow (but not
require) instance-specific logging
- Remove terminate_log() global function since it is a method in
the extended PrintAndLog class
- Modify the apply_usb method in the Configuration class:
- Handle the case where the USB port is in use:
- print and log a message
- set ivs2 object's usb_port property to DISCONNECTED
- Handle the case where the config value is DISCONNECTED
- Treat just the same as case where the port in the config
is attached; do not try to find an Arduino port
- Add optional usb_ports_in_use creation parameter to IV_Swinger2 class
- If the object is created with that parameter specified, set the
object's usb_ports_in_use attribute to the list passed
in. Otherwise, set it to an empty list
- Add a close_usb() method and use that in the reset_arduino()
method. This method is now used by the GUI when closing an instance
GUI.
- Add logging of the resetting of an Arduino

IV_Swinger2_sim.py:
- Add support for non-default app_data_dir:
- Pass the app_data_dir creation parameter to the IV_Swinger2
__init__
- Add app_data_dir creation parameter to the SimulatorDialog class
and pass it to the ivs2_sim object at creation
85d4f69c
Change to flat title on splash screen (Issue #191)
by Chris Satterlee 2 years 3 months
Change to flat title on splash screen (Issue #191)

Changed the splash screen to use a simple flat white font for the title.
ec14979d
Remove debug prints
by Chris Satterlee 2 years 4 months
Remove debug prints

Remove a couple of debug print statements that slipped in with recent commits
6bcb0326
Move revert question to beginning of dialog (Issue...
by Chris Satterlee 2 years 4 months
Move revert question to beginning of dialog (Issue #190)

See Issue #190.
72d574c0
Convert remaining files to f-strings (Issue #188)
by Chris Satterlee 2 years 5 months
Convert remaining files to f-strings (Issue #188)

Somehow missed the two PV_model files in the other commit for Issue #188. Also converting a few more strings that pylint didn't catch because the .format was used after the string template was assigned to a variable.
66024d75
Fix bug in f-string fix in IV_Swinger2_sim.py (Iss...
by Chris Satterlee 2 years 5 months
Fix bug in f-string fix in IV_Swinger2_sim.py (Issue #188)

Don't know how this happened. I thought I ran pylint on all the changed files. And I also thought I ran the app! Apparently not.
56cef7ca
Replace python 2 README file with EOL message/warn...
by Chris Satterlee 2 years 5 months
Replace python 2 README file with EOL message/warning (Issue #189)

README file was replaced with a warning message about the EOL of Python 2 code.
81fb7ea8
Convert to f-strings (Issue #188)
by Chris Satterlee 2 years 5 months
Convert to f-strings (Issue #188)

All formatted strings in the six files included in this commit were converted to f-strings. Pylint now doesn't generate any "consider-using-f-string" warnings.

The conversion was assisted with the "flynt" tool. Nearly all were converted with "flynt -ll 999". Then flake8 was used to identify the lines that were >79 characters, and those were manually split onto multiple lines using string literal concatenation. There were a very small number that flynt couldn't comvert, and those were done manually.
5b15e11f
Report a bug