@@ -106,7 +106,7 @@ def __init__(self, parent, config,
106106 self ._old_use_transparency = self ._config_options ['use_transparency' ][1 ]
107107
108108 ''' Config window parameters check '''
109- logger .error ('DE \n \n check params\n {0}\n {1}' .format (self ._cnf .saved_params , self ._cnf .params ))
109+ # logger.error('DE \n\ncheck params\n{0}\n{1}'.format(self._cnf.saved_params, self._cnf.params))
110110 for a_key in self ._cnf .saved_params .keys ():
111111 if self ._cnf .saved_params [a_key ] != self ._cnf .params [a_key ]:
112112 self ._cnf .dirty_config = True
@@ -548,7 +548,7 @@ def __init__(self,
548548 self ._parent = parent
549549 self ._cnf = config
550550 self .edit_string = string
551- self ._caption = ' Parameter: '
551+ self ._caption = ' Parameter value '
552552 self ._string = self ._orig_string = string
553553
554554 self .Y , self .X = self ._parent .getbegyx ()
@@ -570,14 +570,12 @@ def __init__(self,
570570
571571 self ._too_small = False
572572
573- self ._opening = True
574-
575573 # add line editor
576574 self ._widgets [0 ] = SimpleCursesLineEdit (
577575 parent = self ._win ,
578- width = self .maxX - len ( self . _caption ) ,
579- begin_y = self .Y ,
580- begin_x = self .X + len ( self . _caption ) - 1 ,
576+ width = self .maxX - 2 ,
577+ begin_y = self .Y + 1 ,
578+ begin_x = self .X + 1 ,
581579 boxed = False ,
582580 has_history = False ,
583581 caption = '' ,
@@ -587,14 +585,15 @@ def __init__(self,
587585 cursor_color = curses .color_pair (8 ),
588586 unfocused_color = curses .color_pair (5 ),
589587 string_changed_handler = self ._string_changed )
590- self ._widgets [0 ].bracket = True
588+ self ._widgets [0 ].string = string
589+ self ._widgets [0 ].bracket = False
591590 self ._widgets [0 ]._use_paste_mode = True
592- self ._widgets [0 ]._paste_mode = False # enables direct insersion of ? and \
591+ self ._widgets [0 ]._paste_mode = True # enables direct insersion of ? and \
593592 self ._line_editor = self ._widgets [0 ]
594593
595594 # add horizontal push buttons
596595 self ._h_buttons = SimpleCursesHorizontalPushButtons (
597- Y = 2 , captions = ('OK' , 'Cancel' ),
596+ Y = 3 , captions = ('OK' , 'Cancel' ),
598597 color_focused = curses .color_pair (9 ),
599598 color = curses .color_pair (4 ),
600599 bracket_color = curses .color_pair (5 ),
@@ -623,51 +622,50 @@ def resize(self, parent):
623622 def show (self ):
624623 self ._win .addstr (0 , 0 , self ._caption , curses .color_pair (5 ))
625624 try :
626- self ._win .addstr (4 , 3 , '─' * (self .maxX - 6 ), curses .color_pair (3 ))
625+ self ._win .addstr (5 , 3 , '─' * (self .maxX - 6 ), curses .color_pair (3 ))
627626 except :
628- self ._win .addstr (4 , 3 , '─' .encode ('utf-8' ) * (self .maxX - 6 ), curses .color_pair (3 ))
629- self ._win .addstr (4 , int ((self .maxX - 6 ) / 2 ), ' Help ' , curses .color_pair (4 ))
627+ self ._win .addstr (5 , 3 , '─' .encode ('utf-8' ) * (self .maxX - 6 ), curses .color_pair (3 ))
628+ self ._win .addstr (5 , int ((self .maxX - 6 ) / 2 ), ' Help ' , curses .color_pair (4 ))
630629
631630
632- self ._win .addstr (5 , 5 , 'TAB' , curses .color_pair (4 ))
631+ self ._win .addstr (6 , 5 , 'TAB' , curses .color_pair (4 ))
633632 self ._win .addstr (', ' , curses .color_pair (5 ))
634633 self ._win .addstr ('Down' , curses .color_pair (4 ))
635634 self ._win .addstr (' / ' , curses .color_pair (5 ))
636635 self ._win .addstr ('Up' , curses .color_pair (4 ))
637636 self ._win .addstr (' Go to next / previous field.' , curses .color_pair (5 ))
638- self ._win .addstr (6 , 5 , 'ENTER' , curses .color_pair (4 ))
637+ self ._win .addstr (7 , 5 , 'ENTER' , curses .color_pair (4 ))
639638 self ._win .addstr (' When in Line Editor, go to next field.' , curses .color_pair (5 ))
640639 step = 0
641640 if self ._orig_string :
642- self ._win .addstr (7 , 5 , 'r' , curses .color_pair (4 ))
641+ self ._win .addstr (8 , 5 , 'r' , curses .color_pair (4 ))
643642 self ._win .addstr (', ' , curses .color_pair (5 ))
644643 self ._win .addstr ('^R' , curses .color_pair (4 ))
645- self ._win .addstr (7 , 23 , 'Revert to saved values (' , curses .color_pair (5 ))
644+ self ._win .addstr (8 , 23 , 'Revert to saved values (' , curses .color_pair (5 ))
646645 self ._win .addstr ('^R' , curses .color_pair (4 ))
647- self ._win .addstr (' when in Line Editor).' , curses .color_pair (5 ))
646+ self ._win .addstr (' in Line Editor).' , curses .color_pair (5 ))
648647 step = 1
649- self ._win .addstr (7 + step , 5 , 'Esc' , curses .color_pair (4 ))
650- self ._win .addstr (7 + step , 23 , 'Cancel operation.' , curses .color_pair (5 ))
648+ self ._win .addstr (8 + step , 5 , 'Esc' , curses .color_pair (4 ))
649+ self ._win .addstr (8 + step , 23 , 'Cancel operation.' , curses .color_pair (5 ))
651650
652- self ._win .addstr (8 + step , 5 , 's' , curses .color_pair (4 ))
651+ self ._win .addstr (9 + step , 5 , 's' , curses .color_pair (4 ))
653652 self ._win .addstr (' / ' , curses .color_pair (5 ))
654653 self ._win .addstr ('q' , curses .color_pair (4 ))
655- self ._win .addstr (8 + step , 23 , 'Save / Cancel (not in Line Editor).' , curses .color_pair (5 ))
654+ self ._win .addstr (9 + step , 23 , 'Save / Cancel (not in Line Editor).' , curses .color_pair (5 ))
656655
657- self ._win .addstr (9 + step , 5 , '?' , curses .color_pair (4 ))
658- self ._win .addstr (9 + step , 23 , 'Line editor help (in Line Editor).' , curses .color_pair (5 ))
656+ self ._win .addstr (10 + step , 5 , '?' , curses .color_pair (4 ))
657+ self ._win .addstr (10 + step , 23 , 'Line editor help (in Line Editor).' , curses .color_pair (5 ))
659658 self ._win .refresh ()
660659 self .refresh_win ()
661660
662661 def refresh_win (self ):
663662 if not self ._too_small :
664663 self ._line_editor .show (
665- self ._win , opening = self . _opening ,
666- new_y = self .Y ,
667- new_x = self .X + len ( self . _caption ) - 1 )
664+ self ._win , opening = False ,
665+ new_y = self .Y + 1 ,
666+ new_x = self .X + 1 )
668667 self ._widgets [1 ].show ()
669668 self ._widgets [2 ].show ()
670- self ._opening = False
671669
672670 def _update_focus (self ):
673671 # use _focused here to avoid triggering
@@ -798,11 +796,12 @@ def __init__(self,
798796 focus ,
799797 startY = 1 ,
800798 startX = 1 ,
801- max_lines = 10 ,
799+ max_lines = 11 ,
802800 from_config = True ):
803801 self ._cnf = config
804802 self ._orig_params = deepcopy (self ._cnf .params )
805- logger .error ('DE orig params = {}' .format (self ._orig_params ))
803+ if logger .isEnabledFor (logging .DEBUG ):
804+ logger .debug ('original parameters = {}' .format (self ._orig_params ))
806805 self ._orig_player = player
807806 self ._win = win
808807 self ._focus = focus
@@ -877,6 +876,7 @@ def active(self):
877876 @active .setter
878877 def active (self , val ):
879878 self ._selections [self ._player ][2 ] = val
879+ logger .error ('DE \n \n selections\n \n {}' .format (self ._selections ))
880880
881881 @property
882882 def params (self ):
@@ -891,12 +891,12 @@ def _dict_to_list(self):
891891 """ convert self._working_params dict
892892 to self._items dict, and set self.active
893893 """
894- logger .error ('DE\n ' )
895- logger .error ('DE working params = {}' .format (self ._working_params ))
894+ # logger.error('DE\n')
895+ # logger.error('DE working params = {}'.format(self._working_params))
896896 for a_param_set in self ._working_params .keys ():
897897 for i , a_param in enumerate (self ._working_params [a_param_set ]):
898898 if i == 0 :
899- logger .error ('DE a_param = {}' .format (a_param ))
899+ # logger.error('DE a_param = {}'.format(a_param))
900900 self ._selections [a_param_set ][2 ] = int (a_param ) - 1
901901 else :
902902 self ._items_dict [a_param_set ].append (a_param )
@@ -1022,11 +1022,15 @@ def save_results(self):
10221022 """ pass working parameters to original parameters
10231023 effectively saving any changes.
10241024 """
1025- logger .error ('DE ===== save_results' )
1025+ logger .error ('DE save_results' )
1026+ logger .error ('DE 1 working_params = {}' .format (self ._working_params ))
10261027 self ._list_to_dict ()
1028+ logger .error ('DE 2 working_params = {}' .format (self ._working_params ))
10271029 self .check_parameters ()
1030+ logger .error ('DE 3 working_params = {}' .format (self ._working_params ))
10281031 self ._orig_params = deepcopy (self ._working_params )
1029- logger .error ('DE orig params = {}' .format (self ._orig_params ))
1032+ if logger .isEnabledFor (logging .DEBUG ):
1033+ logger .debug ('new parameters = {}' .format (self ._orig_params ))
10301034
10311035 def keypress (self , char ):
10321036 """ Extra parameters keypress
@@ -1045,7 +1049,9 @@ def keypress(self, char):
10451049 ord ('\r ' ), ord (' ' ), ord ('l' ),
10461050 curses .KEY_RIGHT , ord ('s' )):
10471051 # activate selection
1052+ logger .error ('DE active ={}, selection={}' .format (self .active , self .selection ))
10481053 self .active = self .selection
1054+ logger .error ('DE active ={}, selection={}' .format (self .active , self .selection ))
10491055 if self .from_config :
10501056 self .refresh_win ()
10511057 else :
@@ -1129,7 +1135,7 @@ def keypress(self, char):
11291135
11301136class PyRadioSelectPlayer (object ):
11311137
1132- maxY = 13
1138+ maxY = 14
11331139 maxX = 72
11341140 selection = 0
11351141
@@ -1146,7 +1152,8 @@ class PyRadioSelectPlayer(object):
11461152 mlength = 13
11471153
11481154 def __init__ (self , config , parent , player ):
1149- logger .error ('DE player = {}' .format (player ))
1155+ if logger .isEnabledFor (logging .DEBUG ):
1156+ logger .debug ('current players = {}' .format (player ))
11501157 self ._cnf = config
11511158 self ._parent = parent
11521159 self ._parent_maxY , self ._parent_maxX = parent .getmaxyx ()
@@ -1235,13 +1242,13 @@ def _populate_players(self):
12351242 if ap not in parts :
12361243 self ._players .append ([ap , False , True ])
12371244
1238- logger .error ('DE playsers = {}' .format (self ._players ))
1245+ if logger .isEnabledFor (logging .DEBUG ):
1246+ logger .debug ('all players parameters = {}' .format (self ._players ))
12391247
12401248 def refresh_win (self , do_params = False ):
12411249 self ._win .bkgdset (' ' , curses .color_pair (3 ))
12421250 self ._win .erase ()
12431251 self ._win .box ()
1244- logger .error ('DE Player refresh_win: editing = {}' .format (self .editing ))
12451252 if self .editing == 0 :
12461253 self ._win .addstr (
12471254 0 , int ((self .maxX - len (self ._title )) / 2 ),
@@ -1318,6 +1325,8 @@ def keypress(self, char):
13181325 0 - Accept changes
13191326 1 - Cancel
13201327 2 - Display editor help
1328+ 3 - Editor is visible
1329+ 4 - Editor exited
13211330 """
13221331 if self .editing == 0 :
13231332 if char in (9 , ):
@@ -1408,29 +1417,44 @@ def keypress(self, char):
14081417 elif ret == 4 :
14091418 # edit parameter
14101419 self .editing = 2
1420+ self ._parameter_editor = ExtraParametersEditor (
1421+ self ._win ,
1422+ self ._cnf ,
1423+ string = self ._extra ._items [self ._extra .selection ])
14111424 self .refresh_win ()
1425+ return 3
14121426 elif ret == 5 :
14131427 # add parameter
14141428 self ._parameter_editor = ExtraParametersEditor (
14151429 self ._win ,
14161430 self ._cnf )
14171431 self .editing = 1
14181432 self .refresh_win ()
1433+ return 3
14191434
14201435 else :
14211436 # return from parameter editor
14221437 # adding or editing a parameter
14231438 ret = self ._parameter_editor .keypress (char )
14241439 if ret == 0 :
14251440 # accept parameter or cancel
1426- self .editing = 0
14271441 if self ._parameter_editor .edit_string :
1428- self ._extra ._items .append (self ._parameter_editor .edit_string )
1429- self ._extra .selection = len (self ._extra ._items ) - 1
1430- if logger .isEnabledFor (logging .DEBUG ):
1431- logger .debug ('New parameter: ' + self ._extra ._items [- 1 ])
1442+ if self .editing == 1 :
1443+ ''' add parameter '''
1444+ self ._extra ._items .append (self ._parameter_editor .edit_string )
1445+ self ._extra .selection = len (self ._extra ._items ) - 1
1446+ if logger .isEnabledFor (logging .DEBUG ):
1447+ logger .debug ('New parameter: ' + self ._extra ._items [- 1 ])
1448+ else :
1449+ ''' change parameter '''
1450+ self ._extra ._items [self ._extra .selection ] = self ._parameter_editor .edit_string
1451+ if logger .isEnabledFor (logging .DEBUG ):
1452+ logger .debug ('New parameter value: ' + self ._parameter_editor .edit_string )
1453+
1454+ self .editing = 0
14321455 self .refresh_win (True )
14331456 self ._parameter_editor = None
1457+ return 4
14341458 elif ret == 2 :
14351459 # show editor help
14361460 return ret
0 commit comments