def _set_confidence_level_and_interval(self): ''' Sets default confidence level and interval in Top Level interface Arguments: None Returns: None ''' confidence_levels = ['%.3f' % (w * Decimal('100')) for w in SUPPORTED_CONFIDENCES.keys()] confidence_levels.sort() self._cbx_confidence_levels.Clear() for cl in confidence_levels: self._cbx_confidence_levels.Append(cl) items = self._cbx_confidence_levels.GetItems() index = -1 try: index = items.index(str(DEFAULT_CONFIDENCE_LEVEL)) self._cbx_confidence_levels.SetSelection(index) except ValueError: self._cbx_confidence_levels.SetValue(str(DEFAULT_CONFIDENCE_LEVEL)) self._tc_out_confidence_levels.SetValue(str(DEFAULT_CONFIDENCE_LEVEL)) self._tc_confidence_interval.SetValue(str(int(DEFAULT_CONFIDENCE_INTERVAL)))
def _create_layout(self): '''Creates the main window layout ''' # Input folder section self.input_folder_label = wx.StaticText(self, label="Data folder") self.input_folder_control = wx.TextCtrl(self, style=wx.TE_BESTWRAP, size=(400, -1)) self.input_folder_control.SetEditable(False) self.input_folder_control.SetValue(self.dir_path) self.input_folder_button = wx.Button(self, wx.ID_OPEN, "Select") self.Bind(wx.EVT_BUTTON, self._on_select_input_folder, self.input_folder_button) self.line = wx.StaticLine(self) # Setting output folder section self.output_folder_label = wx.StaticText(self, label="Sampled output") self.output_folder_control = wx.TextCtrl(self, style=wx.TE_BESTWRAP, size=(400, -1)) self.output_folder_control.SetEditable(False) self.output_folder_control.SetValue(self.output_dir_path) self.output_folder_button = wx.Button(self, wx.ID_ANY, "Select") self.Bind(wx.EVT_BUTTON, self._on_select_output_folder, self.output_folder_button) # Setting run and exit buttons self.button_exit = wx.Button(self, wx.ID_EXIT, "Exit") self.button_run = wx.Button(self, wx.ID_ANY, "Run Sampler") self.Bind(wx.EVT_BUTTON, self._on_exit, self.button_exit) self.Bind(wx.EVT_BUTTON, self._on_run_sampler, self.button_run) # Setting parameters self.confidence_text = wx.StaticText(self, label="Confidence Level (%)") self.precision_text = wx.StaticText(self, label="Confidence Interval (%)") confidence_levels = ['%.3f' % (w * Decimal('100')) for w in SUPPORTED_CONFIDENCES.keys()] confidence_levels.sort() self.confidence = wx.ComboBox(self, -1, str(DEFAULT_CONFIDENCE_LEVEL), size=(150, -1), choices=confidence_levels, style=wx.CB_READONLY) self.precision = wx.lib.masked.NumCtrl(self, size=(20,1), fractionWidth=0, integerWidth=2, allowNegative=False, min=1, max=99, value=DEFAULT_CONFIDENCE_INTERVAL) # Layouts sizer_input_output = wx.GridBagSizer(2,2) sizer_input_output.Add(self.input_folder_label,pos = (0,0), flag = wx.ALIGN_LEFT | wx.ALL, border=5 ) sizer_input_output.Add(self.input_folder_control,pos = (0,1), flag = wx.EXPAND | wx.ALL, border=5) sizer_input_output.Add(self.input_folder_button,pos = (0,2), flag = wx.EXPAND | wx.ALL, border=5) sizer_input_output.Add(self.output_folder_label,pos = (1,0), flag = wx.ALIGN_LEFT | wx.EXPAND | wx.ALL, border=5) sizer_input_output.Add(self.output_folder_control,pos = (1,1), flag = wx.EXPAND | wx.ALL, border=5) sizer_input_output.Add(self.output_folder_button,pos = (1,2), flag = wx.EXPAND | wx.ALL, border=5) sizer_input_output.Add(self.confidence_text,pos=(2,0), flag = wx.ALL, border=5) sizer_input_output.Add(self.confidence,pos=(2,1), flag = wx.ALL, border=5) sizer_input_output.Add(self.precision_text,pos=(3,0), flag = wx.ALL, border=5) sizer_input_output.Add(self.precision,pos=(3,1), flag = wx.ALL, border=5) sizer_process_files = wx.BoxSizer(wx.HORIZONTAL) self.process_files_tree = file_list_control(self, 0,self.output_dir_path) sizer_process_files.Add(self.process_files_tree, 0, wx.EXPAND | wx.ALL, border=5) self.Bind(wx.EVT_FILEPICKER_CHANGED, self._on_update_mark, self.process_files_tree) self.Bind(wx.EVT_ACTIVATE, self._on_save_mark_file_status, self.process_files_tree) # Not showing the file_list_control initially self.process_files_tree.Show(False) sizer_btn = wx.BoxSizer( wx.HORIZONTAL ) sizer_btn.Add(self.button_run, proportion=0, flag=wx.ALL | wx.ALIGN_LEFT, border=5) sizer_btn.Add(self.button_exit, proportion=0, flag=wx.ALL | wx.ALIGN_RIGHT, border=5) sizer_main = wx.GridBagSizer(5,5) sizer_main.Add(self.banner,pos = (0,0), span = (1,3), flag = wx.ALL | wx.EXPAND, border=5) sizer_main.Add(sizer_input_output,pos = (1,0), span = (1,3), flag = wx.ALL, border=5) sizer_main.Add(sizer_btn, pos = (2,0), span = (1,3), flag = wx.ALIGN_CENTER | wx.ALL, border=5) sizer_main.Add(sizer_process_files,pos = (3,0), span = (3,3), flag = wx.EXPAND | wx.ALL, border=5) self.SetSizerAndFit(sizer_main) self.Layout()