#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 28 20:34:55 2022

@author: russ
"""


import tkinter as Tk
import logging
import sys
from   tkinter import ttk

from   tkinter.scrolledtext import ScrolledText
# ----- local

from   app_global import AppGlobal
# for russ development, others should be able to delete
sys.path.append( "D:/Russ/0000/python00/python3/_projects/rshlib" )
sys.path.append( "/media/russ/j_sg_bigcase/sync_py_3/_projects/rshlib/" )
sys.path.append( "../rshlib")


import gui_ext
import clip_utils

STICKY_ALL          = Tk.N + Tk.S + Tk.E + Tk.W
STD_BUTTON_HEIGHT   = 2

# -----------------------------------
def  make_check_button( p_frame,  a_text,
                       a_variable, a_function,
                       a_gui_style = None     ):
    """
    !! seems almost not to be in use -- should we keep
    make a combination check box and button  -- not the more common radio button
    look at command frame
    arguments
        p_frame
        a_text
        a_variable       a tkinter variable think this is the index to the state of
                         the check button
        a_function       command to config for button, no arg to function
    return a_fram with the tow controlls
    """
    # a_frame = Tk.Frame( p_frame, bd = 2, relief = Tk.SUNKEN, ) # height = 2 )

    a_frame = p_frame

    a_cb = Tk.Checkbutton( a_frame,
                           text      ="",
                           variable  = a_variable,    )

    a_cb.grid( row = 1,  column = 0 )

    a_button = Tk.Button( a_frame ,
                          width     = 10,
                          height    = 2,
                          text      = a_text )
    a_button.config( command = a_function  )
    a_button.grid( row = 0, column = 0 )

    if a_gui_style is not None:
        a_gui_style.style_checkbox( a_cb     )
        a_gui_style.style_button(   a_button )

    return a_frame


#--------------------------------------
class GUI(  ):
    """
    a class that implements a tab interface

    """
    #  ----------------------
    def __init__( self,   ):

        # self.file_name_list           = None
        # self.img_list                 = None    # will be list of images when loaded
        # self.image_widget_list        = None    # done by the gui in a kind of nasty way

        AppGlobal.gui       = self
        self.controller     = AppGlobal.controller
        self.parameters     = AppGlobal.parameters
        self.logger         = logging.getLogger( AppGlobal.logger_id + ".gui")
        self.logger.info("in class GUI init for the clip_board_1")
           # logger not currently used by her

        # ----- start building gui
        self.root           = Tk.Tk()

        self.text_in        = None    # init later

        #self.dispatch_dict   = {  }    # !! this is a test, may not want or use

        # radio button values !! this stuff needs some clean up
        self.url_to_wiki    = 999    # used in controller  set below for radio button index
        self.comma_sep_rb   = 999
        self.undent_rb      = 999
        self.lower_rb       = 999
        self.no_ws_rb       = 999

        # self.trans_combo_case     = [ ("Trans 1", "xxx" ),
        #                               ("Trans 2", "xxx" ),
        #                               ( "nothing", "yyy") ]
        # ( text, function_call ) and use index

        self.text_out       = None    # used in controller? set below

        #self.default_button = 0   # buttons not currently used at all

        self.button_var     = Tk.IntVar()
        self.button_var.set( self.controller.parameters.rb_num_on )

        # define here or in the panel with waring??


        # !! move to parameters
        self.search_list       = self.parameters.search_list

        self.replace_list      = self.parameters.replace_list
        self.search_many_list  = self.parameters.search_many_list

        self.cb_mulp_cmd_var   = Tk.IntVar()

        self.cb_star_cmd_var   = Tk.IntVar()
        self.cb_url_var        = Tk.IntVar()
        #self.cb_pb_cmd_var     = Tk.IntVar()
        self.cb_exe_file_var   = Tk.IntVar()

        self.cb_edit_txt_var   = Tk.IntVar()
        self.cb_iconify_var    = Tk.IntVar()    # ?? change to BooleanVar(master, True)

        self.root.title( f"{self.controller.app_name} mode: {AppGlobal.parameters.mode} " +
                         f" version: {self.controller.version}" )

        self.root.grid_rowconfigure(    0, weight=0 )
        self.root.grid_rowconfigure(    1, weight=0 )
        self.root.grid_rowconfigure(    2, weight=0 )
        # moving to frame placement
        # self.root.grid_rowconfigure(    3, weight=1 )
        # self.root.grid_rowconfigure(    4, weight=1 )

        self.root.grid_columnconfigure( 0, weight=1 )
        #self.root.grid_columnconfigure( 1, weight=1 )

        #placement = gui_ext.PlaceInGrid(  1, False )

        # ------------------ move to gui_n
        #self.parameters.gui_style
        self.gui_style     = gui_ext.GuiStyle( self.parameters.gui_style )
            # use as self. or through AppGlobal ??

    # -------------------------------------
    def gui_1( self,   ):
        """
        link to a gui build
        """
        self.ix_rb_index   = 0   # used to interpreter the radio button
            # !! add more info here

        self._menu( self.root )

        self._build_it( self.root )

        # self.cb_cmd_var.set(      self.controller.parameters.cmd_on        )
        self.cb_url_var.set(      self.controller.parameters.auto_url_on   )
        self.cb_star_cmd_var.set( self.controller.parameters.star_cmd_on     )
        self.cb_exe_file_var.set( self.controller.parameters.exe_file_on   )

        self.root.geometry( self.controller.parameters.win_geometry )
#        print( "next icon..." )
        if self.parameters.os_win:
#            https://stackoverflow.com/questions/14900510/changing-the-application-and-taskbar-icon-python-tkinter
            import ctypes
            myappid = self.parameters.icon # arbitrary string
            ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID( myappid )
            #rint( "in windows setting icon" )
            self.root.iconbitmap( self.parameters.icon )
        msg       = "... icon done...."
        print( msg )


    #  ----------------------
    def _build_it( self, root ):
        """
        What it says, read
        build the gui on the root frame

        """
        a_notebook          = ttk.Notebook( root, width = 100, height = 100,  )
        self.a_notebook     = a_notebook
        a_notebook.bind( "<<NotebookTabChanged>>", self.on_changed )
        a_notebook.pack( expand=1, fill="both" )

        # clipboard display at bottom of window
        a_frame              = self._make_clip_display( root )
        a_frame.pack( expand=1, fill="both" )

        # ---- add pages
        self._make_page_search_replace(   a_notebook )
        self._make_page_commands(         a_notebook )
        self._make_page_wiki_prog(        a_notebook )
        self._make_page_line_operations(  a_notebook )
        self._make_page_snip(             a_notebook )

    #---------------------
    def _menu (self, parent ) :
        """
        adds a menu bar to the parent
        returns:
            nothing

        """
        # ---- configuration
        menubar    = Tk.Menu( parent )

        a_menu     = Tk.Menu( menubar, tearoff = 0)

        a_menu.add_command( label   = "Show Parameters",
                            command = self.show_parms )

        a_menu.add_command( label   = "Edit Parameters File",
                            command = self.controller.os_open_parmfile )

        a_menu.add_command( label   = "Edit Snippets File",
                            command = self.controller.os_open_snippets )

        a_menu.add_command( label   = "Edit Snip Files",
                            command = self.controller.os_open_snip_file )


        if self.parameters.readme_fn is not None:

            a_menu.add_command( label   = "Edit Readme",
                                command = self.controller.os_open_readme )

        a_menu.add_command( label   = "Default Gui",
                            command = self.controller.default_gui  )

        a_menu.add_command( label   = "Wiki Gui",
                            command = self.controller.wiki_gui )

        a_menu.add_command( label   = "Edit Log File",
                            command = self.controller.os_open_logfile )

        a_menu.add_command( label   = "Restart",
                            command = self.controller.restart )


          # a_button = Tk.Button( a_frame , width=10, height=2, text = "Restart" )
          # a_button.config( command = self.controller.restart  )
          # self.gui_style.style_button( a_button )
          # placement.place( a_button )


        menubar.add_cascade( label  = "Configuration",   menu = a_menu )

        # ---- About
        a_menu = Tk.Menu( menubar, tearoff = 0)
        a_menu.add_command( label   = "Info", ) #command = self.__showInfo)
        a_menu.add_command( label   = "Check Update", ) #command = self.__chkUpdate)
        menubar.add_cascade( label  = "Aboutx", menu = a_menu)

        # ---- help
        a_menu = Tk.Menu( menubar, tearoff = 0 )

        a_menu.add_command( label   = "Show Help",
                            command = self.controller.os_open_help )

        a_menu.add_command( label   = "About",
                            command = self.controller.cb_about )

        menubar.add_cascade( label  = "Help", menu = a_menu)

        parent.config( menu = menubar )


   # ------------------------------------------
    def _make_star_command_frame( self, parent_frame,  ):
        """
        for *>cmd
        """
        a_frame  = Tk.LabelFrame(   parent_frame,
                           bg        = "blue", #self.parameters.bg_color_frame,
                           text      = "Commands...",
                           bd        = 2,
                           height    = 50,
                           width    = 100
                           )

        self.gui_style.style_labelframe( a_frame )

        ix_row        = 0
        ix_col        = 0

        a_cb = make_check_button( a_frame, "*>cmd",
                                  self.cb_star_cmd_var,
                                  self.controller.redo_if_star_cmd,
                                  a_gui_style = self.gui_style )
            # cmd_processor.do_if_cmd
        a_cb.grid( row = ix_row, column = ix_col )

        # self.gui_style.style_checkbox( a_cb ) this is ng causing color problem
        # not a check button styling needs to be there

        # ---- Add *>url
        ix_row                   = 1
        self.ix_rb_index        += 1
        ix_col                  += 1
        self.url_to_helpdb_rb   = ix_col

        self.make_and_place_transform_buttons_3 ( a_frame,
                            text = "Add\n *>url",
                            ix_row           = ix_row, ix_col = ix_col,
                            button_var       = self.button_var,
                            button_command   = AppGlobal.cmd_processor.transform_url_to_helpdb,
                            rb_index         = self.ix_rb_index )

        # ----  star_shell
        self.ix_rb_index         += 1
        ix_col                   += 1
        self.add_shell_rb         = ix_col

        self.make_and_place_transform_buttons_3 ( a_frame,
                            text             = "Add\n *>shell",
                            ix_row           = ix_row, ix_col = ix_col,
                            button_var       = self.button_var,
                            button_command   = AppGlobal.cmd_processor.transform_star_shell,
                            rb_index         = self.ix_rb_index )

        return a_frame

    # ---------------------------
    def make_and_place_transform_buttons_3( self,
                        a_frame,
                        text            = "no text",
                        ix_row          = 5,
                        ix_col          = 5,
                        button_var      = None,
                        button_command  = None,
                        rb_index        = 1 ):
        """
        rb below, centered no text
        make both buttons
        new meaning to command_button

        return radio button
        """
    #        print( f"for {text} index is { ix_col }, {ix_row}" )
        rbx   =  Tk.Radiobutton( a_frame,
                                 text         = "",
                                 variable     = button_var,
                                 value        = rb_index ,
                                 bg           = self.parameters.bg_color_frame)

        self.gui_style.style_radio_button( rbx )

        rbx.grid( row = ix_row,  column = ix_col, )   # sticky = rb_sticky )

        a_button = Tk.Button( a_frame ,
                              width=10,
                              height  = STD_BUTTON_HEIGHT,
                              text    = text,
                              bg      = self.parameters.bn_color_active)

        # do all without dict see smart_plug
        a_button.config( command = lambda: self.controller.button_switcher( a_button ) )
        # placement.place( a_button )

        a_button.grid( row = ix_row - 1, column = ix_col )

        self.controller.button_dict[ a_button ]       = button_command
        self.controller.dispatch_dict[rb_index]       = button_command

        self.gui_style.style_button( a_button )
        self.gui_style.style_button( a_button )

        return rbx

    # ------------------------------------------
    def _make_adjust_search_replace_row_frame( self, parent_frame,  ):

        """
        row frame goes across whole row begins with pressed always on
        second frame for transforms, third row, using frame in frame, lable frame
        return row_frame a frame for an entier row
        """
        row_frame           = Tk.Frame( parent_frame,
                                       bg = "yellow" ,
                                       borderwidth = 2,
                                       relief = "solid" )

        self.gui_style.style_frame( row_frame )

        #main_frame.grid_rowconfigure( 0, weight = 1 )
        #row_frame.grid_columnconfigure( 0, weight = 1 )

        ix_row         = 0
        ix_col         = 0
        ix_col        += 1

        x_frame  = self._make_pressed_always_on_frame_( row_frame )
        x_frame.grid( row = 0, column = 0 , sticky  = STICKY_ALL, )
        ix_col        += 1

        x_frame  = self._make_adjust_search_replace_frame( row_frame )
        x_frame.grid( row = ix_row, column = ix_col , sticky  = STICKY_ALL, )
        ix_col        += 1

        x_frame  = self._make_many_search_replace_frame( row_frame )
        x_frame.grid( row = ix_row, column = ix_col , sticky  = STICKY_ALL, )
        ix_col        += 1

        return row_frame

    # ---- >>>> Search and replace page
    # ------------------------------------------
    def _make_page_search_replace( self, a_notebook,  ):
        """
        first page
        """
        a_page          = ttk.Frame( a_notebook )
        a_notebook.add( a_page, text = 'Search and Replace' )
        placement      = gui_ext.PlaceInGrid(  0, False )

        a_frame         = self._make_a_row_frame_( a_page,
                         [ self._make_fixed_serach_replace_frame, ] )

        placement.place( a_frame )

        a_frame         = self._make_a_row_frame_( a_page,
                             [ self._make_many_search_replace_frame,
                               self._make_adjust_search_replace_frame,  ]  )
        placement.new_row( )
        placement.place( a_frame )

    # ---- >>> Commands and ?? chain ....
    # ------------------------------------------
    def _make_page_commands( self, a_notebook,  ):
        """
        put a page into the notebook
        """
        a_page    = ttk.Frame( a_notebook )    # page is just a frame
        a_notebook.add( a_page, text = 'Commands' )

        frame_function_list  = [ self._make_star_command_frame,
                                 self._make_chain_frame,
                                 self._make_off_unformat_frame,
                                 self._make_test_frame, ]
        a_frame              = self._make_a_row_frame_( a_page, frame_function_list  )
        a_frame.pack( expand = 1, fill = "both" )

    # ---- >>>> wiki/programming
    # ------------------------------------------
    def _make_page_wiki_prog( self, a_notebook,  ):
        """
        put page into the notebook
        """
        a_page     = ttk.Frame( a_notebook )
        a_notebook.add( a_page, text='Wiki/Programming' )

        placement  = gui_ext.PlaceInGrid(  0, False )

        frame_function_list  = [ self._make_wiki_transform_frame,
                                 self._make_python_frame     ]
        a_frame              = self._make_a_row_frame_( a_page, frame_function_list  )
        placement.place( a_frame )

        # frame_function_list  = [ self._make_python_frame ]
        # a_frame              = self._make_a_row_frame_( a_page, frame_function_list  )
        # #placement.new_row( )
        # placement.place( a_frame )

    # ---- >>>> Line operations page
    # ------------------------------------------
    def _make_page_line_operations( self, a_notebook,  ):
        """
        put page into the notebook
        """
        a_page     = ttk.Frame( a_notebook )
        a_notebook.add( a_page, text='Line Operations' )

        placement  = gui_ext.PlaceInGrid(  0, False )

        frame_function_list  = [ self._make_line_transform_frame,
                                 self._make_line_pairs_transform_frame ]
        a_frame              = self._make_a_row_frame_( a_page, frame_function_list  )
        placement.place( a_frame )

        # frame_function_list  = [ self._make_python_frame ]
        # a_frame              = self._make_a_row_frame_( a_page, frame_function_list  )
        # #placement.new_row( )
        # placement.place( a_frame )

    # ---- >>>> Snips and sinppets page
    # ------------------------------------------
    def _make_page_snip( self, a_notebook,  ):
        """
        put page into the notebook
        not quite the same pattern as other pages
        """
        a_page     = ttk.Frame( a_notebook )
        a_notebook.add( a_page, text = 'Snips and Snippets' )

        a_frame    = self._make_snip_frame( a_page )
        a_frame.pack( expand = 1, fill = "both" )


        # placement  = gui_ext.PlaceInGrid(  0, False )

        # frame_function_list  = [ self._make_line_transform_frame,
        #                          self._make_line_pairs_transform_frame ]
        # a_frame              = self._make_a_row_frame_( a_page, frame_function_list  )
        # placement.place( a_frame )

    # ------------------------------------------
    def _make_page_xxxx( self, a_notebook,  ):
        """
        put page into the notebook
        """
        a_page     = ttk.Frame( a_notebook )
        a_frame    = self._make_snip_frame( a_page )
        a_frame.pack( expand = 1, fill = "both" )
        a_notebook.add( a_page, text='Snips and Snippets' )

    # ------------------------------------------
    def _make_a_row_frame_( self, parent_frame, frame_function_list  ):

        """
        a row frame ... make conditional ..... a test
        frame_function_list   = list of functions to make a frame
                                func( a_frame,  )

        """
        row_frame           = Tk.Frame( parent_frame,
                                       bg = "yellow" ,
                                       borderwidth = 2,
                                       relief = "solid" )
        self.gui_style.style_frame( row_frame )

        placement = gui_ext.PlaceInGrid(  0, False )

        #main_frame.grid_rowconfigure( 0, weight = 1 )
        #row_frame.grid_columnconfigure( 0, weight = 1 )

        sub_frame  = self._make_pressed_always_on_frame_( row_frame )
        placement.place( sub_frame )

        for i_func in frame_function_list:
            sub_frame  = i_func( row_frame )
            placement.place( sub_frame )

        return row_frame

    # ------------------------------------------
    def _make_snip_frame(self, parent_frame, ):
        """
        not a history frame, really snipetts and snips
        ?? and add make snippets
        returns this frame, parent should paste
        """
        a_frame          = Tk.Frame( parent_frame )

        # --------- snippets
        snippets_temp    = AppGlobal.controller.snippets

        ( a_tlistbox, a_listbox ) = gui_ext.make_titled_listbox( a_frame, "Snippets" )
        #self.parameters.snippets
        for i_snip in snippets_temp:

            i_id, i_text  = i_snip
            #rint i_snip
            self.controller.snippets_dict.update( dict( [ i_snip ] ) )
                # i_snip a tuple in a list -- this reaches into controller
            a_listbox.insert( 'end', i_id )


        #rint self.controller.snippets
        a_listbox.bind( "<<ListboxSelect>>", self.controller.snippet_select )
        a_tlistbox.grid( column=0, row=0, sticky=( Tk.N, Tk.S, Tk.E, Tk.W) )

        # ----- snips = snipfiles --------------
        ( a_tlistbox, a_listbox ) = gui_ext.make_titled_listbox( a_frame, "SnipFiles" )
        a_tlistbox.grid( column=1, row=0, sticky=( Tk.N, Tk.S, Tk.E, Tk.W) )

        snip_files_temp   = AppGlobal.controller.snip_files
        for i_snip in  snip_files_temp:
            i_id, i_text  = i_snip
            #rint i_snip
            self.controller.snip_files_dict.update( dict( [ i_snip ] ) )
            a_listbox.insert( 'end', i_id )

        # still need to bind
        a_listbox.bind( "<<ListboxSelect>>", self.controller.snip_file_select )
        #a_tlistbox.grid( column=0, row=0, sticky=( Tk.N, Tk.S, Tk.E, Tk.W) )

        a_frame.grid_columnconfigure( 0, weight=1 )
        a_frame.grid_columnconfigure( 1, weight=1 )
        a_frame.grid_rowconfigure(    0, weight=1 )

        return a_frame

    # ---- >>>> make frames
    # ------------------------------------------
    def _make_python_frame( self, parent_frame,  ):
        """
        a subframe added to ....
        for python just started
        """
        a_frame  = Tk.LabelFrame(   parent_frame,
                           bg        = self.parameters.bg_color_frame,
                           text      = "Code, Programming",
                           bd        = 2,
                           height    = 50,
                           width     = 100
                           )

        self.gui_style.style_labelframe( a_frame )

        ix_row                  = 0
        ix_col                  = 0

        ix_row                  += 1

        self.ix_rb_index        += 1
        ix_col                  += 1
        self.url_to_helpdb_rb   = ix_col

        # ---- alling = signs
        self.ix_rb_index        += 1
        ix_col                  += 1
        self.allign_eq_sign_rb  = self.ix_rb_index

        self.make_and_place_transform_buttons_3 ( a_frame,
                            text             = "allign =",
                            ix_row = ix_row, ix_col = ix_col,
                            button_var       = self.button_var,
                            button_command   = AppGlobal.cmd_processor.transform_allign_eq_sign,
                            rb_index         = self.ix_rb_index )

        # ---- to _ py name -----
        self.ix_rb_index   += 1
        ix_col             += 1
        self.test_rb        = self.ix_rb_index

        self.make_and_place_transform_buttons_3 ( a_frame,
                            text = "to \n py name",
                            ix_row = ix_row, ix_col = ix_col,
                            button_var       = self.button_var,
                            button_command   = AppGlobal.cmd_processor.transform_to_name,
                            rb_index         = self.ix_rb_index )

        # ---- string to py list -----
        self.ix_rb_index   += 1
        ix_col             += 1
        self.test_rb        = self.ix_rb_index

        self.make_and_place_transform_buttons_3 ( a_frame,
                            text = "string to\n py list",
                            ix_row = ix_row,
                            ix_col = ix_col,
                            button_var       = self.button_var,
                            button_command   = AppGlobal.cmd_processor.transform_string_to_py_list,
                            rb_index         = self.ix_rb_index )

        return a_frame


    # ---- >>>> page One  line pair
    # # ------------------------------------------
    # def _make_line_pairs_transform_row_frame( self, parent_frame,  ):
    #     """
    #     row frame goes across whole row begins with pressed always on
    #     second frame for transforms, third row, using frame in frame, lable frame
    #     return row_frame a frame for an entier row
    #     """
    #     row_frame           = Tk.Frame( parent_frame, )

    #     self.gui_style.style_frame( row_frame )

    #     ix_row         = 0
    #     ix_col         = 0
    #     ix_col        += 1

    #     x_frame  = self._make_pressed_always_on_frame_( row_frame )
    #     x_frame.grid( row = 0, column = 0 , sticky  = STICKY_ALL, )
    #     ix_col        += 1

    #     x_frame  = self._make_line_pairs_transform_frame( row_frame )
    #     x_frame.grid( row = ix_row, column = ix_col , sticky  = STICKY_ALL, )
    #     ix_col        += 1

    #     return row_frame

    # ------------------------------------------
    def _make_line_pairs_transform_frame( self, parent_frame,  ):
        """
        search and replace, not adjustable
        put in a row frame
        """
        a_frame  = Tk.LabelFrame(   parent_frame,
                           bg        = self.parameters.bg_color_frame,
                           text      = "Line Pair Transforms",
                           bd        = 2,
                           height    = 50,
                           width    = 100
                           )

        self.gui_style.style_labelframe( a_frame )

        ix_row        = 2
        ix_col        = 0

        # ---- Alt Line Sort
        self.ix_rb_index          += 1
        ix_col                    += 1
        self.alt_line_sort_rb      = self.ix_rb_index

        self.make_and_place_transform_buttons_3 ( a_frame,
                            text             = "Alt Line \nSort 0",
                            ix_row           = ix_row,
                            ix_col           = ix_col,
                            button_var       = self.button_var,
                            button_command   = AppGlobal.cmd_processor.transform_alt_line_sort,
                            rb_index         = self.ix_rb_index )
        #self.controller.dispatch_dict[ix_rb_index]
              # = self.controller.cmd_processor.transform_alt_line_sort


        # ----  delete_dup  -----------------
        self.ix_rb_index    += 1
        ix_col              += 1
        self.comma_sep_rb   = ix_col

        self.make_and_place_transform_buttons_3( a_frame,
                text             = "Delete\nDuplicates",
                ix_row           = ix_row,   ix_col = ix_col,
                button_var       = self.button_var,
                button_command   = AppGlobal.cmd_processor.transform_lines_pairs_delete_duplicates,
                rb_index         = self.ix_rb_index )

        return a_frame


    # ------------------------------------------
    def _make_pressed_always_on_frame_( self, parent_frame,  ):
        """

        """
        a_frame          = Tk.Frame( parent_frame,
                                     bg             = self.parameters.bg_color_frame,
                                     borderwidth    = 2,
                                     relief         = "solid" )

        self.gui_style.style_frame( a_frame )

        ix_row        = 0
        ix_col        = 0

        spacer_frame      = Tk.Frame( a_frame,
                bg             = self.parameters.bg_color_frame,
                    # color does not show except as a line
                borderwidth    = 0,
                relief         = "flat",
                    # None "solid", "flat"   -> search on relief
                height         = 30,
                width          = 1 )

        spacer_frame.grid( row = ix_row, column= ix_col, )
            #   propagate = 0 )  does something but what
        spacer_frame.grid_propagate(0)


        pb_title     = "\n    Press:"
        rb_title     = "\n Alway On:"

        b_label = Tk.Label( a_frame, text = pb_title,  )
        b_label.grid( row = ix_row, column= ix_col )
        self.gui_style.style_label( b_label )

        ix_row        += 4

        a_label = Tk.Label( a_frame, text = rb_title,  )
        self.gui_style.style_label( a_label )
        a_label.grid( row = ix_row, column = ix_col )

        return a_frame

    # ------------------------------------------
    def _make_adjust_search_replace_frame( self, parent_frame,  ):
        """
        frame that perhaps should be a class instead ??
        this is for search and replace
        """
        #rint("make transform frame ")
        a_frame  = Tk.LabelFrame(  parent_frame,
                                   bg        = "white",
                                   text      = "Search/Replace Adj",
                                   bd        = 2,
                                   height    = 50,
                                   width    = 100
                                   )

        self.gui_style.style_labelframe( a_frame )

        ix_row        = 1
        ix_row        = 2

        #self.ix_rb_index   = 0
        ix_col        = 0

        # cbp3      = ttk.Labelframe( demoPanel, text='Pre-defined List' )
        a_widget       = Tk.ttk.Combobox( a_frame, values=self.search_list,
                                          state= "normal", font = ('Courier ', '10', 'bold'))
        a_widget.set( self.search_list[2] )  # manual choice of which
        a_widget.grid( row = ix_row, column = ix_col )
        self.search_widget = a_widget

        ix_col   += 1

        a_widget   = Tk.ttk.Combobox( a_frame, values=self.replace_list,
                                      state= "normal",
                                      font = ('Courier ', '10', 'bold'))
        a_widget.set( self.replace_list[2] )  # manual choice of which
        a_widget.grid( row = ix_row, column = ix_col )
        self.replace_widget    = a_widget

        ix_col   += 1

        txt      = "Search\nReplace"
        a_button = Tk.Button( a_frame, width = 15, height = 2, text = txt,   )
        a_button.config( command = lambda: self.controller.button_switcher( a_button ) )
        a_button.grid( row = ix_row, column = ix_col )
        # !!  need to put command into a dict, or is this too special ...

        self.gui_style.style_button( a_button )

        # this is for the regular button, radio button still needed
        self.controller.button_dict[ a_button ]       = self.controller.do_search_replace

        return a_frame

    # ------------------------------------------
    def _make_many_search_replace_frame( self, parent_frame,  ):
        """
        frame that perhaps should be a class instead ??
        this is for search and replace
        """
        #rint("make transform frame ")
        a_frame  = Tk.LabelFrame(  parent_frame,
                                   bg        = "white",
                                   text      = "Search/Replace Many",
                                   bd        = 2,
                                   height    = 50,
                                   width    = 100
                                   )

        self.gui_style.style_labelframe( a_frame )

        ix_row        = 1
        ix_row        = 2

        #self.ix_rb_index   = 0
        ix_col        = 0

        # cbp3      = ttk.Labelframe( demoPanel, text='Pre-defined List' )
        a_widget       = Tk.ttk.Combobox( a_frame, values = self.search_many_list,
                                          state= "normal",
                                          font = ('Courier ', '10', 'bold'),
                                          width = 50, )
        a_widget.set( self.search_many_list[2] )  # manual choice of whitch
        a_widget.grid( row = ix_row, column = ix_col )
        self.search_many_widget = a_widget

        ix_col   += 1

        txt      = "Search\nReplace"
        a_button = Tk.Button( a_frame,
                              width     = 15,
                              height    = STD_BUTTON_HEIGHT,
                              text      = txt,   )
        a_button.config( command = lambda: self.controller.button_switcher( a_button ) )
        self.gui_style.style_button( a_button )
        a_button.grid( row = ix_row, column = ix_col )
        # !!  need to put command into a dict, or is this too special ...

        # this is for the regular button, radio button still needed
        self.controller.button_dict[ a_button ]       = self.controller.do_search_replace_many

        return a_frame

    # ------------------------------------------
    def _make_fixed_serach_replace_frame( self, parent_frame,  ):
        """
        search and replace, not adjustable
        put in a row frame
        """
        a_frame  = Tk.LabelFrame(   parent_frame,
                           bg        = self.parameters.bg_color_frame,
                           text      = "Search/Replace Fixed",
                           bd        = 2,
                           height    = 50,
                           width    = 100
                           )

        self.gui_style.style_labelframe( a_frame )

        ix_row        = 2
        ix_col        = 0

         # -------- tab_to_space
        self.ix_rb_index         += 1
        ix_col                   += 1

        self.make_and_place_transform_buttons_3( a_frame,
                        text             = "Tab -> \nSpace",
                        ix_row           = ix_row,
                        ix_col           = ix_col,
                        button_var       = self.button_var,
                        button_command   = AppGlobal.cmd_processor.transform_tab_to_space,
                        rb_index         = self.ix_rb_index )

         # -------- semi -> nl
        self.ix_rb_index         += 1
        ix_col                   += 1

        self.make_and_place_transform_buttons_3( a_frame,
                        text             = "; -> \nnl",
                        ix_row           = ix_row,
                        ix_col           = ix_col,
                        button_var       = self.button_var,
                        button_command   = AppGlobal.cmd_processor.transform_semi_nl,
                        rb_index         = self.ix_rb_index )

        # -------- \ -> /
        self.ix_rb_index         += 1
        ix_col                   += 1

        self.make_and_place_transform_buttons_3 ( a_frame,
                        text             = "\\ -> \n/",
                        ix_row           = ix_row,
                        ix_col           = ix_col,
                        button_var       = self.button_var,
                        button_command   = clip_utils.transform_back_slash_slash,
                        rb_index         = self.ix_rb_index )

        # -------- space ->\nzip
        self.ix_rb_index         += 1
        ix_col                   += 1

        self.make_and_place_transform_buttons_3 ( a_frame,    text = "space ->\nzip",
                        ix_row           = ix_row,
                        ix_col           = ix_col,
                        button_var       = self.button_var,
                        button_command   = clip_utils.transform_space_zip,
                        rb_index         = self.ix_rb_index )

         # -------- space ->\nzip
        self.ix_rb_index         += 1
        ix_col                   += 1

        self.make_and_place_transform_buttons_3 ( a_frame,
                                    text             = "pdf ->\nmath",
                                    ix_row           = ix_row,
                                    ix_col           = ix_col,
                                    button_var       = self.button_var,
                                    button_command   = AppGlobal.cmd_processor.transform_pdf_math,
                                    rb_index         = self.ix_rb_index )

        # -------- transform_cap,
        self.ix_rb_index  += 1
        ix_col       += 1
        self.cap_rb   = ix_col

        self.make_and_place_transform_buttons_3 ( a_frame,
                                text             = "CAP",
                                ix_row           = ix_row,
                                ix_col           = ix_col,
                                button_var       = self.button_var,
                                button_command   = AppGlobal.cmd_processor.transform_cap,
                                rb_index         = self.ix_rb_index )

        # -------- transform_lower,
        self.ix_rb_index  += 1
        ix_col            += 1
        self.lower_rb    = ix_col

        self.make_and_place_transform_buttons_3 ( a_frame,
                                text                     = "lower",
                                ix_row                   = ix_row,
                                ix_col                   = ix_col,
                                button_var               = self.button_var,
                                button_command           = AppGlobal.cmd_processor.transform_lower,
                                rb_index                 = self.ix_rb_index )

        # -------- transform_no_ws,
        self.ix_rb_index      += 1
        ix_col           += 1
        self.no_ws_rb    = ix_col

        self.make_and_place_transform_buttons_3 ( a_frame,
                        text                     = "No WS",
                        ix_row = ix_row, ix_col  = ix_col,
                        button_var               = self.button_var,
                        button_command           = AppGlobal.cmd_processor.transform_no_ws,
                        rb_index                 = self.ix_rb_index )

        # -------- transform_less_ws
        self.ix_rb_index  += 1
        ix_col       += 1
        self.less_ws_rb    = ix_col

        self.make_and_place_transform_buttons_3 ( a_frame,
                        text                     = "Less WS",
                        ix_row = ix_row, ix_col  = ix_col,
                        button_var               = self.button_var,
                        button_command           = AppGlobal.cmd_processor.transform_less_ws,
                        rb_index                 = self.ix_rb_index )

        # ---------  comm sep  -----------------
        self.ix_rb_index         += 1
        ix_col              += 1
        self.comma_sep_rb   = ix_col

        self.make_and_place_transform_buttons_3 ( a_frame,
                        text             = "nl ->\n , sep",
                        ix_row           = ix_row,
                        ix_col           = ix_col,
                        button_var       = self.button_var,
                        button_command   = AppGlobal.cmd_processor.transform_comma_sep,
                        rb_index         = self.ix_rb_index )

        return a_frame

    # ------------------------------------------
    def _make_wiki_transform_frame( self, parent_frame,  ):
        """
        put in a row frame
        """
        a_frame  = Tk.LabelFrame(   parent_frame,
                           bg        = self.parameters.bg_color_frame,
                           text      = "Wiki Transforms",
                           bd        = 2,
                           height    = 50,
                           width    = 100
                           )

        self.gui_style.style_labelframe( a_frame )

        ix_row        = 2
        ix_col        = 0

        # ---- url to wiki
        self.ix_rb_index  += 1
        ix_col       += 1
        self.url_to_wiki_rb   = ix_col

        self.make_and_place_transform_buttons_3 ( a_frame,
                        text     = "URL to\n Wiki",
                        ix_row = ix_row,
                        ix_col = ix_col,
                        button_var       = self.button_var,
                        button_command   = AppGlobal.cmd_processor.transform_url_wiki,
                        rb_index         = self.ix_rb_index )

        # ---- upload_log - for wikis
        self.ix_rb_index        += 1
        ix_col             += 1
        self.x_file_up_rb        = self.ix_rb_index   ## !! is this right ??

        self.make_and_place_transform_buttons_3 ( a_frame,
                        text             = "wiki\nfile_upload",
                        ix_row           = ix_row,
                        ix_col           = ix_col,
                        button_var       = self.button_var,
                        button_command   = AppGlobal.cmd_processor.transform_upload_log,
                        rb_index         = self.ix_rb_index )

        return a_frame

    # ------------------------------------------
    def _make_line_transform_frame( self, parent_frame,  ):
        """
        search and replace, not adjustable
        put in a row frame
        """
        a_frame  = Tk.LabelFrame(   parent_frame,
                           bg        = self.parameters.bg_color_frame,
                           text      = "Line Transforms",
                           bd        = 2,
                           height    = 50,
                           width     = 100
                           )

        self.gui_style.style_labelframe( a_frame )

        ix_row        = 0
        ix_col        = 0


        # ix_row         = 0
        # ix_col         = 0
        # ix_col        += 1

        # x_frame  = self._make_pressed_always_on_frame_( a_frame )
        # x_frame.grid( row = ix_row, column = ix_col , sticky  = STICKY_ALL, )
        # ix_col        += 1

        # ---- transform_star_line
        self.ix_rb_index    += 1
        ix_col              += 1
        ix_row               = 1
        self.star_line_rb   = ix_col
            # adjust for new button -- think this really should be radio button
            # index or fails on second line

        self.make_and_place_transform_buttons_3 ( a_frame,    text = "* Lines",
                                   ix_row = ix_row,
                                   ix_col = ix_col,  # adjust for new button
                                   button_var       = self.button_var,
                                   button_command   = AppGlobal.cmd_processor.transform_star_line,
                                   rb_index         = self.ix_rb_index )


        # ---- transform_number_lines( self, in_text,  ):
        self.ix_rb_index         += 1
        ix_col                   += 1
        self.sage_rb             = self.ix_rb_index

        self.make_and_place_transform_buttons_3 ( a_frame,
                                text = "Line Num",
                                ix_row           = ix_row,
                                ix_col           = ix_col,
                                button_var       = self.button_var,
                                button_command   = AppGlobal.cmd_processor.transform_number_lines,
                                rb_index         = self.ix_rb_index )

        # ---- no_trailing_space( self, in_text,  ):
        self.ix_rb_index         += 1
        ix_col                   += 1
        self.sage_rb              = self.ix_rb_index

        self.make_and_place_transform_buttons_3 ( a_frame,
                        text             = "No Trail\nSpace",
                        ix_row           = ix_row,
                        ix_col           = ix_col,
                        button_var       = self.button_var,
                        button_command   = AppGlobal.cmd_processor.transform_no_trailing_space,
                        rb_index         = self.ix_rb_index )

        # ---- transform_no_around_space( self, in_text,  ):
        self.ix_rb_index         += 1
        ix_col                   += 1
        self.sage_rb              = self.ix_rb_index

        self.make_and_place_transform_buttons_3 ( a_frame,
                        text             = "No Lead. or\nTrail Space",
                        ix_row           = ix_row,
                        ix_col           = ix_col,
                        button_var       = self.button_var,
                        button_command   = AppGlobal.cmd_processor.transform_no_around_space,
                        rb_index         = self.ix_rb_index )
        # ---- Indent
        self.ix_rb_index      += 1
        ix_col                += 1
        self.indent_line_rb   = ix_col

        self.make_and_place_transform_buttons_3 ( a_frame,    text = "Indent",
                    ix_row = ix_row, ix_col = ix_col,
                    button_var               = self.button_var,
                    button_command           = AppGlobal.cmd_processor.transform_insert_spaces,
                    rb_index                 = self.ix_rb_index )

        # ----  un_dent  -----------------
        self.ix_rb_index  += 1
        ix_col            += 1
        self.undent_rb     = self.ix_rb_index

        self.make_and_place_transform_buttons_3 ( a_frame,
                    text             = "undent",
                    ix_row = ix_row, ix_col = ix_col,
                    button_var       = self.button_var,
                    button_command   = AppGlobal.cmd_processor.transform_un_dent,
                    rb_index         = self.ix_rb_index )

        # -------- transform_no_blank_lines
        self.ix_rb_index          += 1
        ix_col                    += 1
        self.alt_line_sort_rb      = self.ix_rb_index

        self.make_and_place_transform_buttons_3 (   a_frame,
                    text = "No Blank\nLines",
                    ix_row = ix_row, ix_col = ix_col,
                    button_var       = self.button_var,
                    button_command   = AppGlobal.cmd_processor.transform_no_blank_lines,
                    rb_index         = self.ix_rb_index )

        # ---- Line Sort -- single lines
        self.ix_rb_index          += 1
        ix_col                    += 1
        self.alt_line_sort_rb      = self.ix_rb_index

        self.make_and_place_transform_buttons_3 ( a_frame,
                    text             = "Line \nSort",
                    ix_row           = ix_row, ix_col = ix_col,
                    button_var       = self.button_var,
                    button_command   = AppGlobal.cmd_processor.transform_lines_sort,
                    rb_index         = self.ix_rb_index )

        # ---- Delete Duplicates and Sort -- single lines
        self.ix_rb_index          += 1
        ix_col                    += 1
        self.alt_line_sort_rb      = self.ix_rb_index

        self.make_and_place_transform_buttons_3 ( a_frame,
                    text = "Del Dup \nSort",
                    ix_row = ix_row,
                    ix_col = ix_col,
                    button_var       = self.button_var,
                    button_command   = AppGlobal.cmd_processor.transform_lines_delete_duplicates,
                    rb_index         = self.ix_rb_index )

        return a_frame

    # ------------------------------------------
    def _make_chain_frame( self, parent_frame,  ):
        """
        chain and related
        """
        a_frame  = Tk.LabelFrame(   parent_frame,
                           bg        = self.parameters.bg_color_frame,
                           text      = "Chain...",
                           bd        = 2,
                           height    = 50,
                           width    = 100
                           )

        self.gui_style.style_labelframe( a_frame )

        placement = gui_ext.PlaceInGrid(  99, False )

        txt      = "CHAIN\nLast Transform"
        a_button = Tk.Button( a_frame,
                              width     = 15,
                              height    = STD_BUTTON_HEIGHT,
                              text      = txt )
        a_button.config( command = self.controller.chain_transform  )
        self.gui_style.style_button( a_button )
        placement.place( a_button )

        # !! need to init from parms --- combine with chain
        a_cb = Tk.Checkbutton( a_frame, text="auto chain!!",   )
                #  variable = self.cb_iconify_var,    ) # value=0 )
        self.gui_style.style_checkbutton( a_cb )
        placement.place( a_cb )

        # !! need to init from parms
        a_cb = Tk.Checkbutton( a_frame,
                               text         = "iconify on use",
                               variable     = self.cb_iconify_var,    ) # value=0 )
        self.gui_style.style_checkbutton( a_cb )
        placement.place( a_cb )

        return a_frame

    # ------------------------------------------
    def _make_off_unformat_frame( self, parent_frame,  ):
        """
        off and unformatted
        """
        a_frame  = Tk.LabelFrame(   parent_frame,
                           bg        = self.parameters.bg_color_frame,
                           text      = "Off and Unformatted",
                           bd        = 2,
                           height    = 50,
                           width    = 100
                           )

        self.gui_style.style_labelframe( a_frame )

        ix_row        = 2
        ix_col        = 0

        # ----------- redo_off
        self.ix_rb_index    += 1
        ix_col              += 1
        self.trans_off_rb   = ix_col
        #txt                 = "off"

        # special case because does not call cmd_processor, perhaps should change this
        rb0 = self.make_and_place_transform_buttons_x ( a_frame,    text = "off",
                                           ix_row = ix_row, ix_col = ix_col,
                                           button_var       = self.button_var,
                                           button_command   = self.controller.redo_off,
                                           rb_index         = self.ix_rb_index )

        rb0.select() # default this button

        # -------- redo_unformatted
        self.ix_rb_index   += 1
        ix_col             += 1
        self.uformat_rb    = ix_col

        # special case because does not call cmd_processor, perhaps should change this
        self.make_and_place_transform_buttons_x ( a_frame,    text = "unformmated",
                                   ix_row = ix_row, ix_col = ix_col,
                                   button_var       = self.button_var,
                                   button_command   = self.controller.redo_unformatted,
                                   rb_index         = self.ix_rb_index )

        return a_frame

   # ------------------------------------------
    def _make_test_frame( self, parent_frame,  ):
        """
        what it says, read
        """
        a_frame  = Tk.LabelFrame(   parent_frame,
                           bg        = self.parameters.bg_color_frame,
                           text      = "Test Items, Stuff",
                           bd        = 2,
                           height    = 50,
                           width    = 100
                           )

        self.gui_style.style_labelframe( a_frame )

        ix_row        = 2
        ix_col        = 0

        # # ---------  delete_dup  -----------------
        # self.ix_rb_index    += 1
        # ix_col              += 1
        # self.comma_sep_rb   = ix_col

        # self.make_and_place_transform_buttons_3 ( a_frame,
            # text            = "new test",
            # ix_row           = ix_row,   ix_col = ix_col,
            # button_var       = self.button_var,
            # button_command   = AppGlobal.cmd_processor.transform_lines_pairs_delete_duplicates,
            # rb_index         = self.ix_rb_index )

        # -------- "Edit Dev\nNotes"
        self.ix_rb_index          += 1
        ix_col                    += 1
        self.alt_line_sort_rb      = self.ix_rb_index

        self.make_and_place_transform_buttons_3 (   a_frame,    text = "Edit Dev\nNotes",
                                                    ix_row = ix_row, ix_col = ix_col,
                                   button_var       = self.button_var,
                                   button_command   = AppGlobal.controller.bcb_edit_dev_notes,
                                   rb_index         = self.ix_rb_index )

        # # -------- transform_del_dups
        # self.ix_rb_index               += 1
        # ix_col                    += 1
        # self.alt_line_sort_rb      = self.ix_rb_index

        # self.make_and_place_transform_buttons_3 (   a_frame,    text = "Delete\nDups",
        #                                             ix_row = ix_row, ix_col = ix_col,
        #                            button_var       = self.button_var,
        #                            button_command   = AppGlobal.cmd_processor.transform_del_dups,
        #                            rb_index         = self.ix_rb_index )

        # -------- sage
        self.ix_rb_index         += 1
        ix_col                   += 1
        self.sage_rb              = self.ix_rb_index

        self.make_and_place_transform_buttons_3 ( a_frame,    text = "Sage",
                                   ix_row = ix_row,
                                   ix_col = ix_col,
                                   button_var       = self.button_var,
                                   button_command   = AppGlobal.cmd_processor.transform_sage,
                                   rb_index         = self.ix_rb_index )
        #self.controller.dispatch_dict[ix_rb_index]  = self.controller.cmd_processor.transform_sage

        # -------------------- if wiki
        if AppGlobal.parameters.include_wiki_buttons:
            pass

        #-------- test -----
        self.ix_rb_index        += 1
        ix_col             += 1
        self.test_rb        = self.ix_rb_index

        self.make_and_place_transform_buttons_3 ( a_frame,    text = "test",
                                   ix_row = ix_row, ix_col = ix_col,
                                   button_var       = self.button_var,
                                   button_command   = AppGlobal.cmd_processor.transform_to_camel,
                                   rb_index         = self.ix_rb_index )

        #-------- user_pages ------
        self.ix_rb_index         += 1
        ix_col                   += 1
        self.sage_rb      = self.ix_rb_index

        self.make_and_place_transform_buttons_3 ( a_frame,
                                    text = "UserPage",
                                    ix_row = ix_row, ix_col = ix_col,
                                    button_var       = self.button_var,
                                    button_command   = AppGlobal.cmd_processor.transform_user_pages,
                                    rb_index         = self.ix_rb_index )

        return a_frame

    # ------------------------------------------
    def _make_clip_display( self, parent_frame,  ):
        """
        make clipboard display area
        """
        frame0 = Tk.Frame( parent_frame )   # frame is not really needed laft over

        frame0.grid_rowconfigure(    0, weight=1 )
        frame0.grid_columnconfigure( 0, weight=1 )

        text0 = Tk.Text( frame0 , width=50, height=10 )
        #text0.takefocus = 0
        #text0.config(state=Tk.DISABLED)

        s_text0 = Tk.Scrollbar( frame0  )  # LEFT left
        s_text0.grid( row=0, column=1, sticky = Tk.N + Tk.S  )
        s_text0.config( command=text0.yview )

        text0.config( yscrollcommand=s_text0.set )
        text0.grid( row=0, column=0, sticky = Tk.N + Tk.S + Tk.E + Tk.W  )

        self.text_in  = text0   # not very ellegant

