Changeset b697396b in sasview


Ignore:
Timestamp:
Apr 5, 2017 11:41:47 AM (8 years ago)
Author:
krzywon
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
0d8ee36
Parents:
1661cd5
git-author:
Jeff Krzywon <krzywon@…> (04/05/17 11:41:47)
git-committer:
krzywon <krzywon@…> (04/05/17 11:41:47)
Message:

Check all items in the list box by default. More documentation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/local_perspectives/plotting/parameters_panel_slicer.py

    rf15da54 rb697396b  
    44import wx.lib.newevent 
    55import time 
    6 #from copy import deepcopy 
    76from sas.sasgui.guiframe.events import EVT_SLICER_PARS 
    87from sas.sasgui.guiframe.utils import format_number 
     
    139138                         wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    140139            iy += 1 
     140            # Create a list box with all of the 2D plots 
    141141            self.process_list() 
    142142            self.bck.Add(self.data_list, (iy, ix), (1, 1), 
    143143                         wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    144144            iy += 1 
     145            # Button to start batch slicing 
    145146            button_label = "Apply Slicer to Selected Plots" 
    146147            self.batch_slicer_button = wx.Button(parent=self, 
     
    149150            self.bck.Add(self.batch_slicer_button, (iy, ix), (1, 1), 
    150151                             wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    151             # TODO: Select all button 
    152152            # TODO: Check box for saving file 
    153153            # TODO: append to file information and file type 
     
    206206        type = self.type_select.GetStringSelection() 
    207207 
    208         # Find loaded 2D data panels 
     208        # Find desired 2D data panels 
    209209        for key, mgr in spp.plot_panels.iteritems(): 
    210210            if mgr.graph.prop['title'] in self.data_list.CheckedStrings: 
    211211                apply_to_list.append(mgr) 
    212212 
    213         # Apply slicer to selected panels 
     213        # Apply slicer type to selected panels 
    214214        for item in apply_to_list: 
    215215            self._apply_slicer_to_plot(item, type) 
    216216 
     217        # Post an event to apply appropriate slicer params to each slicer 
     218        # Event needed due to how apply_slicer_to_plot works 
    217219        event = ApplyParams(params=params, plot_list=apply_to_list) 
    218220        wx.PostEvent(self, event) 
    219  
    220221        # TODO: save file (if desired) 
    221222        # TODO: send to fitting (if desired) 
     
    233234        :param plot: 2D plot panel to apply a slicer to 
    234235        :param type: The type of slicer to apply to the panel 
    235         :return: Return the plot with the slicer applied 
    236236        """ 
    237237        if type is None: 
     
    247247 
    248248    def process_list(self): 
     249        """ 
     250        Populate the check list from the currently plotted 2D data 
     251        """ 
    249252        self.checkme = None 
    250253        main_window = self.parent.parent 
    251254        self.loaded_data = [] 
    252255        id = wx.NewId() 
     256        # Iterate over the loaded plots and find all 2D panels 
    253257        for key, value in main_window.plot_panels.iteritems(): 
    254258            if isinstance(value, ModelPanel2D): 
    255259                self.loaded_data.append(value.data2D.name) 
    256260                if value.data2D.id == self.parent.data2D.id: 
     261                    # Set current plot panel as uncheckable 
    257262                    self.checkme = self.loaded_data.index(value.data2D.name) 
    258263        self.data_list = wx.CheckListBox(parent=self, id=id, 
    259264                                         choices=self.loaded_data, 
    260265                                         name="Apply Slicer to 2D Plots:") 
    261         if self.checkme is not None: 
    262             self.data_list.Check(self.checkme) 
     266        # Check all items bty default 
     267        for item in range(len(self.data_list.Items)): 
     268            self.data_list.Check(item) 
    263269        self.data_list.Bind(wx.EVT_CHECKLISTBOX, self.onCheckBoxList) 
    264270 
    265271    def onCheckBoxList(self, e): 
    266272        """ 
    267         Do not allow a checkbox to be unchecked 
     273        Prevent a checkbox item from being unchecked 
    268274        :param e: Event triggered when a checkbox list item is checked 
    269275        """ 
     
    273279 
    274280    def apply_params_list(self, evt=None): 
     281        """ 
     282        Event based parameter setting. 
     283        :param evt: Event triggered to apply parameters to a list of plots 
     284                    evt should have attrs plot_list and params 
     285        """ 
     286        # Apply parameter list to each plot as desired 
    275287        for item in evt.plot_list: 
    276288            item.slicer.set_params(evt.params) 
    277289            item.slicer.base.update() 
     290        # Close the slicer window 
    278291        self.Destroy() 
Note: See TracChangeset for help on using the changeset viewer.