DOCUMENTATION

SYNOPSIS

PERL PERL PROGRAM NAME: L_SU.pm
AUTHOR: 	Juan Lorenzo
DATE: 		May 14 2018 

DESCRIPTION 
    
BASED ON:
previous versions of the main L_SU.pl
 

USE

NOTES

Examples

SEISMIC UNIX NOTES

CHANGES and their DATES V 0.1.0 refactoring of 2017 version of L_SU.pl

V 0.1.1 May 16 2018
 moving FileDialog_button, FileDialog, FileDialog_close
 to file_dialog.pm
 
 making save_button redundant
 refactor superflow selection
 
 V0.1.2 refactoring superflows and user-built flows
 
 V0.1.3 introduce multi-color flows ( 4 off)
 
 V0.1.5 includes gui_history 9-13-19
 
 V0.1.6 move methods into color_listbox class 2.10.2021
 
 V0.1.7 May 2021
 permit my_dialogs to interact with user and change flow
 
 V0.1.8 January 2023 Includes Delete a file through the
 FileDialog

share the following parameters in same name space

flow_listbox_grey_w -left listbox, input by user selection flow_listbox_green_w -right listbox,input by user selection sunix_listbox -choice of listed sunix modules in a listbox

36 off

defaults

declare private variables

private hash to manage listbox occupation

	Opening a file of folder for a superflow
	Only superflow bindings use this private (' _') subroutine.
	Superflows that are opening Data files from GUI are directed here
	
	FileDialog_button is mainly used for user-built flows 
	and directs superflows
	to _FileDialog_button
	
	For safety, place set_hash_ref first
	$$dialog_type_sref can be Data, Save or SaveAs
	
	print(" 43 L_SU,_FileDialog_button, dialog type: $L_SU_href->{_dialog_type}\n");
   print(" L_SU,_FileDialog_button, values_aref: @{$L_SU_href->{_values_aref}}\n");

sub _get_flow_color

sub _set_flow_color

set the flow color even if it is blank (=no color))

sub _set_flow_listbox_color_w

sub _unset_pre_built_userflow_type

sub _set_user_built_flow_type

sub _FileDialog_button_Delete

is color-listbox-neutral

sub _FileDialog_button_Open

sub FileDialog_button

(1) For user-built flows. (2) Interactively choose a file name that will then be entered into the values of the parameter frame and stored away via param_flow for colored flows: grey, pink, blue, green

(3) Set conditions for the use of a FileDialog_button i.e., find out which prior widget invoked the FileDialog_button e.g., was it a user-built flow or a superflow?

print("L_SU,FileDialog_button parameter_values_frame: $L_SU_href->{_parameter_values_frame}\n"); print("L_SU,FileDialog_button parameter_values_frame: $parameter_values_frame\n");

(4) dialog_type is one of 3 topics: 'Data ', (open a) 
Open (open a user-built perl flow) or'SaveAs 'a user-built perl flow)
or 'Delete' any file
	
(5) The Save (main) option goes straight to the L_SU,save_button for both'
 user_built'and 'pre_built_superflow'

(6) flow_type can be 'user_built'or 'pre_built_superflow ' (7) for safety, place set_hash_ref first