#        # spacer
#        s_frame = Tk.Frame( bframe, bg ="green", height=20 ) # width=30  )
#        s_frame.grid( row=0, column=0  )

        return frame0

    # --------------------------
    def on_changed( self, event ):
        # tab_parent.bind("<<NotebookTabChanged>>", on_tab_selected)
        # np.bind("<<NotebookTabChanged>>", self.on_changed )
        print( f"on_changed  {event}" )
        print( self.get_info() )

    # --------------------------
    def run_gui( self ):
        """
        what it says

        """
        self.root.mainloop()

    # --------------------------
    def get_info( self ):
        """
        needs doc -- left over from notebook demo, delete

        """
        msg         =  "get_info\n"
        #msg    =  f"{msg}{(self.nb ).tab( self.nb.select(), "text" )}"
        nb_frame    = self.a_notebook.select()

        msg         =  f"{msg}nb_frame{nb_frame} \n"

        msg         =  f"{msg}text on the tab{self.a_notebook.tab( nb_frame, 'text' )}\n"
        # same more compct
        msg         = ( f"{msg}text on the tab: "
                       f"{self.a_notebook.tab( self.a_notebook.select(), 'text' )}\n" )
        return msg

    # ---------------------
    def print_info( self ):
        msg     = self.get_info()
        print( msg )

    #----------------------------------------------------------------------
    def show_parms(self, ):
        """
        what it says, read
        """
        msg     = f"{AppGlobal.parameters}"
        title   = "Parameters"
        #rint( msg )
        self.write_gui_wt( title, msg )

    #----------------------------------------------------------------------
    def write_gui_wt(self, title, a_string ):
        """
        write to gui with a title.
        title     the title
        a_string  additional stuff to write
        make a better function with title = ""  ??
        title the string with some extra formatting
        clear and write string to input area
        """
        self.write_gui( f" =============== {title} ==> \n{a_string}"  )

    #----------------------------------------------------------------------
    def write_gui(self, string ):
        """
        clear and write string to display area
        leave it disabled
        """
        self.text_in['state'] = 'normal'       # normal or disabled
        self.text_in.delete( 1.0, Tk.END )
        self.text_in.insert( Tk.END, string )
        self.text_in['state'] = 'disabled'

    #----------------------------------------------------------------------
    def iconify_if(self, ):
        """
        iconify ( or other geo change depending on whatever, here gui )
        """
        if self.cb_iconify_var.get():      # minimize on use
            self.root.iconify()    # !! refactor to gui.iconify


    # both of these in use !! why or explain
    # ---------------------------
    def make_and_place_transform_buttons_x( self, a_frame,
                                                text            = "no text",
                                                ix_row          = 5,
                                                ix_col          = 5,
                                                button_var      = None,
                                                button_command  = None,
                                                rb_index        = 1 ):
        """
        special case for commands that call into the controller not the command class
        rb below, centered no text
        make both buttons
        """
        #rint( f"for {text} index is { ix_col }, {ix_row}" )
        rbx   =  Tk.Radiobutton( a_frame, text= "",
                                  variable = button_var, value = rb_index )
        rbx.grid( row = ix_row,  column = ix_col, )   # sticky = rb_sticky )

        a_button = Tk.Button( a_frame , width=10, height=2, text = text )
        a_button.config( command = button_command  )
        # placement.place( a_button )
        a_button.grid( row = ix_row - 1, column = ix_col )

        self.gui_style.style_radio_button( rbx )
        self.gui_style.style_button( a_button )

        return rbx


# --------------------
if __name__ == "__main__":
    #----- run the full app
    import clip_board
    clip_board.main()
    #app  = clip_board.App( None, None



