<s> __copyright__ = "<STR_LIT>" <EOL> import wx , wx . stc <EOL> from Cura . gui . util import gcodeTextArea <EOL> from Cura . util import profile <EOL> class alterationPanel ( wx . Panel ) : <EOL> def __init__ ( self , parent , callback ) : <EOL> wx . Panel . __init__ ( self , parent , - <NUM_LIT:1> ) <EOL> self . callback = callback <EOL> self . alterationFileList = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> if int ( profile . getMachineSetting ( '<STR_LIT>' ) ) > <NUM_LIT:1> : <EOL> self . alterationFileList += [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . alterationFileList += [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> if int ( profile . getMachineSetting ( '<STR_LIT>' ) ) > <NUM_LIT:2> : <EOL> self . alterationFileList += [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> if int ( profile . getMachineSetting ( '<STR_LIT>' ) ) > <NUM_LIT:3> : <EOL> self . alterationFileList += [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> if int ( profile . getMachineSetting ( '<STR_LIT>' ) ) > <NUM_LIT:4> : <EOL> self . alterationFileList += [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . currentFile = None <EOL> self . textArea = gcodeTextArea . GcodeTextArea ( self ) <EOL> self . list = wx . ListBox ( self , choices = self . alterationFileList , style = wx . LB_SINGLE ) <EOL> self . list . SetSelection ( <NUM_LIT:0> ) <EOL> self . Bind ( wx . EVT_LISTBOX , self . OnSelect , self . list ) <EOL> self . textArea . Bind ( wx . EVT_KILL_FOCUS , self . OnFocusLost , self . textArea ) <EOL> self . textArea . Bind ( wx . stc . EVT_STC_CHANGE , self . OnFocusLost , self . textArea ) <EOL> sizer = wx . GridBagSizer ( ) <EOL> sizer . Add ( self . list , ( <NUM_LIT:0> , <NUM_LIT:0> ) , span = ( <NUM_LIT:5> , <NUM_LIT:1> ) , flag = wx . EXPAND ) <EOL> sizer . Add ( self . textArea , ( <NUM_LIT:5> , <NUM_LIT:0> ) , span = ( <NUM_LIT:5> , <NUM_LIT:1> ) , flag = wx . EXPAND ) <EOL> sizer . AddGrowableCol ( <NUM_LIT:0> ) <EOL> sizer . AddGrowableRow ( <NUM_LIT:0> ) <EOL> sizer . AddGrowableRow ( <NUM_LIT:5> ) <EOL> sizer . AddGrowableRow ( <NUM_LIT:6> ) <EOL> sizer . AddGrowableRow ( <NUM_LIT:7> ) <EOL> self . SetSizer ( sizer ) <EOL> self . loadFile ( self . alterationFileList [ self . list . GetSelection ( ) ] ) <EOL> self . currentFile = self . list . GetSelection ( ) <EOL> def OnSelect ( self , e ) : <EOL> self . loadFile ( self . alterationFileList [ self . list . GetSelection ( ) ] ) <EOL> self . currentFile = self . list . GetSelection ( ) <EOL> def loadFile ( self , filename ) : <EOL> self . textArea . SetValue ( profile . getAlterationFile ( filename ) ) <EOL> def OnFocusLost ( self , e ) : <EOL> if self . currentFile == self . list . GetSelection ( ) : <EOL> profile . setAlterationFile ( self . alterationFileList [ self . list . GetSelection ( ) ] , self . textArea . GetValue ( ) ) <EOL> self . callback ( ) <EOL> def updateProfileToControls ( self ) : <EOL> self . OnSelect ( None ) </s>
