<s> from collections import OrderedDict <EOL> import datetime <EOL> import wx <EOL> import wx . lib . agw . ribbon as RB <EOL> from wx . lib . pubsub import pub as Publisher <EOL> from odmtools . common . exceptions import EmptySelection <EOL> from odmtools . controller . frmAddPoints import AddPoints <EOL> from odmtools . controller . frmDataFilters import frmDataFilter <EOL> from odmtools . controller . frmChangeValue import frmChangeValue <EOL> from frmFlagValues import frmFlagValues <EOL> from odmtools . controller . frmLinearDrift import frmLinearDrift <EOL> from odmtools . controller . frmAbout import frmAbout <EOL> import wizSave <EOL> from odmtools . common import * <EOL> import pandas as pd <EOL> import logging <EOL> from odmtools . common . logger import LoggerTool <EOL> tool = LoggerTool ( ) <EOL> logger = tool . setupLogger ( __name__ , __name__ + '<STR_LIT>' , '<STR_LIT:w>' , logging . DEBUG ) <EOL> [ wxID_PANEL1 , wxID_RIBBONPLOTTIMESERIES , wxID_RIBBONPLOTPROB , wxID_RIBBONPLOTHIST , wxID_RIBBONPLOTBOX , <EOL> wxID_RIBBONPLOTSUMMARY , wxID_RIBBONPLOTTSTYPE , wxID_RIBBONPLOTTSCOLOR , wxID_RIBBONPLOTTSLEGEND , wxID_RIBBONPLOTBOXTYPE , <EOL> wxID_RIBBONPLOTHISTTYPE , wxID_RIBBONPLOTHISTBIN , wxID_RIBBONPLOTDATEEND , wxID_RIBBONPLOTDATEREFRESH , <EOL> wxID_RIBBONPLOTDATEFULL , wxID_RIBBONEDITSERIES , wxID_RIBBONEDITDERIVE , wxID_RIBBONEDITRESTORE , wxID_RIBBONEDITSAVE , <EOL> wxID_RIBBONEDITCHGVALUE , wxID_RIBBONEDITINTEROPOLATE , wxID_RIBBONEDITFLAG , wxID_RIBBONEDITADDPOINT , <EOL> wxID_RIBBONEDITDELPOINT , wxID_RIBBONEDITSCRIPTEXECUTE , wxID_RIBBONEDITSCRIPTOPEN , wxID_RIBBONEDITSCRIPTNEW , <EOL> wxID_RIBBONEDITSCRIPTSAVE , wxID_RIBBONVIEWPLOT , wxID_RIBBONVIEWTABLE , wxID_RIBBONVIEWSERIES , wxID_RIBBONVIEWCONSOLE , <EOL> wxID_RIBBONVIEWSCRIPT , wxID_RIBBONPLOTBLANKBTN , wxID_FileMenu , wxID_STARTDPDATE , wxID_ENDDPDATE , wxID_FRAME1SPINCTRL1 , <EOL> wxID_RIBBONEDITFILTER , wxID_RIBBONEDITRECORD , wxID_RIBBONEDITLINFILTER , wxID_RIBBONPLOTDATEAPPLY , <EOL> wxID_RIBBONEDITRESETFILTER , wxID_RIBBONRECORDNEW , wxID_RIBBONRECORDOPEN , wxID_RIBBONRECORDSAVE ] = [ wx . NewId ( ) for <EOL> _init_ctrls in <EOL> range ( <NUM_LIT> ) ] <EOL> class mnuRibbon ( RB . RibbonBar ) : <EOL> def _init_ctrls ( self , prnt ) : <EOL> RB . RibbonBar . __init__ ( self , name = '<STR_LIT>' , parent = prnt , id = wxID_PANEL1 ) <EOL> self . SetArtProvider ( RB . RibbonAUIArtProvider ( ) ) <EOL> self . SetFont ( wx . Font ( <NUM_LIT:9> , wx . SWISS , wx . NORMAL , wx . NORMAL , False , u'<STR_LIT>' ) ) <EOL> fileMenu = RB . RibbonPage ( self , wxID_FileMenu , "<STR_LIT>" ) <EOL> home = RB . RibbonPage ( self , wx . ID_ANY , "<STR_LIT>" ) <EOL> plot_panel = RB . RibbonPanel ( home , wx . ID_ANY , "<STR_LIT>" , wx . NullBitmap , wx . DefaultPosition , wx . DefaultSize , <EOL> RB . RIBBON_PANEL_NO_AUTO_MINIMISE ) <EOL> self . plots_bar = RB . RibbonButtonBar ( plot_panel , wx . ID_ANY ) <EOL> self . plots_bar . AddSimpleButton ( wxID_RIBBONPLOTTIMESERIES , "<STR_LIT>" , tsa_icon . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . plots_bar . AddSimpleButton ( wxID_RIBBONPLOTPROB , "<STR_LIT>" , probability . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . plots_bar . AddSimpleButton ( wxID_RIBBONPLOTHIST , "<STR_LIT>" , histogram . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . plots_bar . AddSimpleButton ( wxID_RIBBONPLOTBOX , "<STR_LIT>" , box_whisker . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . plots_bar . AddSimpleButton ( wxID_RIBBONPLOTSUMMARY , "<STR_LIT>" , summary . GetBitmap ( ) , "<STR_LIT>" ) <EOL> PlotOptions_panel = RB . RibbonPanel ( home , wx . ID_ANY , "<STR_LIT>" , wx . NullBitmap , wx . DefaultPosition , <EOL> wx . DefaultSize , RB . RIBBON_PANEL_NO_AUTO_MINIMISE ) <EOL> self . PlotsOptions_bar = RB . RibbonButtonBar ( PlotOptions_panel , wx . ID_ANY ) <EOL> self . PlotsOptions_bar . AddDropdownButton ( wxID_RIBBONPLOTTSTYPE , "<STR_LIT>" , plot_type . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . PlotsOptions_bar . AddSimpleButton ( wxID_RIBBONPLOTTSLEGEND , "<STR_LIT>" , legend . GetBitmap ( ) , <EOL> help_string = "<STR_LIT>" , kind = <NUM_LIT> ) <EOL> self . PlotsOptions_bar . AddSimpleButton ( wxID_RIBBONPLOTBLANKBTN , "<STR_LIT>" , blank . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTBLANKBTN , False ) <EOL> self . spnBins = wx . SpinCtrl ( id = wxID_FRAME1SPINCTRL1 , initial = <NUM_LIT:50> , max = <NUM_LIT:100> , min = <NUM_LIT:1> , name = '<STR_LIT>' , <EOL> parent = self . PlotsOptions_bar , pos = wx . Point ( <NUM_LIT> , <NUM_LIT:7> ) , <EOL> size = wx . Size ( <NUM_LIT> , <NUM_LIT> ) , style = wx . SP_ARROW_KEYS ) <EOL> self . spnBins . Enabled = False <EOL> self . PlotsOptions_bar . AddDropdownButton ( wxID_RIBBONPLOTBOXTYPE , "<STR_LIT>" , <EOL> box_whisker_type . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTTSTYPE , False ) <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTTSLEGEND , False ) <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTBOXTYPE , False ) <EOL> dateTime_panel = RB . RibbonPanel ( home , wx . ID_ANY , "<STR_LIT>" , wx . NullBitmap , wx . DefaultPosition , wx . DefaultSize , <EOL> RB . RIBBON_PANEL_NO_AUTO_MINIMISE ) <EOL> self . dateTime_buttonbar = RB . RibbonButtonBar ( dateTime_panel ) <EOL> self . dateTime_buttonbar . AddSimpleButton ( wxID_RIBBONPLOTBLANKBTN , "<STR_LIT>" , blank . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . dateTime_buttonbar . AddSimpleButton ( wxID_RIBBONPLOTBLANKBTN , "<STR_LIT>" , blank . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . dateTime_buttonbar . AddSimpleButton ( wxID_RIBBONPLOTBLANKBTN , "<STR_LIT>" , blank . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . dateTime_buttonbar . EnableButton ( wxID_RIBBONPLOTBLANKBTN , False ) <EOL> self . dpStartDate = wx . DatePickerCtrl ( id = wxID_STARTDPDATE , name = u'<STR_LIT>' , parent = self . dateTime_buttonbar , <EOL> pos = wx . Point ( <NUM_LIT:5> , <NUM_LIT:8> ) , size = wx . Size ( <NUM_LIT> , <NUM_LIT> ) , style = wx . DP_DROPDOWN ) <EOL> self . dpStartDate . SetToolTipString ( u'<STR_LIT>' ) <EOL> self . dpEndDate = wx . DatePickerCtrl ( id = wxID_ENDDPDATE , name = u'<STR_LIT>' , parent = self . dateTime_buttonbar , <EOL> pos = wx . Point ( <NUM_LIT:5> , <NUM_LIT> ) , size = wx . Size ( <NUM_LIT> , <NUM_LIT> ) , style = wx . DP_DROPDOWN ) <EOL> self . dpEndDate . SetToolTipString ( u'<STR_LIT>' ) <EOL> self . dateTime_buttonbar . AddSimpleButton ( wxID_RIBBONPLOTDATEAPPLY , "<STR_LIT>" , date_setting . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . dateTime_buttonbar . AddSimpleButton ( wxID_RIBBONPLOTDATEFULL , "<STR_LIT>" , full_date_range . GetBitmap ( ) , <EOL> "<STR_LIT>" ) <EOL> self . dateTime_buttonbar . EnableButton ( wxID_RIBBONPLOTDATEFULL , False ) <EOL> self . dateTime_buttonbar . EnableButton ( wxID_RIBBONPLOTDATEAPPLY , False ) <EOL> self . dpEndDate . Enabled = False <EOL> self . dpStartDate . Enabled = False <EOL> editPage = RB . RibbonPage ( self , wx . ID_ANY , "<STR_LIT>" ) <EOL> main_panel = RB . RibbonPanel ( editPage , wx . ID_ANY , "<STR_LIT>" , wx . NullBitmap , wx . DefaultPosition , wx . DefaultSize , <EOL> RB . RIBBON_PANEL_NO_AUTO_MINIMISE ) <EOL> self . main_bar = RB . RibbonButtonBar ( main_panel ) <EOL> self . editbutton = self . main_bar . AddSimpleButton ( wxID_RIBBONEDITSERIES , "<STR_LIT>" , bitmap = edit . GetBitmap ( ) , <EOL> help_string = "<STR_LIT>" , <EOL> kind = <NUM_LIT> ) <EOL> self . main_bar . AddSimpleButton ( wxID_RIBBONEDITRESTORE , "<STR_LIT>" , restore . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . main_bar . AddSimpleButton ( wxID_RIBBONEDITSAVE , "<STR_LIT>" , save_data . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . main_bar . EnableButton ( wxID_RIBBONEDITRESTORE , False ) <EOL> self . main_bar . EnableButton ( wxID_RIBBONEDITSAVE , False ) <EOL> edit_panel = RB . RibbonPanel ( editPage , wx . ID_ANY , "<STR_LIT>" , wx . NullBitmap , wx . DefaultPosition , <EOL> wx . DefaultSize , RB . RIBBON_PANEL_NO_AUTO_MINIMISE ) <EOL> self . edit_bar = RB . RibbonButtonBar ( edit_panel ) <EOL> self . edit_bar . AddSimpleButton ( wxID_RIBBONEDITFILTER , "<STR_LIT>" , filter_list . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . edit_bar . AddSimpleButton ( wxID_RIBBONEDITRESETFILTER , "<STR_LIT>" , Undo . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . edit_bar . AddSimpleButton ( wxID_RIBBONEDITCHGVALUE , "<STR_LIT>" , edit_view . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . edit_bar . AddSimpleButton ( wxID_RIBBONEDITINTEROPOLATE , "<STR_LIT>" , interpolate . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . edit_bar . AddSimpleButton ( wxID_RIBBONEDITLINFILTER , "<STR_LIT>" , lin_drift . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . edit_bar . AddSimpleButton ( wxID_RIBBONEDITFLAG , "<STR_LIT>" , flag . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . edit_bar . AddSimpleButton ( wxID_RIBBONEDITADDPOINT , "<STR_LIT>" , add . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . edit_bar . AddSimpleButton ( wxID_RIBBONEDITDELPOINT , "<STR_LIT>" , delete . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . edit_bar . EnableButton ( wxID_RIBBONEDITFILTER , False ) <EOL> self . edit_bar . EnableButton ( wxID_RIBBONEDITCHGVALUE , False ) <EOL> self . edit_bar . EnableButton ( wxID_RIBBONEDITINTEROPOLATE , False ) <EOL> self . edit_bar . EnableButton ( wxID_RIBBONEDITLINFILTER , False ) <EOL> self . edit_bar . EnableButton ( wxID_RIBBONEDITFLAG , False ) <EOL> self . edit_bar . EnableButton ( wxID_RIBBONEDITADDPOINT , False ) <EOL> self . edit_bar . EnableButton ( wxID_RIBBONEDITDELPOINT , False ) <EOL> self . record_panel = RB . RibbonPanel ( editPage , wx . ID_ANY , "<STR_LIT>" , wx . NullBitmap , wx . DefaultPosition , <EOL> wx . DefaultSize , RB . RIBBON_PANEL_NO_AUTO_MINIMISE ) <EOL> self . record_bar = RB . RibbonButtonBar ( self . record_panel ) <EOL> self . record_bar . AddSimpleButton ( wxID_RIBBONRECORDNEW , "<STR_LIT>" , newscript . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . record_bar . AddSimpleButton ( wxID_RIBBONRECORDOPEN , "<STR_LIT>" , openscript . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . record_bar . AddSimpleButton ( wxID_RIBBONRECORDSAVE , "<STR_LIT>" , savescript . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . record_bar . EnableButton ( wxID_RIBBONRECORDNEW , False ) <EOL> self . record_bar . EnableButton ( wxID_RIBBONRECORDOPEN , False ) <EOL> self . record_bar . EnableButton ( wxID_RIBBONRECORDSAVE , False ) <EOL> viewPage = RB . RibbonPage ( self , wx . ID_ANY , "<STR_LIT>" ) <EOL> view_panel = RB . RibbonPanel ( viewPage , wx . ID_ANY , "<STR_LIT>" , wx . NullBitmap , wx . DefaultPosition , wx . DefaultSize , <EOL> RB . RIBBON_PANEL_NO_AUTO_MINIMISE ) <EOL> view_bar = RB . RibbonButtonBar ( view_panel ) <EOL> view_bar . AddSimpleButton ( wxID_RIBBONVIEWPLOT , "<STR_LIT>" , line_chart . GetBitmap ( ) , "<STR_LIT>" ) <EOL> view_bar . AddSimpleButton ( wxID_RIBBONVIEWTABLE , "<STR_LIT>" , table . GetBitmap ( ) , "<STR_LIT>" ) <EOL> view_bar . AddSimpleButton ( wxID_RIBBONVIEWSERIES , "<STR_LIT>" , bitmap_editor . GetBitmap ( ) , "<STR_LIT>" ) <EOL> view_bar . AddSimpleButton ( wxID_RIBBONVIEWCONSOLE , "<STR_LIT>" , window_command_line . GetBitmap ( ) , "<STR_LIT>" ) <EOL> view_bar . AddSimpleButton ( wxID_RIBBONVIEWSCRIPT , "<STR_LIT>" , script . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . scriptPanel = RB . RibbonPanel ( viewPage , wx . ID_ANY , "<STR_LIT>" , wx . NullBitmap , wx . DefaultPosition , <EOL> wx . DefaultSize , RB . RIBBON_PANEL_NO_AUTO_MINIMISE ) <EOL> self . scriptBar = RB . RibbonButtonBar ( self . scriptPanel ) <EOL> self . scriptBar . AddSimpleButton ( wxID_RIBBONRECORDNEW , "<STR_LIT>" , newscript . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . scriptBar . AddSimpleButton ( wxID_RIBBONRECORDOPEN , "<STR_LIT>" , openscript . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . scriptBar . AddSimpleButton ( wxID_RIBBONRECORDSAVE , "<STR_LIT>" , savescript . GetBitmap ( ) , "<STR_LIT>" ) <EOL> self . scriptPanel . Hide ( ) <EOL> self . CurrPage = <NUM_LIT:1> <EOL> self . SetActivePageByIndex ( self . CurrPage ) <EOL> self . bindEvents ( ) <EOL> self . initPubSub ( ) <EOL> def __init__ ( self , parent , id , name ) : <EOL> self . parent = parent <EOL> self . _init_ctrls ( parent ) <EOL> def bindEvents ( self ) : <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onDocking , id = wxID_RIBBONVIEWTABLE ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onDocking , id = wxID_RIBBONVIEWSERIES ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onDocking , id = wxID_RIBBONVIEWPLOT ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onDocking , id = wxID_RIBBONVIEWCONSOLE ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onDocking , id = wxID_RIBBONVIEWSCRIPT ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onPlotSelection , id = wxID_RIBBONPLOTTIMESERIES ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onPlotSelection , id = wxID_RIBBONPLOTPROB ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onPlotSelection , id = wxID_RIBBONPLOTBOX ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onPlotSelection , id = wxID_RIBBONPLOTHIST ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onPlotSelection , id = wxID_RIBBONPLOTSUMMARY ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED , self . onPlotTypeDropdown , id = wxID_RIBBONPLOTTSTYPE ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_DROPDOWN_CLICKED , self . onBoxTypeDropdown , id = wxID_RIBBONPLOTBOXTYPE ) <EOL> self . Bind ( wx . EVT_SPINCTRL , self . onBinChanged , id = wxID_FRAME1SPINCTRL1 ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onShowLegend , id = wxID_RIBBONPLOTTSLEGEND ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onFullDate , id = wxID_RIBBONPLOTDATEFULL ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onDateChanged , id = wxID_RIBBONPLOTDATEAPPLY ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onExecuteScript , id = wxID_RIBBONEDITSCRIPTEXECUTE ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onEditSeries , id = wxID_RIBBONEDITSERIES ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onRestore , id = wxID_RIBBONEDITRESTORE ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onSave , id = wxID_RIBBONEDITSAVE ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onEditFilter , id = wxID_RIBBONEDITFILTER ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onResetFilter , id = wxID_RIBBONEDITRESETFILTER ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onEditChangeValue , id = wxID_RIBBONEDITCHGVALUE ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onEditInterpolate , id = wxID_RIBBONEDITINTEROPOLATE ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onEditFlag , id = wxID_RIBBONEDITFLAG ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onEditAddPoint , id = wxID_RIBBONEDITADDPOINT ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onEditDelPoint , id = wxID_RIBBONEDITDELPOINT ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onRecordNew , id = wxID_RIBBONRECORDNEW ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onRecordOpen , id = wxID_RIBBONRECORDOPEN ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onRecordSave , id = wxID_RIBBONRECORDSAVE ) <EOL> self . Bind ( RB . EVT_RIBBONBUTTONBAR_CLICKED , self . onLineDrift , id = wxID_RIBBONEDITLINFILTER ) <EOL> self . edit_bar . EnableButton ( wxID_RIBBONEDITLINFILTER , False ) <EOL> self . Bind ( RB . EVT_RIBBONBAR_PAGE_CHANGED , self . onFileMenu , id = wxID_PANEL1 ) <EOL> def initPubSub ( self ) : <EOL> Publisher . subscribe ( self . toggleEditButtons , "<STR_LIT>" ) <EOL> Publisher . subscribe ( self . enableButtons , "<STR_LIT>" ) <EOL> Publisher . subscribe ( self . resetDateRange , "<STR_LIT>" ) <EOL> Publisher . subscribe ( self . onToggleEdit , "<STR_LIT>" ) <EOL> Publisher . subscribe ( self . setEdit , "<STR_LIT>" ) <EOL> def onFileMenu ( self , event ) : <EOL> if not self . GetActivePage ( ) == <NUM_LIT:0> : <EOL> self . CurrPage = self . GetActivePage ( ) <EOL> if self . GetActivePage ( ) == <NUM_LIT:0> : <EOL> self . SetActivePageByIndex ( self . CurrPage ) <EOL> menu = wx . Menu ( ) <EOL> self . Bind ( wx . EVT_MENU , self . onChangeDBConfig , menu . Append ( wx . ID_ANY , "<STR_LIT>" ) ) <EOL> self . Bind ( wx . EVT_MENU , self . onAbout , menu . Append ( wx . ID_ANY , "<STR_LIT>" ) ) <EOL> self . Bind ( wx . EVT_MENU , self . onClose , menu . Append ( wx . ID_ANY , "<STR_LIT>" ) ) <EOL> self . PopupMenu ( menu , wx . Point ( <NUM_LIT:50> , <NUM_LIT> ) ) <EOL> event . Skip ( ) <EOL> def onFullDate ( self , event ) : <EOL> Publisher . sendMessage ( "<STR_LIT>" ) <EOL> def onDateChanged ( self , event ) : <EOL> date = self . dpStartDate . GetValue ( ) <EOL> startDate = datetime . datetime ( date . Year , date . Month + <NUM_LIT:1> , date . Day , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> date = self . dpEndDate . GetValue ( ) <EOL> endDate = datetime . datetime ( date . Year , date . Month + <NUM_LIT:1> , date . Day , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> logger . debug ( "<STR_LIT>" % ( startDate ) ) <EOL> logger . debug ( "<STR_LIT>" % ( endDate ) ) <EOL> if startDate . date ( ) <= endDate . date ( ) : <EOL> endDate = endDate . replace ( hour = <NUM_LIT:11> , minute = <NUM_LIT> , second = <NUM_LIT> ) <EOL> else : <EOL> startDate = startDate . replace ( hour = <NUM_LIT:11> , minute = <NUM_LIT> , second = <NUM_LIT> ) <EOL> Publisher . sendMessage ( "<STR_LIT>" , startDate = startDate , endDate = endDate ) <EOL> event . Skip ( ) <EOL> def resetDateRange ( self , startDate , endDate , currStart = None , currEnd = None ) : <EOL> maxStart = _pydate2wxdate ( startDate ) <EOL> maxEnd = _pydate2wxdate ( endDate ) <EOL> self . dpStartDate . SetRange ( maxStart , maxEnd ) <EOL> if currStart : <EOL> self . dpStartDate . SetValue ( _pydate2wxdate ( currStart ) ) <EOL> else : <EOL> self . dpEndDate . SetValue ( self . maxStart ) <EOL> self . dpEndDate . SetRange ( maxStart , maxEnd ) <EOL> if currEnd : <EOL> self . dpEndDate . SetValue ( _pydate2wxdate ( currEnd ) ) <EOL> else : <EOL> self . dpEndDate . SetValue ( self . maxEnd ) <EOL> def onResetFilter ( self , event ) : <EOL> recordService = self . parent . getRecordService ( ) <EOL> recordService . reset_filter ( ) <EOL> def isEmptySelection ( self , dataframe ) : <EOL> if isinstance ( dataframe , pd . DataFrame ) : <EOL> if dataframe . empty : <EOL> raise EmptySelection <EOL> else : <EOL> if not dataframe : <EOL> raise EmptySelection <EOL> def onLineDrift ( self , event ) : <EOL> dataframe = self . parent . getRecordService ( ) . get_filtered_points ( ) <EOL> try : <EOL> self . isEmptySelection ( dataframe ) <EOL> except EmptySelection : <EOL> val = wx . MessageBox ( "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> '<STR_LIT>' , wx . OK | wx . ICON_WARNING ) <EOL> return <EOL> lin_drift = frmLinearDrift ( self . parent , self . parent . getRecordService ( ) ) <EOL> lin_drift . CenterOnParent ( ) <EOL> lin_drift . ShowModal ( ) <EOL> lin_drift . Destroy ( ) <EOL> event . Skip ( ) <EOL> def onRecordNew ( self , event ) : <EOL> panedet = self . parent . _mgr . GetPane ( self . parent . txtPythonScript ) <EOL> if not panedet . IsShown ( ) : <EOL> panedet . Show ( show = True ) <EOL> script = self . parent . txtPythonScript <EOL> script . OnNew ( event ) <EOL> def onRecordOpen ( self , event ) : <EOL> script = self . parent . txtPythonScript <EOL> panedet = self . parent . _mgr . GetPane ( self . parent . txtPythonScript ) <EOL> if not panedet . IsShown ( ) : <EOL> panedet . Show ( show = True ) <EOL> script . OnOpen ( event ) <EOL> def onRecordSave ( self , event ) : <EOL> script = self . parent . txtPythonScript <EOL> script . OnSaveAs ( event ) <EOL> def onSave ( self , event ) : <EOL> wiz = wizSave . wizSave ( self . parent , self . parent . getServiceManager ( ) , self . parent . getRecordService ( ) ) <EOL> wiz . Close ( ) <EOL> event . Skip ( ) <EOL> def onEditFilter ( self , event ) : <EOL> data_filter = frmDataFilter ( self . parent , self . parent . getRecordService ( ) ) <EOL> data_filter . ShowModal ( ) <EOL> data_filter . Destroy ( ) <EOL> event . Skip ( ) <EOL> def onEditChangeValue ( self , event ) : <EOL> change_value = frmChangeValue ( self . parent , self . parent . getRecordService ( ) ) <EOL> change_value . CenterOnParent ( ) <EOL> change_value . ShowModal ( ) <EOL> change_value . Destroy ( ) <EOL> event . Skip ( ) <EOL> def onEditInterpolate ( self , event ) : <EOL> dataframe = self . parent . getRecordService ( ) . get_filtered_points ( ) <EOL> try : <EOL> self . isEmptySelection ( dataframe ) <EOL> except EmptySelection : <EOL> val = wx . MessageBox ( "<STR_LIT>" , <EOL> '<STR_LIT>' , wx . OK | wx . ICON_EXCLAMATION , parent = self . parent ) <EOL> return <EOL> val = wx . MessageBox ( "<STR_LIT>" % len ( dataframe ) , <EOL> '<STR_LIT>' , wx . YES_NO | wx . ICON_QUESTION | wx . CENTRE , parent = self . parent ) <EOL> if val == <NUM_LIT:2> : <EOL> self . parent . getRecordService ( ) . interpolate ( ) <EOL> event . Skip ( ) <EOL> def onEditFlag ( self , event ) : <EOL> serviceManager = self . parent . getDBService ( ) <EOL> series_service = serviceManager . get_series_service ( ) <EOL> qualifierChoices = OrderedDict ( ( x . code + '<STR_LIT:->' + x . description , x . id ) for x in series_service . get_all_qualifiers ( ) <EOL> if x . code and x . description ) <EOL> add_flag = frmFlagValues ( self . parent , series_service , qualifierChoices ) <EOL> val = add_flag . ShowModal ( ) <EOL> if val == wx . ID_OK : <EOL> logger . debug ( "<STR_LIT>" % ( val , type ( val ) ) ) <EOL> self . parent . getRecordService ( ) . flag ( add_flag . GetValue ( ) ) <EOL> add_flag . Destroy ( ) <EOL> event . Skip ( ) <EOL> def onEditAddPoint ( self , event ) : <EOL> recordService = self . parent . getRecordService ( ) <EOL> serviceManager = self . parent . getServiceManager ( ) <EOL> addPoint = AddPoints ( self . parent , serviceManager = serviceManager , recordService = recordService ) <EOL> addPoint . Center ( ) <EOL> addPoint . ShowModal ( ) <EOL> event . Skip ( ) <EOL> def onEditDelPoint ( self , event ) : <EOL> dataframe = self . parent . getRecordService ( ) . get_filtered_points ( ) <EOL> try : <EOL> self . isEmptySelection ( dataframe ) <EOL> except EmptySelection : <EOL> wx . MessageBox ( "<STR_LIT>" , <EOL> '<STR_LIT>' , wx . OK | wx . ICON_WARNING , parent = self . parent ) <EOL> return <EOL> val = wx . MessageBox ( "<STR_LIT>" % len ( dataframe ) , <EOL> '<STR_LIT>' , wx . YES_NO | wx . ICON_QUESTION , parent = self . parent ) <EOL> if val == <NUM_LIT:2> : <EOL> self . parent . getRecordService ( ) . delete_points ( ) <EOL> event . Skip ( ) <EOL> def onRestore ( self , event ) : <EOL> self . parent . getRecordService ( ) . restore ( ) <EOL> event . Skip ( ) <EOL> def onToggleEdit ( self , checked = True ) : <EOL> self . main_bar . ToggleButton ( self . editbutton . id , checked ) <EOL> def setEdit ( self , isEdit ) : <EOL> self . isEdit = isEdit <EOL> def getEditStatus ( self ) : <EOL> try : <EOL> return self . isEdit <EOL> except : <EOL> return None <EOL> def onEditSeries ( self , event = None ) : <EOL> if event . IsChecked ( ) : <EOL> Publisher . sendMessage ( "<STR_LIT>" , event = event ) <EOL> logging . debug ( "<STR_LIT>" % self . isEdit ) <EOL> if not self . isEdit : <EOL> self . onToggleEdit ( False ) <EOL> else : <EOL> Publisher . sendMessage ( ( "<STR_LIT>" ) , event = event ) <EOL> event . Skip ( ) <EOL> def onBinChanged ( self , event ) : <EOL> Publisher . sendMessage ( ( "<STR_LIT>" ) , numBins = event . Selection ) <EOL> event . Skip ( ) <EOL> def onShowLegend ( self , event ) : <EOL> Publisher . sendMessage ( ( "<STR_LIT>" ) , event = event , isVisible = event . IsChecked ( ) ) <EOL> event . Skip ( ) <EOL> def onAbout ( self , event ) : <EOL> frmAbout ( self ) <EOL> event . Skip ( ) <EOL> def onClose ( self , event ) : <EOL> Publisher . sendMessage ( ( "<STR_LIT>" ) , event = event ) <EOL> event . Skip ( ) <EOL> def onChangeDBConfig ( self , event ) : <EOL> Publisher . sendMessage ( ( "<STR_LIT>" ) , event = event ) <EOL> self . CurrPage = <NUM_LIT:1> <EOL> self . SetActivePageByIndex ( self . CurrPage ) <EOL> event . Skip ( ) <EOL> def onExecuteScript ( self , event ) : <EOL> Publisher . sendMessage ( ( "<STR_LIT>" ) , event = event ) <EOL> event . Skip ( ) <EOL> def onBoxTypeDropdown ( self , event ) : <EOL> menu = wx . Menu ( ) <EOL> self . Bind ( wx . EVT_MENU , self . onBoxMonthly , menu . Append ( wx . ID_ANY , "<STR_LIT>" ) ) <EOL> self . Bind ( wx . EVT_MENU , self . onBoxYearly , menu . Append ( wx . ID_ANY , "<STR_LIT>" ) ) <EOL> self . Bind ( wx . EVT_MENU , self . onBoxSeasonal , menu . Append ( wx . ID_ANY , "<STR_LIT>" ) ) <EOL> self . Bind ( wx . EVT_MENU , self . onBoxOverall , menu . Append ( wx . ID_ANY , "<STR_LIT>" ) ) <EOL> event . PopupMenu ( menu ) <EOL> event . Skip ( ) <EOL> def onBoxMonthly ( self , event ) : <EOL> Publisher . sendMessage ( ( "<STR_LIT>" ) , str = event ) <EOL> event . Skip ( ) <EOL> def onBoxYearly ( self , event ) : <EOL> Publisher . sendMessage ( ( "<STR_LIT>" ) , str = event ) <EOL> event . Skip ( ) <EOL> def onBoxSeasonal ( self , event ) : <EOL> Publisher . sendMessage ( ( "<STR_LIT>" ) , str = event ) <EOL> event . Skip ( ) <EOL> def onBoxOverall ( self , event ) : <EOL> Publisher . sendMessage ( ( "<STR_LIT>" ) , str = event ) <EOL> event . Skip ( ) <EOL> def onPlotTypeDropdown ( self , event ) : <EOL> menu = wx . Menu ( ) <EOL> self . Bind ( wx . EVT_MENU , self . onPlotTypeLine , menu . Append ( wx . ID_ANY , "<STR_LIT>" ) ) <EOL> self . Bind ( wx . EVT_MENU , self . onPlotTypePoint , menu . Append ( wx . ID_ANY , "<STR_LIT>" ) ) <EOL> self . Bind ( wx . EVT_MENU , self . onPlotTypeBoth , menu . Append ( wx . ID_ANY , "<STR_LIT>" ) ) <EOL> event . PopupMenu ( menu ) <EOL> event . Skip ( ) <EOL> def onPlotTypeLine ( self , event ) : <EOL> Publisher . sendMessage ( ( "<STR_LIT>" ) , event = event , ptype = "<STR_LIT>" ) <EOL> event . Skip ( ) <EOL> def onPlotTypePoint ( self , event ) : <EOL> Publisher . sendMessage ( ( "<STR_LIT>" ) , event = event , ptype = "<STR_LIT>" ) <EOL> event . Skip ( ) <EOL> def onPlotTypeBoth ( self , event ) : <EOL> Publisher . sendMessage ( ( "<STR_LIT>" ) , event = event , ptype = "<STR_LIT>" ) <EOL> event . Skip ( ) <EOL> def onPlotSelection ( self , event ) : <EOL> if event . Id == wxID_RIBBONPLOTTIMESERIES : <EOL> value = <NUM_LIT:0> <EOL> elif event . Id == wxID_RIBBONPLOTPROB : <EOL> value = <NUM_LIT:1> <EOL> elif event . Id == wxID_RIBBONPLOTHIST : <EOL> value = <NUM_LIT:2> <EOL> elif event . Id == wxID_RIBBONPLOTBOX : <EOL> value = <NUM_LIT:3> <EOL> elif event . Id == wxID_RIBBONPLOTSUMMARY : <EOL> value = <NUM_LIT:4> <EOL> self . enableButtons ( value , True ) <EOL> Publisher . sendMessage ( ( "<STR_LIT>" ) , value = value ) <EOL> event . Skip ( ) <EOL> def onDocking ( self , event ) : <EOL> if event . Id == wxID_RIBBONVIEWSCRIPT : <EOL> value = "<STR_LIT>" <EOL> '''<STR_LIT>''' <EOL> elif event . Id == wxID_RIBBONVIEWCONSOLE : <EOL> value = "<STR_LIT>" <EOL> elif event . Id == wxID_RIBBONVIEWSERIES : <EOL> value = "<STR_LIT>" <EOL> elif event . Id == wxID_RIBBONVIEWTABLE : <EOL> value = "<STR_LIT>" <EOL> elif event . Id == wxID_RIBBONVIEWPLOT : <EOL> value = "<STR_LIT>" <EOL> Publisher . sendMessage ( ( "<STR_LIT>" ) , value = value ) <EOL> event . Skip ( ) <EOL> def enableDateSelection ( self , isActive ) : <EOL> self . dateTime_buttonbar . EnableButton ( wxID_RIBBONPLOTDATEFULL , isActive ) <EOL> self . dateTime_buttonbar . EnableButton ( wxID_RIBBONPLOTDATEAPPLY , isActive ) <EOL> self . dpEndDate . Enabled = isActive <EOL> self . dpStartDate . Enabled = isActive <EOL> def enableButtons ( self , plot , isActive ) : <EOL> if not isActive : <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTTSTYPE , False ) <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTTSLEGEND , False ) <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTBOXTYPE , False ) <EOL> self . spnBins . Enabled = False <EOL> self . enableDateSelection ( False ) <EOL> elif plot == <NUM_LIT:0> or plot == <NUM_LIT:1> : <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTTSTYPE , True ) <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTTSLEGEND , True ) <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTBOXTYPE , False ) <EOL> self . spnBins . Enabled = False <EOL> self . enableDateSelection ( True ) <EOL> elif plot == <NUM_LIT:2> : <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTTSTYPE , False ) <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTTSLEGEND , False ) <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTBOXTYPE , False ) <EOL> self . spnBins . Enabled = True <EOL> self . enableDateSelection ( True ) <EOL> elif plot == <NUM_LIT:3> : <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTTSTYPE , False ) <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTTSLEGEND , False ) <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTBOXTYPE , True ) <EOL> self . spnBins . Enabled = False <EOL> self . enableDateSelection ( True ) <EOL> elif plot == <NUM_LIT:4> : <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTTSTYPE , False ) <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTTSLEGEND , False ) <EOL> self . PlotsOptions_bar . EnableButton ( wxID_RIBBONPLOTBOXTYPE , False ) <EOL> self . spnBins . Enabled = False <EOL> self . enableDateSelection ( True ) <EOL> def toggleEditButtons ( self , state ) : <EOL> self . main_bar . EnableButton ( wxID_RIBBONEDITRESTORE , state ) <EOL> self . main_bar . EnableButton ( wxID_RIBBONEDITSAVE , state ) <EOL> self . edit_bar . EnableButton ( wxID_RIBBONEDITFILTER , state ) <EOL> self . edit_bar . EnableButton ( wxID_RIBBONEDITLINFILTER , state ) <EOL> self . edit_bar . EnableButton ( wxID_RIBBONEDITRESETFILTER , state ) <EOL> self . edit_bar . EnableButton ( wxID_RIBBONEDITCHGVALUE , state ) <EOL> self . edit_bar . EnableButton ( wxID_RIBBONEDITINTEROPOLATE , state ) <EOL> self . edit_bar . EnableButton ( wxID_RIBBONEDITFLAG , state ) <EOL> self . edit_bar . EnableButton ( wxID_RIBBONEDITADDPOINT , state ) <EOL> self . edit_bar . EnableButton ( wxID_RIBBONEDITDELPOINT , state ) <EOL> self . record_bar . EnableButton ( wxID_RIBBONRECORDOPEN , state ) <EOL> self . record_bar . EnableButton ( wxID_RIBBONRECORDNEW , state ) <EOL> self . record_bar . EnableButton ( wxID_RIBBONRECORDSAVE , state ) <EOL> self . enableDateSelection ( not state ) <EOL> def _pydate2wxdate ( date ) : <EOL> import datetime <EOL> assert isinstance ( date , ( datetime . datetime , datetime . date ) ) <EOL> tt = date . timetuple ( ) <EOL> dmy = ( tt [ <NUM_LIT:2> ] , tt [ <NUM_LIT:1> ] - <NUM_LIT:1> , tt [ <NUM_LIT:0> ] ) <EOL> return wx . DateTimeFromDMY ( * dmy ) </s>