(8) Each colored flow will be directed to a different program

	 	foreach my $key (sort keys %$L_SU_href) {
      	print (" L_SU,FileDialog_button, key is $key, value is $L_SU_href->{$key}\n");
 	}
 	
 (9) The number of values and names = what is read from the configuration file
 After FileDialog is run, the number of values and names = max default value, 
 because param_widgets are chosen inside file_dialog
 This action is justified because I chose to determine independently # variables
 from the param_widget which is defaulted to a large number 
 (so that we know in advance how many value are occupied without reading SeismicUnixPltTk_global_cosntants.pm
  The "large number" can be changed within L_SU_global_constants.

sub get_help

Callback sequence following MB3 click activation of a sunix (Listbox) item. Program name is a scalar reference

Allow this subroutine help decide whether it is a superflow or a user-created flow

Show a window with the perldoc to the user

sub help_menubutton

Callback sequence following MB1 (regular) click activation of a help_menubutton item. Program name is a scalar reference

Allow this subroutine help_menubutton to select action e.g., open a perldoc file for information

sub initialize my dialogs

Create widgets that show messages Show warnings or errors in a message box Message box is defined in main where it is also made invisible (withdraw) Here we turn on the message box (deiconify, raise) The message does not release the program until OK or cancels clicked and wait variable changes from no/yes to yes/no.

sub initialize messages

Create widgets that show messages Show warnings or errors in a message box Message box is defined in main where it is also made invisible (withdraw) Here we turn on the message box (deiconify, raise) The message does not release the program until OK is clicked and wait variable changes from yes to no.

sub pre_built_superflows

   scalar reference:
     print("LSU_Tk,superflow_select,prog_name: ${$L_SU_href->{_prog_name_sref}}\n");
    array reference:
      print("LSU_Tk,superflow_select: _names_aref @{$L_SU_href->{_names_aref}}\n");
      sets flow type = pre-built superflow
      
      # print complete hash
 		while (my ( $key,$value ) = each %{$L_SU_href} ){
 			print ("$key \t\t=> $value\n");
 		}

 		 binding needs:
 		  	$pre_built_big_stream	->select(); 
			$pre_built_big_stream	->set_sub_ref
		$pre_built_big_stream	->set_flowNsuperflow_name_w  displays superflow name at top of gui 
			
	);

  	 	foreach my $key (sort keys %$L_SU_href) {
 		print (" file_dialog,key is $key, value is $L_SU_href->{$key}\n");
    			

sub set_run_button

comes from MAIN and is used by superflow

    uses flow or pre_built superflow names  
	
	original L_SU plus changes is returned	
    
    for safety, place set_hash_ref first
    
 	foreach my $key (sort keys %$L_SU_href) {
      	print (" L_SU,set_run_button, key is $key, value is $L_SU_href->{$key}\n");
 	}
 				      	
     

sub set_save_button

called from MAIN

foreach my $key (sort keys %$L_SU_href) {
     print (" L_SU,set_save_button, key is $key, value is $L_SU_href->{$key}\n");
}	
         
        dialog_type for set_save_button is only 'Save'
        
  Because private hash does not have _dialog type
  it should be assigned to set_save_button after set_hash_ref transfers L_SU hash
  but not before
  i.e. for safety, transfer set_hash_ref first
        
  save can be for 2 situations: pre-built superflows and user-built flows
        
 collect changes to environmental indicator variables such as _has_used_SaveAs_button
        
   print("L_SU,set_save_button, flow_type : $L_SU_href->{_flow_type}\n");
   
   In:  set_save_button, uses topics
   	
   Topics originate as a dialog_type topic which can be  'Data', 'Flow
'SaveAs', or 'Delete'
   
   Topic for set_save_button can also be 'Save'
   
   Flow types can be: user-built or pre-built superflow
   
   Logic for use: SaveAs_button must have been used previously or Save_button
   Once Save_button is used has_used_SaveAs_button = false
	

sub set_hash_ref

	imports external hash into private settings
	once at the start of the Main Loop
	Settings are lost thereafter and so it is good
	to store them with local names
 

set_param_widgets

Initially, checkbutton widgets and values 
are green ("on") or red ("off"), and
Labels and Entry Widgets are made blank.
get back the Label and Entry widgets 

print("L_SU, set_param_widgets _check_buttons_settings_aref: @{$L_SU_href->{_check_buttons_settings_aref}}\n")
print("L_SU, set_param_widgets _labels_w_aref: @{$L_SU_href->{_labels_w_aref}}\n");

sub user_built_flows

USE:

 for any colored flow
to delete an item from a flow
'delete_from_flow_button'
to move up and down a list of flow items
'flow_item_up_arrow_button'
'flow_item_down_arrow_button '
'delete_whole_flow_button '
add2flows

sunix_listbox get_help (MB3)
flow-item selection ('flow_select') (MB1)

if neutral-colored stored parameters exist they have to be transferred from neutral_flow to either grey, pink, green, or blue, _flow

displays superflow name at top of gui $pre_built_big_stream ->set_flowNsuperflow_name_w($flowNsuperflow_name_w);

needed for binding to file dialog options $grey_flow ->set_sub_ref(\&_FileDialog_button);

Display of all the parameters and names occurs via select method $pre_built_big_stream ->select();

return changes to $L_SU_href without altering other original values $L_SU_href = $pre_built_big_stream->get_hash_ref();

listbox color is selected, e.g., with a MB1 click in Main