Changes in / [225aca8:d06c34c] in sasview


Ignore:
Files:
3 deleted
29 edited

Legend:

Unmodified
Added
Removed
  • build_tools/jenkins_osx_build.sh

    re9e3e38 r460f5f2  
    4646python setup_mac.py py2app 
    4747 
    48 #cd $WORKSPACE/sasview/dist 
    49 #tar -czf `python -c "import pkg_resources;print '%s.tar.gz SasView-%s.app' % (pkg_resources.get_distribution('sasview').egg_name(),pkg_resources.get_distribution('sasview').version)"` 
     48cd $WORKSPACE/sasview/dist 
     49tar -czf `python -c "import pkg_resources;print '%s.tar.gz' % pkg_resources.get_distribution('sasview').egg_name()"` sasview.app 
  • sasview.latestversion

    r9533593 r0ea31ca  
    1 3.1.1 
     13.1.0 
  • sasview/README.txt

    r9533593 r8bea1519  
    441- Features 
    55=========== 
    6  
    7    - New in Version 3.1.1 
    8      -------------------- 
    9      - Fixes bug #457 that prevented SasView from starting if the user was not 
    10        connected to the internet, or was behind a proxy server. 
    116 
    127   - New in Version 3.1.0 
     
    307302          different browser and set that as your default browser. Issues have 
    308303          been noted with Internet Explorer 11. 
    309         - Check for Updates may fail (with the status bar message ' Cannot  
    310           connect to the application server') if your internet connection uses  
    311           a proxy server. Tested resolutions for this are described on the  
    312           website FAQ. 
    313304        - The copy and paste functions (^C, ^V) in the batch mode results grid 
    314305          require two clicks: one to select the cell and a second to select the 
  • sasview/__init__.py

    r9533593 rbc84fa7  
    1 __version__ = "3.1.1" 
     1__version__ = "3.1.0" 
    22__build__ = "1" 
  • sasview/local_config.py

    r957af0d r5846bb5  
    1313__build__ = sas.sasview.__build__ 
    1414__download_page__ = 'https://github.com/SasView/sasview/releases' 
    15 __update_URL__ = 'http://www.sasview.org/latestversion.json' 
     15__update_URL__ = ['raw.githubusercontent.com', 
     16                  '/SasView/sasview/master/sasview.latestversion'] 
     17 
    1618 
    1719# Debug message flag 
     
    129131DEFAULT_PERSPECTIVE = 'None' 
    130132 
    131 # Time out for updating sasview 
    132 UPDATE_TIMEOUT = 2 
    133  
    134133def printEVT(message): 
    135134    if __EVT_DEBUG__: 
  • sasview/setup_mac.py

    r49cd712 r018582f  
    116116                                   CFBundleTypeRole="Shell" )],) 
    117117 
    118 #Get version - NB nasty hack. Need to find correct way to give path to installed sasview (AJJ) 
    119 import __init__ as sasviewver 
    120  
    121 VERSION = sasviewver.__version__ 
    122 APPNAME = "SasView "+VERSION 
    123 DMGNAME = "SasView-"+VERSION 
    124  
    125118APP = ['sasview.py'] 
    126119DATA_FILES += ['images','test','media'] 
     
    140133           } 
    141134setup( 
    142     name=APPNAME, 
     135    name="sasview", 
    143136    app=APP, 
    144137    data_files=DATA_FILES, 
     
    147140    setup_requires=['py2app'], 
    148141) 
    149  
    150 #Build dmg 
    151 DMG="dist/%s.dmg"%DMGNAME 
    152 if os.path.exists(DMG): os.unlink(DMG) 
    153 os.system('cd dist && ../../build_tools/dmgpack.sh "%s" "%s.app"'%(DMGNAME,APPNAME)) 
    154 os.system('chmod a+r "%s"'%DMG) 
    155  
  • src/sas/guiframe/config.py

    r9989a6a r5846bb5  
    1010__build__ = '1' 
    1111__download_page__ = 'https://github.com/SasView/sasview/releases' 
    12 __update_URL__ = 'http://www.sasview.org/latestversion.json' 
     12__update_URL__ = ['raw.githubusercontent.com', 
     13                  '/SasView/sasview/master/sasview.latestversion'] 
    1314 
    1415 
  • src/sas/guiframe/data_processor.py

    r44d20af re54dbc3e  
    11""" 
    2 Implement grid used to store results of a batch fit. 
    3  
    4 This is in Guiframe rather than fitting which is probably where it should be. 
    5 Actually could be a generic framework implemented in fit gui module.  At this 
    6 point however there this grid behaves independently of the fitting panel and 
    7 only knows about information sent to it but not about the fits or fit panel and 
    8 thus cannot feed back to the fitting panel.  This could change in the future. 
    9  
    10 The organization of the classes goes as: 
    11  
    12 .. image::  ../../user/guiframe/BatchGridClassLayout.png 
    13    :align:   center 
    14  
     2Implement grid used to store data 
    153""" 
    164import wx 
     
    3826    """ 
    3927    Object describing a cell in  the grid. 
     28 
    4029    """ 
    4130    def __init__(self): 
    42         """ 
    43         Initialize attributes of class (label, value, col, row, object) 
    44         """ 
    4531        self.label = "" 
    4632        self.value = None 
     
    5339    """ 
    5440    Return a dictionary of column label and index or row selected 
    55  
    5641    :param sentence: String to parse 
    5742    :param list: list of columns label 
    58     :returns: col_dict 
    5943    """ 
    60  
    6144    p2 = re.compile(r'\d+') 
    6245    p = re.compile(r'[\+\-\*\%\/]') 
     
    9881 
    9982class SPanel(ScrolledPanel): 
    100     """ 
    101     ensure proper scrolling of GridPanel  
    102      
    103     Adds a SetupScrolling call to the normal ScrolledPanel init.     
    104     GridPanel then subclasses this class 
    105      
    106     """ 
    10783    def __init__(self, parent, *args, **kwds): 
    108         """ 
    109         initialize ScrolledPanel then force a call to SetupScrolling 
    110  
    111         """ 
    11284        ScrolledPanel.__init__(self, parent, *args, **kwds) 
    11385        self.SetupScrolling() 
     
    11587 
    11688class GridCellEditor(sheet.CCellEditor): 
    117     """ 
    118     Custom cell editor 
    119  
    120     This subclasses the sheet.CCellEditor (itself a subclass of 
    121     grid.GridCellEditor) in order to override two of its methods: 
    122     PaintBackrgound and EndEdit. 
    123      
    124     This is necessary as the sheet module is broken in wx 3.0.2 and 
    125     improperly subclasses grid.GridCellEditor 
    126     """ 
     89    """ Custom cell editor """ 
    12790    def __init__(self, grid): 
    128         """ 
    129         Override of CCellEditor init. Runs the grid.GridCellEditor init code 
    130         """ 
    13191        super(GridCellEditor, self).__init__(grid) 
    13292 
    133     def PaintBackground(self, dc, rect, attr): 
    134         """ 
    135         Overrides wx.sheet.CCellEditor.PaintBackground which incorrectly calls 
    136         the base class method. 
    137  
    138         In wx3.0 all paint objects must explicitly 
    139         have a wxPaintDC (Device Context) object.  Thus the paint event which 
    140         generates a call to this method provides such a DC object and the 
    141         base class in grid expects to receive that object.  sheet was apparently 
    142         not updated to reflect this and hence fails.  This could thus 
    143         become obsolete in a future bug fix of wxPython. 
    144  
    145         Apart from adding a dc variable in the list of arguments in the def 
    146         and in the call to the base class the rest of this method is copied 
    147         as is from sheet.CCellEditor.PaintBackground 
    148  
    149         **From original GridCellEditor docs:** 
    150  
    151         Draws the part of the cell not occupied by the edit control.  The 
    152         base class version just fills it with background colour from the 
    153         attribute. 
    154  
    155         NOTE: There is no need to override this if you don't need 
    156         to do something out of the ordinary. 
    157  
    158         :param dc: the wxDC object for the paint 
    159         """ 
    160         # Call base class method. 
    161         DC = dc 
    162         super(sheet.CCellEditor,self).PaintBackground(DC, rect, attr) 
    163  
    16493    def EndEdit(self, row, col, grid, previous): 
    165         """ 
    166         Commit editing the current cell. Returns True if the value has changed. 
    167  
    168         :param previous: previous value in the cell 
     94        """  
     95            Commit editing the current cell. Returns True if the value has changed. 
     96            @param previous: previous value in the cell 
    16997        """ 
    17098        changed = False                             # Assume value not changed 
     
    180108class GridPage(sheet.CSheet): 
    181109    """ 
    182     Class that receives the results of a batch fit. 
    183  
    184     GridPage displays the received results in a wx.grid using sheet.  This is 
    185     then used by GridPanel and GridFrame to present the full GUI. 
    186110    """ 
    187111    def __init__(self, parent, panel=None): 
    188112        """ 
    189         Initialize 
    190  
    191         Initialize all the attributes of GridPage, and the events. include 
    192         the init stuff from sheet.CSheet as well. 
    193113        """ 
    194114        #sheet.CSheet.__init__(self, parent) 
    195  
     115         
    196116        # The following is the __init__ from CSheet. ########################## 
    197117        # We re-write it here because the class is broken in wx 3.0, 
     
    219139 
    220140        # Sink events 
     141        self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnLeftClick) 
     142        self.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.OnRightClick) 
     143        #self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.OnLeftDoubleClick) 
    221144        self.Bind(wx.grid.EVT_GRID_RANGE_SELECT, self.OnRangeSelect) 
    222145        self.Bind(wx.grid.EVT_GRID_ROW_SIZE, self.OnRowSize) 
    223146        self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.OnColSize) 
     147        self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnCellChange) 
    224148        self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnGridSelectCell) 
    225         # NOTE: the following bind to standard sheet methods that are 
    226         # overriden in this subclassn - actually we have currently 
    227         # disabled the on_context_menu that would override the OnRightClick 
    228         self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnCellChange) 
    229         self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnLeftClick) 
    230         self.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.OnRightClick) 
    231         #self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.OnLeftDoubleClick) 
    232149        # This ends the __init__ section for CSheet. ########################## 
    233  
    234  
    235  
    236         # The following events must be bound even if CSheet is working  
    237         # properly and does not need the above re-implementation of the 
    238         # CSheet init method.  Basically these override any intrinsic binding 
    239         self.Bind(wx.grid.EVT_GRID_LABEL_RIGHT_CLICK, self.on_right_click) 
    240         self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.on_left_click) 
    241150 
    242151        self.AdjustScrollbars() 
     
    278187        if self.GetNumberCols() > 0: 
    279188            self.default_col_width = self.GetColSize(0) 
    280         # We have moved these to the top of the init section with the 
    281         # rest of the grid event bindings from the sheet init when 
    282         # appropriate 
    283189        #self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.on_left_click) 
    284190        #self.Bind(wx.grid.EVT_GRID_LABEL_RIGHT_CLICK, self.on_right_click) 
     
    288194 
    289195    def OnLeftClick(self, event): 
    290         """ 
    291         Overrides sheet.CSheet.OnLefClick. 
    292  
    293         Processes when a cell is selected by left clicking on that cell. First 
    294         process the base Sheet method then the current class specific method 
    295         """ 
    296196        sheet.CSheet.OnLeftClick(self, event) 
    297197        self.on_selected_cell(event) 
    298  
    299  
    300     def OnCellChange(self, event): 
    301         """ 
    302         Overrides sheet.CSheet.OnCellChange.   
    303  
    304         Processes when a cell has been edited by a cell editor. Checks for the 
    305         edited row being outside the max row to use attribute and if so updates 
    306         the last row.  Then calls the base handler using skip. 
     198         
     199    def on_edit_cell(self, event): 
     200        """ 
    307201        """ 
    308202        row, _ = event.GetRow(), event.GetCol() 
     
    315209    def on_selected_cell(self, event): 
    316210        """ 
    317         Handler catching cell selection. 
    318  
    319         Called after calling base 'on left click' method. 
    320         """ 
    321  
     211        Handler catching cell selection 
     212        """ 
    322213        flag = event.CmdDown() or event.ControlDown() 
    323214        flag_shift = event.ShiftDown() 
     
    389280    def on_left_click(self, event): 
    390281        """ 
    391         Is triggered when the left mouse button is clicked while the mouse 
    392         is hovering over the column 'label.' 
    393  
    394         This processes the information on the selected column: the column name 
    395         (in row 0 of column) and the range of cells with a valid value to be 
    396         used by the GridPanel set_axis methods. 
    397         """ 
    398  
     282        Catch the left click on label mouse event 
     283        """ 
    399284        flag = event.CmdDown() or event.ControlDown() 
    400285 
     
    439324    def on_right_click(self, event): 
    440325        """ 
    441         Is triggered when the right mouse button is clicked while the mouse 
    442         is hovering over the column 'label.' 
    443  
    444         This brings up a context menu that allows the deletion of the column, 
    445         or the insertion of a new column either to the right or left of the 
    446         current column.  If inserting a new column can insert a blank column or 
    447         choose a number of hidden columns.  By default all the error parameters 
    448         are in hidden columns so as to save space on the grid.  Also any other 
    449         intrinsic variables stored with the data such as Temperature, pressure, 
    450         time etc can be used to populate this menu. 
    451         """ 
    452  
     326        Catch the right click mouse 
     327        """ 
    453328        col = event.GetCol() 
    454329        row = event.GetRow() 
     
    485360    def insert_col_menu(self, menu, label, window): 
    486361        """ 
    487         method called to populate the 'insert column before current column' 
    488         submenu. 
    489         """ 
    490  
     362        """ 
    491363        if self.data is None: 
    492364            return 
     
    508380    def insert_after_col_menu(self, menu, label, window): 
    509381        """ 
    510         Method called to populate the 'insert column after current column' 
    511         submenu 
    512         """ 
    513  
     382        """ 
    514383        if self.data is None: 
    515384            return 
     
    532401    def on_remove_column(self, event=None): 
    533402        """ 
    534         Called when user chooses remove from the column right click menu 
    535         Checks the columnn exists then calls the remove_column method 
    536         """ 
    537  
     403        """ 
    538404        if self.selected_cols is not None or len(self.selected_cols) > 0: 
    539405            col = self.selected_cols[0] 
     
    542408    def remove_column(self, col, numCols=1): 
    543409        """ 
    544         Remove the col column from the current grid 
    545         """ 
    546  
     410        Remove column to the current grid 
     411        """ 
    547412        # add data to the grid     
    548413        row = 0 
     
    564429    def on_insert_column(self, event): 
    565430        """ 
    566         Called when user chooses insert 'column before' submenu 
    567         of the column context menu obtained when right clicking on a given 
    568         column header. 
    569  
    570         Sets up to insert column into the current grid before the current 
    571         highlighted column location and sets up what to populate that column 
    572         with.  Then calls insert_column method to actually do the insertion.  
    573         """ 
    574  
     431        """ 
    575432        if self.selected_cols is not None or len(self.selected_cols) > 0: 
    576433            col = self.selected_cols[0] 
     
    585442    def on_insert_after_column(self, event): 
    586443        """ 
    587         Called when user chooses insert 'column after' submenu 
    588         of the column context menu obtained when right clicking on a given 
    589         column header. 
    590  
    591         Sets up to insert column into the current grid after the current 
    592         highlighted column location and sets up what to populate that column 
    593         with.  Then calls insert_column method to actually do the insertion.  
    594         """ 
    595  
     444        Insert the given column after the highlighted column 
     445        """ 
    596446        if self.selected_cols is not None or len(self.selected_cols) > 0: 
    597447            col = self.selected_cols[0] + 1 
     
    605455    def insert_column(self, col, col_name): 
    606456        """ 
    607         Insert column at position col with data[col_name] into the current 
    608         grid. 
    609         """ 
    610  
     457        """ 
    611458        row = 0 
    612459        self.InsertCols(pos=col, numCols=1, updateLabels=True) 
     
    630477    def on_set_x_axis(self, event): 
    631478        """ 
    632         Just calls the panel version of the method 
    633         """ 
    634  
     479        """ 
    635480        self.panel.set_xaxis(x=self.axis_value, label=self.axis_label) 
    636481 
    637482    def on_set_y_axis(self, event): 
    638483        """ 
    639         Just calls the panel version of the method 
    640         """ 
    641  
     484        """ 
    642485        self.panel.set_yaxis(y=self.axis_value, label=self.axis_label) 
    643486 
     
    645488        """ 
    646489        Add data to the grid 
    647  
    648490        :param data_inputs: data to use from the context menu of the grid 
    649         :param data_ouputs: default columns displayed 
    650         """ 
    651  
     491        :param data_ouputs: default columns deplayed 
     492        """ 
    652493        self.file_name = file_name 
    653494        self.details = details 
     
    686527        Set the values in grids 
    687528        """ 
    688  
    689529        # add data to the grid 
    690530        row = 0 
     
    722562        Return value contained in the grid 
    723563        """ 
    724  
    725564        grid_view = {} 
    726565        for col in xrange(self.GetNumberCols()): 
     
    745584    def onContextMenu(self, event): 
    746585        """ 
    747         Method to handle cell right click context menu.  
    748  
    749         THIS METHOD IS NOT CURRENTLY USED.  It is designed to provide a 
    750         cell pop up context by right clicking on a cell and gives the 
    751         option to cut, paste, and clear. This will probably be removed in 
    752         future versions and is being superceded by more traditional cut and 
    753         paste options. 
    754         """ 
    755  
     586        Default context menu 
     587        """ 
    756588        wx_id = wx.NewId() 
    757589        c_menu = wx.Menu() 
     
    788620    def on_copy(self, event): 
    789621        """ 
    790         Called when copy is chosen from cell right click context menu 
    791  
    792         THIS METHOD IS NOT CURRENTLY USED.  it is part of right click cell 
    793         context menu which is being removed. This will probably be removed in 
    794         future versions and is being superceded by more traditional cut and 
    795         paste options 
    796         """ 
    797  
     622        On copy event from the contextmenu 
     623        """ 
    798624        self.Copy() 
    799625 
    800626    def on_paste(self, event): 
    801627        """ 
    802         Called when paste is chosen from cell right click context menu 
    803  
    804         THIS METHOD IS NOT CURRENTLY USED.  it is part of right click cell 
    805         context menu which is being removed. This will probably be removed in 
    806         future versions and is being superceded by more traditional cut and 
    807         paste options 
    808         """ 
    809  
     628        On paste event from the contextmenu 
     629        """ 
    810630        if self.data == None: 
    811631            self.data = {} 
     
    816636    def on_clear(self, event): 
    817637        """ 
    818         Called when clear cell is chosen from cell right click context menu 
    819  
    820         THIS METHOD IS NOT CURRENTLY USED.  it is part of right click cell 
    821         context menu which is being removed. This will probably be removed in 
    822         future versions and is being superceded by more traditional cut and 
    823         paste options 
    824         """ 
    825  
     638        Clear the cells selected 
     639        """ 
    826640        self.Clear() 
    827641 
     
    832646    ## Title to appear on top of the window 
    833647    """ 
    834  
    835648    window_caption = "Notebook " 
    836649 
     
    869682    def enable_close_button(self): 
    870683        """ 
    871         display the close button on the tab if more than 1 tab exits. 
    872         Otherwise remove the close button 
    873         """ 
    874  
     684        display the close button on tab for more than 1 tabs else remove the 
     685        close button 
     686        """ 
    875687        if self.GetPageCount() <= 1: 
    876688            style = self.GetWindowStyleFlag() 
     
    888700    def on_edit_axis(self): 
    889701        """ 
    890         Return the select cell range from a given selected column. Checks that 
    891         all cells are from the same column 
    892         """ 
    893  
     702        Return the select cell of a given selected column. Check that all cells 
     703        are from the same column 
     704        """ 
    894705        pos = self.GetSelection() 
    895706        grid = self.GetPage(pos) 
     
    921732        Add highlight rows 
    922733        """ 
    923  
    924734        pos = self.GetSelection() 
    925735        grid = self.GetPage(pos) 
     
    949759    def get_column_labels(self): 
    950760        """ 
    951         return dictionary of columns labels on the current page 
    952         """ 
    953  
     761        return dictionary of columns labels of the current page 
     762        """ 
    954763        pos = self.GetSelection() 
    955764        grid = self.GetPage(pos) 
     
    964773        """ 
    965774        Receive a list of cells and  create a string presenting the selected 
    966         cells that can be used as data for one axis of a plot. 
    967  
     775        cells. 
    968776        :param cell_list: list of tuple 
     777 
    969778        """ 
    970779        pos = self.GetSelection() 
     
    1044853        close the page 
    1045854        """ 
    1046  
    1047855        if self.GetPageCount() == 1: 
    1048856            event.Veto() 
     
    1050858 
    1051859    def set_data(self, data_inputs, data_outputs, details="", file_name=None): 
    1052         """ 
    1053         """ 
    1054860        if data_outputs is None or data_outputs == {}: 
    1055861            return 
     
    1074880    def get_odered_results(self, inputs, outputs=None): 
    1075881        """ 
    1076         Order a list of 'inputs.' Used to sort rows and columns to present 
    1077         in batch results grid. 
    1078         """ 
    1079  
     882        Get ordered the results 
     883        """ 
    1080884        # Let's re-order the data from the keys in 'Data' name. 
    1081885        if outputs == None: 
     
    1110914        Append a new column to the grid 
    1111915        """ 
    1112  
    1113         # I Believe this is no longer used now that we have removed the  
    1114         # edit menu from the menubar - PDB July 12, 2015 
    1115916        pos = self.GetSelection() 
    1116917        grid = self.GetPage(pos) 
     
    1121922        Remove the selected column from the grid 
    1122923        """ 
    1123         # I Believe this is no longer used now that we have removed the  
    1124         # edit menu from the menubar - PDB July 12, 2015 
    1125924        pos = self.GetSelection() 
    1126925        grid = self.GetPage(pos) 
     
    1128927 
    1129928class GridPanel(SPanel): 
    1130     """ 
    1131     A ScrolledPanel class that contains the grid sheet as well as a number of 
    1132     widgets to create interesting plots and buttons for help etc. 
    1133     """ 
    1134  
    1135929    def __init__(self, parent, data_inputs=None, 
    1136930                 data_outputs=None, *args, **kwds): 
    1137         """ 
    1138         Initialize the GridPanel 
    1139         """ 
    1140  
    1141931        SPanel.__init__(self, parent, *args, **kwds) 
    1142932 
     
    1200990    def get_plot_axis(self, col, list): 
    1201991        """ 
     992 
    1202993        """ 
    1203994        axis = [] 
     
    12241015    def on_view(self, event): 
    12251016        """ 
    1226         Get object represented by the given cells and plot them.  Basically 
    1227         plot the colum in y vs the column in x. 
    1228         """ 
    1229  
     1017        Get object represented buy the given cell and plot them. 
     1018        """ 
    12301019        pos = self.notebook.GetSelection() 
    12311020        grid = self.notebook.GetPage(pos) 
     
    13071096        Evaluate the contains of textcrtl and plot result 
    13081097        """ 
    1309  
    13101098        pos = self.notebook.GetSelection() 
    13111099        grid = self.notebook.GetPage(pos) 
     
    14151203        running "file:///...." 
    14161204 
    1417         :param evt: Triggers on clicking the help button 
    1418         """ 
    1419  
     1205    :param evt: Triggers on clicking the help button 
     1206    """ 
    14201207        #import documentation window here to avoid circular imports 
    14211208        #if put at top of file with rest of imports. 
     
    14311218        Get sentence from dict 
    14321219        """ 
    1433  
    14341220        for tok, (col_name, list) in dict.iteritems(): 
    14351221            col = column_names[col_name] 
     
    14441230    def layout_grid(self): 
    14451231        """ 
    1446         Draw the area related to the grid by adding it as the first element 
    1447         in the panel's grid_sizer 
    1448         """ 
    1449  
     1232        Draw the area related to the grid 
     1233        """ 
    14501234        self.notebook = Notebook(parent=self) 
    14511235        self.notebook.set_data(self._data_inputs, self._data_outputs) 
     
    14541238    def layout_plotting_area(self): 
    14551239        """ 
    1456         Add the area containing all the plot options, buttons etc to a plotting 
    1457         area sizer to later be added to the top level grid_sizer 
    1458         """ 
    1459  
     1240        Draw area containing options to plot 
     1241        """ 
    14601242        view_description = wx.StaticBox(self, -1, 'Plot Fits/Residuals') 
    14611243        note = "To plot the fits (or residuals), click the 'View Fits' button" 
     
    14991281                                   (self.plot_button, 0, 
    15001282                                    wx.LEFT | wx.TOP | wx.BOTTOM, 12), 
    1501                                    (self.help_button,0, 
     1283                                   (self.help_button,0,  
    15021284                                    wx.LEFT | wx.TOP | wx.BOTTOM, 12)]) 
    15031285 
     
    15341316        Get the selected column on  the visible grid and set values for axis 
    15351317        """ 
    1536  
    15371318        try: 
    15381319            cell_list = self.notebook.on_edit_axis() 
     
    15541335        Receive a list of cells and  create a string presenting the selected 
    15551336        cells. 
    1556  
    15571337        :param cell_list: list of tuple 
    1558         """ 
    1559  
     1338 
     1339        """ 
    15601340        if self.notebook is not None: 
    15611341            return self.notebook.create_axis_label(cell_list) 
     
    15651345        get controls to modify 
    15661346        """ 
    1567  
    15681347        if label != None: 
    15691348            tcrtl_label.SetValue(str(label)) 
     
    15741353        """ 
    15751354        """ 
    1576         # I Believe this is no longer used now that we have removed the 
    1577         # edit menu from the menubar - PDB July 12, 2015 
    15781355        if self.notebook is not None: 
    15791356            self.notebook.add_column() 
     
    15821359        """ 
    15831360        """ 
    1584         # I Believe this is no longer used now that we have removed the 
    1585         # edit menu from the menubar - PDB July 12, 2015 
    15861361        if self.notebook is not None: 
    15871362            self.notebook.on_remove_column() 
     
    15891364 
    15901365class GridFrame(wx.Frame): 
    1591     """ 
    1592     The main wx.Frame for the batch results grid 
    1593     """ 
    1594  
    15951366    def __init__(self, parent=None, data_inputs=None, data_outputs=None, id=-1, 
    1596                  title="Batch Fitting Results Panel", size=(800, 500)): 
    1597         """ 
    1598         Initialize the Frame 
    1599         """ 
    1600  
     1367                 title="Grid Window", size=(800, 500)): 
    16011368        wx.Frame.__init__(self, parent=parent, id=id, title=title, size=size) 
    16021369        self.parent = parent 
     
    16221389        wx.EVT_MENU(self, self.save_menu.GetId(), self.on_save_page) 
    16231390 
    1624         # We need to grab a WxMenu handle here, otherwise the next one to grab 
    1625         # the handle will be treated as the Edit Menu handle when checking in 
    1626         # on_menu_open event handler and thus raise an exception when it hits an  
    1627         # unitialized object.  Alternative is to comment out that whole section 
    1628         # in on_menu_open, but that would make it more difficult to undo the 
    1629         # hidding of the menu.   PDB  July 12, 2015. 
    1630         # 
    1631         # To enable the Edit menubar comment out next line and uncomment the 
    1632         # following line. 
    1633         self.edit = wx.Menu() 
    1634         #self.add_edit_menu() 
    1635  
     1391        # To add the edit menu, call add_edit_menu() here. 
     1392        self.edit = None 
    16361393        self.Bind(wx.EVT_MENU_OPEN, self.on_menu_open) 
     1394         
    16371395        self.Bind(wx.EVT_CLOSE, self.on_close) 
    16381396 
    16391397    def add_edit_menu(self, menubar): 
    1640         """ 
    1641         populates the edit menu on the menubar.  Not activated as of SasView 
    1642         3.1.0 
    1643         """ 
    16441398        self.edit = wx.Menu() 
    16451399 
     
    16751429    def on_copy(self, event): 
    16761430        """ 
    1677         On Copy from the Edit menu item on the menubar 
    1678         """ 
    1679         # I Believe this is no longer used now that we have removed the  
    1680         # edit menu from the menubar - PDB July 12, 2015 
     1431        On Copy 
     1432        """ 
    16811433        if event != None: 
    16821434            event.Skip() 
     
    16871439    def on_paste(self, event): 
    16881440        """ 
    1689         On Paste from the Edit menu item on the menubar 
    1690         """ 
    1691         # I Believe this is no longer used now that we have removed the  
    1692         # edit menu from the menubar - PDB July 12, 2015 
     1441        On Paste 
     1442        """ 
    16931443        if event != None: 
    16941444            event.Skip() 
     
    16991449    def on_clear(self, event): 
    17001450        """ 
    1701         On Clear from the Edit menu item on the menubar 
    1702         """ 
    1703         # I Believe this is no longer used now that we have removed the  
    1704         # edit menu from the menubar - PDB July 12, 2015 
     1451        On Clear 
     1452        """ 
    17051453        pos = self.panel.notebook.GetSelection() 
    17061454        grid = self.panel.notebook.GetPage(pos) 
     
    17181466    def on_remove_column(self, event): 
    17191467        """ 
    1720         On remove column from the Edit menu Item on the menubar 
    1721         """ 
    1722         # I Believe this is no longer used now that we have removed the  
    1723         # edit menu from the menubar - PDB July 12, 2015 
     1468        On remove column 
     1469        """ 
    17241470        pos = self.panel.notebook.GetSelection() 
    17251471        grid = self.panel.notebook.GetPage(pos) 
     
    17891535    def on_save_page(self, event): 
    17901536        """ 
    1791         Saves data in grid to a csv file. 
    1792  
    1793         At this time only the columns displayed get saved.  Thus any error 
    1794         bars not inserted before saving will not be saved in the file 
    1795         """ 
    1796  
     1537        """ 
    17971538        if self.parent is not None: 
    17981539            pos = self.panel.notebook.GetSelection() 
     
    18251566    def on_open(self, event): 
    18261567        """ 
    1827         Open file containing batch result 
    1828         """ 
    1829  
     1568        Open file containg batch result 
     1569        """ 
    18301570        if self.parent is not None: 
    18311571            self.parent.on_read_batch_tofile(self) 
     
    18351575        open excel and display batch result in Excel 
    18361576        """ 
    1837  
    18381577        if self.parent is not None: 
    18391578            pos = self.panel.notebook.GetSelection() 
     
    18861625                 details="", *args, **kwds): 
    18871626        """ 
    1888         Initialize dialog 
    1889  
    18901627        :param parent: Window instantiating this dialog 
    1891         :param result: result to display in a grid or export to an external\ 
     1628        :param result: result to display in a grid or export to an external 
    18921629                application. 
    18931630        """ 
    1894  
    18951631        #kwds['style'] = wx.CAPTION|wx.SYSTEM_MENU 
    18961632        wx.Frame.__init__(self, parent, *args, **kwds) 
     
    19151651        Draw the content of the current dialog window 
    19161652        """ 
    1917  
    19181653        vbox = wx.BoxSizer(wx.VERTICAL) 
    19191654        box_description = wx.StaticBox(self.panel, -1, str("Batch Outputs")) 
     
    19691704        Get the user selection and display output to the selected application 
    19701705        """ 
    1971  
    19721706        if self.flag == 1: 
    19731707            self.parent.open_with_localapp(data_inputs=self.data_inputs, 
     
    19811715        close the Window 
    19821716        """ 
    1983  
    19841717        self.Close() 
    19851718 
     
    19881721        Receive event and display data into third party application 
    19891722        or save data to file. 
     1723 
    19901724        """ 
    19911725        if self.save_to_file.GetValue(): 
  • src/sas/guiframe/documentation_window.py

    rfb3f9af r7a508b6  
    4343    (self, parent, dummy_id, path, url_instruction, title, size=(850, 540)) 
    4444 
    45     :param path: path to html file beginning AFTER /doc/ and ending in the\ 
    46     file.html. 
    47     :param url_instructions: anchor string or other query e.g. '#MyAnchor' 
    48     :param title: text to place in the title bar of the help panel 
     45    :param path: path to html file beginning AFTER /doc/ and ending in the 
     46    file.html 
     47    :param url_instructions: anchor string or other query e.g. '#MyAnchor 
     48    :param title - text to place in the title bar of the help panel 
    4949    """ 
    5050    def __init__(self, parent, dummy_id, path, url_instruction, title, size=(850, 540)): 
  • src/sas/guiframe/gui_manager.py

    r957af0d r78f75d02  
    2727import urllib 
    2828import urllib2 
    29 import json 
     29 
    3030 
    3131from sas.guiframe.events import EVT_CATEGORY 
     
    4646from sas.guiframe.CategoryManager import CategoryManager 
    4747from sas.dataloader.loader import Loader 
    48 from sas.guiframe.proxy import Connection 
    4948from matplotlib import _pylab_helpers 
    50  
    5149 
    5250def get_app_dir(): 
     
    5452        The application directory is the one where the default custom_config.py 
    5553        file resides. 
    56  
    57         :returns: app_path - the path to the applicatin directory 
    5854    """ 
    5955    # First, try the directory of the executable we are running 
     
    7268 
    7369    # Finally, try the directory of the sasview module 
    74     # TODO: gui_manager will have to know about sasview until we 
     70    #TODO: gui_manager will have to know about sasview until we 
    7571    # clean all these module variables and put them into a config class 
    7672    # that can be passed by sasview.py. 
     
    834830    def PushStatusText(self, *args, **kwds): 
    835831        """ 
    836         .. todo:: No message is passed. What is this supposed to do? 
     832            FIXME: No message is passed. What is this supposed to do? 
    837833        """ 
    838834        field = self.sb.get_msg_position() 
    839835        wx.Frame.PushStatusText(self, field=field, 
    840                                 string="FIXME - PushStatusText called without text") 
     836                                string="FIXME: PushStatusText called without text") 
    841837 
    842838    def add_perspective(self, plugin): 
     
    894890        :param dir: directory in which to look for plug-ins 
    895891 
    896         :returns: list of plug-ins 
     892        :return: list of plug-ins 
    897893 
    898894        """ 
     
    941937                            file.close() 
    942938        except: 
    943             # Should raise and catch at a higher level and 
     939            # Should raise and catch at a higher level and  
    944940            # display error on status bar 
    945941            logging.error(sys.exc_value) 
     
    988984 
    989985        # Set up welcome panel 
    990         # TODO: this needs serious simplification 
     986        #TODO: this needs serious simplification 
    991987        if self.welcome_panel_class is not None: 
    992988            welcome_panel = MDIFrame(self, None, 'None', (100, 200)) 
     
    10781074    def onfreeze(self, theory_id): 
    10791075        """ 
    1080         Saves theory/model and passes to data loader. 
    1081  
    1082         ..warning:: This seems to be the exact same code as the next 
    1083         function called simply freeze. This probably needs fixing 
    10841076        """ 
    10851077        data_state_list = self._data_manager.freeze(theory_id) 
     
    10931085    def freeze(self, data_id, theory_id): 
    10941086        """ 
    1095         Saves theory/model and passes to data loader. 
    1096  
    1097         ..warning:: This seems to be the exact same code as the next 
    1098         function called simply freeze. This probably needs fixing 
    10991087        """ 
    11001088        data_state_list = self._data_manager.freeze_theory(data_id=data_id, 
     
    11611149        :param p: panel object to add to the AUI manager 
    11621150 
    1163         :returns: ID of the event associated with the new panel [int] 
     1151        :return: ID of the event associated with the new panel [int] 
    11641152 
    11651153        """ 
     
    11821170        # Append nummber 
    11831171        captions = self._get_plotpanel_captions() 
    1184         # FIXME: Fix this awful loop 
     1172        #FIXME: Fix this aweful loop 
    11851173        while (1): 
    11861174            caption = windowcaption + '%s' % str(self.graph_num) 
     
    20432031        a call-back method when the current version number has been obtained. 
    20442032        """ 
    2045         version_info = {"version": "0.0.0"} 
    2046         c = Connection(config.__update_URL__, config.UPDATE_TIMEOUT) 
    2047         response = c.connect() 
    2048         if response is not None: 
    2049             try: 
    2050                 #  
    2051                 content = response.read().strip() 
    2052                 logging.info("Connected to www.sasview.org. Latest version: %s" 
    2053                              % (content)) 
    2054                 version_info = json.loads(content) 
    2055             except: 
    2056                 logging.info("Failed to connect to www.sasview.org") 
    2057         self._process_version(version_info, standalone=event == None)     
    2058  
    2059          
    2060          
    2061 #          
    2062 #         try: 
    2063 #             req = urllib2.Request(config.__update_URL__) 
    2064 #             res = urllib2.urlopen(req) 
    2065 #             content = res.read().strip() 
    2066 #             logging.info("Connected to www.sasview.org. Latest version: %s" 
    2067 #                          % (content)) 
    2068 #             version_info = json.loads(content) 
    2069 #         except: 
    2070 #             logging.info("Failed to connect to www.sasview.org") 
    2071 #             version_info = {"version": "0.0.0"} 
    2072 #         self._process_version(version_info, standalone=event == None) 
    2073  
    2074     def _process_version(self, version_info, standalone=True): 
     2033        try: 
     2034            req = urllib2.Request('https://github.com/SasView/sasview/releases/latest') 
     2035            res = urllib2.urlopen(req) 
     2036            get_url= res.geturl() 
     2037            content = get_url.partition('/v')[2] 
     2038            logging.info("connected to GitHub. sasview.latestversion = %s" 
     2039                         % (content)) 
     2040        except: 
     2041            msg = traceback.format_exc() 
     2042            logging.info(msg) 
     2043            logging.info("failed to connect to GitHub") 
     2044            content = "0.0.0" 
     2045 
     2046        version = content.strip() 
     2047        logging.info("Latest SasView version number: %s" % (version)) 
     2048        if len(re.findall('\d+\.\d+\.\d+$', version)) < 0: 
     2049            content = "0.0.0" 
     2050        self._process_version(content, standalone=event == None) 
     2051 
     2052    def _process_version(self, version, standalone=True): 
    20752053        """ 
    20762054        Call-back method for the process of checking for updates. 
     
    20852063        """ 
    20862064        try: 
    2087             version = version_info["version"] 
    20882065            if version == "0.0.0": 
    20892066                msg = "Could not connect to the application server." 
     
    20942071                if not standalone: 
    20952072                    import webbrowser 
    2096                     if "download_url" in version_info: 
    2097                         webbrowser.open(version_info["download_url"]) 
    2098                     else: 
    2099                         webbrowser.open(config.__download_page__) 
     2073                    webbrowser.open(config.__download_page__) 
    21002074                else: 
    21012075                    msg += "See the help menu to download it." 
     
    24612435        """ 
    24622436        Save file as txt 
    2463  
    2464         .. todo:: Refactor and remove this method. See 'TODO' in _onSave. 
     2437        :TODO: Refactor and remove this method. See TODO in _onSave. 
    24652438        """ 
    24662439        if not path == None: 
     
    28902863                    # Append nummber 
    28912864                    inc = 1 
    2892                     # FIXME: fix this terrible loop 
     2865                    #FIXME: fix this terrible loop 
    28932866                    while (1): 
    28942867                        caption = new_caption + '_%s' % str(inc) 
     
    29132886 
    29142887        :param name: window_name in AuiPaneInfo 
    2915         :returns: AuiPaneInfo of the name 
     2888        :return: AuiPaneInfo of the name 
    29162889        """ 
    29172890        for panel in self.plot_panels.values(): 
     
    30853058                pass 
    30863059 
    3087         # Draw all panels 
     3060        # Draw all panels  
    30883061        if count == 1: 
    30893062            f_draw(self.schedule_full_draw_list[0]) 
    30903063        else: 
    30913064            map(f_draw, self.schedule_full_draw_list) 
    3092         # Reset the attr 
     3065        # Reset the attr   
    30933066        if len(self.schedule_full_draw_list) == 0: 
    30943067            self.set_schedule(False) 
     
    31313104        Get window size 
    31323105 
    3133         :returns: size 
    3134         :rtype: tuple 
     3106        :return size: tuple 
    31353107        """ 
    31363108        width, height = self.GetSizeTuple() 
     
    31533125            pass 
    31543126 
    3155         # restart idle 
     3127        # restart idle         
    31563128        self._redraw_idle(*args, **kwargs) 
    31573129 
     
    31613133        Restart Idle 
    31623134        """ 
    3163         # restart idle 
     3135        # restart idle    
    31643136        self.idletimer.Restart(100 * TIME_FACTOR, *args, **kwargs) 
    31653137 
     
    33183290        """ 
    33193291        is_maximized = False 
    3320         # Get size of screen without 
     3292        # Get size of screen without  
    33213293        for screenCount in range(wx.Display().GetCount()): 
    33223294            screen = wx.Display(screenCount) 
     
    33353307            customHeight = displayHeight * 0.9 
    33363308        else: 
    3337             # If the custom screen is bigger than the 
     3309            # If the custom screen is bigger than the  
    33383310            # window screen than make maximum size 
    33393311            if customWidth > displayWidth: 
     
    34333405    def show_data_panel(self, action): 
    34343406        """ 
    3435         Turns on the data panel 
    3436  
    3437         The the data panel is optional.  Most of its functions can be 
    3438         performed from the menu bar and from the plots. 
    34393407        """ 
    34403408        self.parent.show_data_panel(action) 
  • src/sas/guiframe/local_perspectives/plotting/Plotter1D.py

    r098f3d2 rb99a4552  
    564564            self._slicerpop.Append(wx_id, '&Print Image', 'Print image ') 
    565565            wx.EVT_MENU(self, wx_id, self.onPrint) 
     566            wx_id = wx.NewId() 
     567            self._slicerpop.Append(wx_id, '&Print Preview', 'Print preview') 
     568            wx.EVT_MENU(self, wx_id, self.onPrinterPreview) 
    566569 
    567570            wx_id = wx.NewId() 
  • src/sas/guiframe/local_perspectives/plotting/Plotter2D.py

    r098f3d2 rc039589  
    300300 
    301301        wx_id = wx.NewId() 
     302        slicerpop.Append(wx_id, '&Print Preview', 'Print preview') 
     303        wx.EVT_MENU(self, wx_id, self.onPrinterPreview) 
     304 
     305        wx_id = wx.NewId() 
    302306        slicerpop.Append(wx_id, '&Copy to Clipboard', 'Copy to the clipboard') 
    303307        wx.EVT_MENU(self, wx_id, self.OnCopyFigureMenu) 
  • src/sas/guiframe/local_perspectives/plotting/SimplePlot.py

    r098f3d2 rb40ad40  
    5858        slicerpop.Append(wx_id, '&Print Image', 'Print image') 
    5959        wx.EVT_MENU(self, wx_id, self.onPrint) 
     60 
     61        wx_id = wx.NewId() 
     62        slicerpop.Append(wx_id, '&Print Preview', 'Print preview') 
     63        wx.EVT_MENU(self, wx_id, self.onPrinterPreview) 
    6064 
    6165        wx_id = wx.NewId() 
     
    230234        wx.EVT_MENU(self, id, self.on_print_image) 
    231235 
     236        id = wx.NewId() 
     237        item = wx.MenuItem(menu, id, "&Print Preview") 
     238        item.SetBitmap(preview_bmp) 
     239        menu.AppendItem(item) 
     240        wx.EVT_MENU(self, id, self.on_print_preview) 
     241 
    232242        menu.AppendSeparator() 
    233243        id = wx.NewId() 
  • src/sas/guiframe/report_dialog.py

    r098f3d2 re8bb5b6  
    6666        hbox.Add(button_close) 
    6767        button_close.SetFocus() 
     68 
     69        button_preview = wx.Button(self, wx.NewId(), "Preview") 
     70        button_preview.SetToolTipString("Print preview this report.") 
     71        button_preview.Bind(wx.EVT_BUTTON, self.onPreview, 
     72                            id=button_preview.GetId())  
     73        hbox.Add(button_preview) 
    6874 
    6975        button_print = wx.Button(self, wx.NewId(), "Print") 
  • src/sas/models/CoreMultiShellModel.py

    re0c16ce rac7be54  
    5353        ## parameters with orientation: can be removed since there is no orientational params 
    5454        self._set_orientation_params() 
    55  
     55                 
     56         
    5657    def _clone(self, obj): 
    5758        """ 
     
    6667 
    6768        return obj 
    68  
     69     
     70     
    6971    def _set_dispersion(self): 
    7072        """ 
    7173        model dispersions 
    7274        Polydispersion should not be applied to s_model 
    73         """ 
    74         ##set dispersion from model 
     75        """  
     76        ##set dispersion from model  
    7577        for name , value in self.model.dispersion.iteritems():       
    7678            nshell = 0 
     
    8082                    if name.split('_')[-1] == 'shell%s' % str(nshell): 
    8183                        self.dispersion[name] = value 
    82                     else: 
     84                    else:  
    8385                        continue 
    8486            else: 
    8587                self.dispersion[name] = value 
    86  
     88                 
    8789    def _set_orientation_params(self): 
    8890        """ 
    8991        model orientation and magnetic parameters, same params for this model 
    90         """ 
     92        """  
    9193        ##set dispersion from model  
    9294        for param in self.model.orientation_params:      
     
    102104                    self.orientation_params.append(param) 
    103105                    self.magnetic_params.append(param) 
    104                     continue 
     106                    continue                            
    105107 
    106108    def _set_params(self): 
    107109        """ 
    108110        Concatenate the parameters of the model to create 
    109         this model parameters 
     111        this model parameters  
    110112        """ 
    111113        # rearrange the parameters for the given # of shells 
     
    126128            else: 
    127129                self.params[name]= value 
    128  
     130             
    129131        # set constrained values for the original model params 
    130         self._set_xtra_model_param() 
    131  
     132        self._set_xtra_model_param()        
     133   
    132134    def _set_details(self): 
    133135        """ 
    134136        Concatenate details of the original model to create 
    135         this model details 
     137        this model details  
    136138        """ 
    137139        for name ,detail in self.model.details.iteritems(): 
    138140            if name in self.params.iterkeys(): 
    139141                self.details[name]= detail 
    140  
    141  
     142             
     143     
    142144    def _set_xtra_model_param(self): 
    143145        """ 
     
    161163                                self.model.setParam(key, 0.0) 
    162164                        except: pass 
    163  
     165                      
    164166 
    165167    def getProfile(self): 
    166168        """ 
    167         Get SLD profile 
    168         **Note:** This works only for func_shell num = 2. 
    169  
    170         :return: (r, beta) where r is a list of radius of the transition points\ 
    171          and beta is a list of the corresponding SLD values. 
     169        Get SLD profile  
     170         
     171        : return: (r, beta) where r is a list of radius of the transition points 
     172            beta is a list of the corresponding SLD values 
     173        : Note: This works only for func_shell num = 2. 
    172174        """ 
    173175        r = [] 
     
    179181        r.append(self.params['rad_core0']) 
    180182        beta.append(self.params['sld_core0']) 
    181  
     183         
    182184        # for shells 
    183185        for n in range(1, self.n_shells+1): 
    184186            # Left side of each shells 
    185             r0 = r[len(r)-1] 
     187            r0 = r[len(r)-1]             
    186188            r.append(r0) 
    187189            exec "beta.append(self.params['sld_shell%s'% str(n)])" 
     
    191193            r.append(r0) 
    192194            exec "beta.append(self.params['sld_shell%s'% str(n)])" 
    193  
     195             
    194196        # for solvent 
    195197        r0 = r[len(r)-1]             
     
    199201        r.append(r_solv) 
    200202        beta.append(self.params['sld_solv']) 
    201  
     203         
    202204        return r, beta 
    203205 
    204206    def setParam(self, name, value): 
    205         """ 
     207        """  
    206208        Set the value of a model parameter 
    207  
    208         :param name: name of the parameter 
    209         :param value: value of the parameter 
     209     
     210        : param name: name of the parameter 
     211        : param value: value of the parameter 
    210212        """ 
    211213        # set param to new model 
    212214        self._setParamHelper( name, value) 
    213         ## setParam to model 
     215        ## setParam to model  
    214216        if name == 'sld_solv': 
    215217            # the sld_*** model.params not in params must set to value of sld_solv 
     
    241243                self.params[item] = value 
    242244                return 
     245         
    243246        #raise ValueError, "Model does not contain parameter %s" % name 
    244  
    245  
     247              
     248    
    246249    def _set_fixed_params(self): 
    247250        """ 
     
    249252        """ 
    250253        for item in self.model.fixed: 
    251             if item.split('.')[0] in self.params.keys(): 
     254            if item.split('.')[0] in self.params.keys():  
    252255                self.fixed.append(item) 
    253256 
    254257        self.fixed.sort() 
    255  
     258                 
    256259    def run(self, x = 0.0): 
    257         """ 
     260        """  
    258261        Evaluate the model 
    259  
    260         :param x: input q-value (float or [float, float] as [r, theta]) 
    261         :return: (DAB value) 
     262         
     263        : param x: input q-value (float or [float, float] as [r, theta]) 
     264        : return: (DAB value) 
    262265        """ 
    263266        # set effective radius and scaling factor before run 
     
    266269 
    267270    def runXY(self, x = 0.0): 
    268         """ 
     271        """  
    269272        Evaluate the model 
    270  
    271         :param x: input q-value (float or [float, float] as [qx, qy]) 
    272         :return: DAB value 
     273         
     274        : param x: input q-value (float or [float, float] as [qx, qy]) 
     275        : return: DAB value 
    273276        """   
    274277        # set effective radius and scaling factor before run 
    275278 
    276279        return self.model.runXY(x) 
    277  
     280     
    278281    ## Now (May27,10) directly uses the model eval function  
    279282    ## instead of the for-loop in Base Component. 
    280283    def evalDistribution(self, x = []): 
    281         """ 
     284        """  
    282285        Evaluate the model in cartesian coordinates 
    283  
    284         :param x: input q[], or [qx[], qy[]] 
    285         :return: scattering function P(q[]) 
     286         
     287        : param x: input q[], or [qx[], qy[]] 
     288        : return: scattering function P(q[]) 
    286289        """ 
    287290        # set effective radius and scaling factor before run 
    288291        return self.model.evalDistribution(x) 
    289  
     292     
    290293    def calculate_ER(self): 
    291         """ 
     294        """  
    292295        Calculate the effective radius for P(q)*S(q) 
    293  
     296         
    294297        :return: the value of the effective radius 
    295         """ 
     298         
     299        """        
    296300        return self.model.calculate_ER()  
    297  
     301     
    298302    def calculate_VR(self): 
    299         """ 
     303        """  
    300304        Calculate the volf ratio for P(q)*S(q) 
    301  
     305         
    302306        :return: the value of the volf ratio 
    303         """ 
     307         
     308        """        
    304309        return self.model.calculate_VR() 
    305  
     310     
    306311    def set_dispersion(self, parameter, dispersion): 
    307312        """ 
    308313        Set the dispersion object for a model parameter 
    309  
    310         :param parameter: name of the parameter [string] 
    311         :param dispersion: dispersion object of type DispersionModel 
     314         
     315        : param parameter: name of the parameter [string] 
     316        :dispersion: dispersion object of type DispersionModel 
    312317        """ 
    313318        value = None 
     
    318323            return value 
    319324        except: 
    320             raise 
     325            raise  
  • src/sas/models/MultiplicationModel.py

    rfb3f9af rac7be54  
    1010        which will be calculated from P(Q) via calculate_ER(),  
    1111        and 2) 'scale' in P model which is synchronized w/ volfraction in S  
    12         then P*S is multiplied by a new parameter, 'scale_factor'. 
     12        then P*S is multiplied by a new param, 'scale_factor'. 
    1313        The polydispersion is applicable only to P(Q), not to S(Q). 
    14  
    15         .. note:: P(Q) refers to 'form factor' model while S(Q) does to 'structure factor'. 
     14        Note: P(Q) refers to 'form factor' model while S(Q) does to 'structure factor'. 
    1615    """ 
    1716    def __init__(self, p_model, s_model ): 
     
    8281    def _clone(self, obj): 
    8382        """ 
    84         Internal utility function to copy the internal data members to a 
    85         fresh copy. 
     83            Internal utility function to copy the internal 
     84            data members to a fresh copy. 
    8685        """ 
    8786        obj.params     = copy.deepcopy(self.params) 
     
    9796    def _set_dispersion(self): 
    9897        """ 
    99         combine the two models' dispersions. Polydispersity should not be 
    100         applied to s_model 
     98           combined the two models dispersions 
     99           Polydispersion should not be applied to s_model 
    101100        """ 
    102101        ##set dispersion only from p_model  
     
    108107        Get SLD profile of p_model if exists 
    109108         
    110         :return: (r, beta) where r is a list of radius of the transition points\ 
    111                 beta is a list of the corresponding SLD values 
    112  
    113         .. note:: This works only for func_shell num = 2 (exp function). 
     109        : return: (r, beta) where r is a list of radius of the transition points 
     110                beta is a list of the corresponding SLD values  
     111        : Note: This works only for func_shell num = 2 (exp function). 
    114112        """ 
    115113        try: 
     
    123121    def _set_params(self): 
    124122        """ 
    125         Concatenate the parameters of the two models to create 
    126         these model parameters  
     123            Concatenate the parameters of the two models to create 
     124            this model parameters  
    127125        """ 
    128126 
     
    143141    def _set_details(self): 
    144142        """ 
    145         Concatenate details of the two models to create 
    146         this model's details  
     143            Concatenate details of the two models to create 
     144            this model details  
    147145        """ 
    148146        for name, detail in self.p_model.details.iteritems(): 
     
    156154    def _set_scale_factor(self): 
    157155        """ 
    158         Set scale=volfraction for P model 
     156            Set scale=volfraction to P model 
    159157        """ 
    160158        value = self.params['volfraction'] 
     
    170168    def _set_effect_radius(self): 
    171169        """ 
    172         Set effective radius to S(Q) model 
     170            Set effective radius to S(Q) model 
    173171        """ 
    174172        if not 'effect_radius' in self.s_model.params.keys(): 
     
    208206    def _setParamHelper(self, name, value): 
    209207        """ 
    210         Helper function to setparam 
     208            Helper function to setparam 
    211209        """ 
    212210        # Look for dispersion parameters 
     
    231229    def _set_fixed_params(self): 
    232230        """ 
    233         Fill the self.fixed list with the p_model fixed list 
     231             fill the self.fixed list with the p_model fixed list 
    234232        """ 
    235233        for item in self.p_model.fixed: 
     
    242240        """  
    243241        Evaluate the model 
    244          
    245242        :param x: input q-value (float or [float, float] as [r, theta]) 
    246243        :return: (scattering function value) 
     
    253250 
    254251    def runXY(self, x = 0.0): 
    255         """  
    256         Evaluate the model 
    257          
    258         :param x: input q-value (float or [float, float] as [qx, qy]) 
    259         :return: scattering function value 
     252        """ Evaluate the model 
     253            @param x: input q-value (float or [float, float] as [qx, qy]) 
     254            @return: scattering function value 
    260255        """   
    261256        # set effective radius and scaling factor before run 
     
    271266        """  
    272267        Evaluate the model in cartesian coordinates 
    273          
    274268        :param x: input q[], or [qx[], qy[]] 
    275269        :return: scattering function P(q[]) 
     
    285279        """ 
    286280        Set the dispersion object for a model parameter 
    287          
    288281        :param parameter: name of the parameter [string] 
    289282        :dispersion: dispersion object of type DispersionModel 
     
    300293    def fill_description(self, p_model, s_model): 
    301294        """ 
    302         Fill the description for P(Q)*S(Q) 
     295            Fill the description for P(Q)*S(Q) 
    303296        """ 
    304297        description = "" 
  • src/sas/models/c_extension/c_models/GelFit.cpp

    r1d115ef r79492222  
    3434    radius = Parameter(104.0,true); 
    3535    radius.set_min(2.0); 
    36     FractalExp = Parameter(2.0,true); 
     36    scale = Parameter(2.0,true); 
    3737    background = Parameter(0.01); 
    3838} 
     
    4343    dp[0] = zeta(); 
    4444    dp[1] = radius(); 
    45     dp[2] = FractalExp(); 
     45    dp[2] = scale(); 
    4646     
    4747    if (dp[2] <= 0) 
  • src/sas/models/c_extension/python_wrapper/WrapperGenerator.py

    r1f5f206 r13e46abe  
    560560    def replaceToken(self, line, key, value): #pylint: disable-msg=R0201 
    561561        """ Replace a token in the template file  
    562             :param line: line of text to inspect 
    563             :param key: token to look for 
    564             :param value: string value to replace the token with 
    565             :return: new string value 
     562            @param line: line of text to inspect 
     563            @param key: token to look for 
     564            @param value: string value to replace the token with 
     565            @return: new string value 
    566566        """ 
    567         _str_value = str(value) 
    568         _new_value = _str_value.replace('\\','/') 
    569567        lenkey = len(key) 
    570568        newline = line 
     
    572570        while newline.count(key) > 0: 
    573571            index = newline.index(key) 
    574             newline = newline[:index] + _new_value + newline[index + lenkey:] 
     572            newline = newline[:index] + value + newline[index + lenkey:] 
    575573 
    576574        return newline 
  • src/sas/models/c_extension/python_wrapper/modelTemplate.txt

    r1f5f206 rc93122e  
    1717 
    1818.. WARNING:: 
     19 
    1920   THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 
    2021   DO NOT MODIFY THIS FILE, MODIFY 
     
    2930def create_[PYTHONCLASS](): 
    3031    """ 
    31     Create a model instance 
     32       Create a model instance 
    3233    """ 
    3334    obj = [PYTHONCLASS]() 
     
    99100        """ 
    100101        Evaluate the model 
    101  
    102102        :param x: input q, or [q,phi] 
    103103        :return: scattering function P(q) 
     
    108108        """ 
    109109        Evaluate the model in cartesian coordinates 
    110  
    111110        :param x: input q, or [qx, qy] 
    112111        :return: scattering function P(q) 
     
    117116        """ 
    118117        Evaluate the model in cartesian coordinates 
    119  
    120118        :param x: input q[], or [qx[], qy[]] 
    121119        :return: scattering function P(q[]) 
     
    126124        """ 
    127125        Calculate the effective radius for P(q)*S(q) 
    128  
    129126        :return: the value of the effective radius 
    130127        """ 
     
    134131        """ 
    135132        Calculate the volf ratio for P(q)*S(q) 
    136  
    137133        :return: the value of the volf ratio 
    138134        """ 
     
    142138        """ 
    143139        Set the dispersion object for a model parameter 
    144  
    145140        :param parameter: name of the parameter [string] 
    146141        :param dispersion: dispersion object of type DispersionModel 
  • src/sas/models/include/GelFit.h

    r1d115ef r79492222  
    3333  Parameter radius; 
    3434 
    35   //  [DEFAULT]=FractalExp= 2 
    36   Parameter FractalExp; 
     35  //  [DEFAULT]=scale= 2 
     36  Parameter scale; 
    3737 
    3838  //  [DEFAULT]=background= 0.01 
  • src/sas/models/include/dabmodel.h

    rf008ee2 r79492222  
    1717// [PYTHONCLASS] = DABModel 
    1818// [DISP_PARAMS] = length, scale, background 
    19 // [DESCRIPTION] = <text>DAB (Debye Anderson Brumberger) Model 
    20 //    F(x) = scale * L^3/( 1 + (q*L)^2 )^2 + background 
    21 //    L: the correlation length 
     19// [DESCRIPTION] = <text>Provide F(x) = scale/( 1 + (x*L)^2 )^(2) + background 
     20//    DAB (Debye Anderson Brumberger) function as a BaseComponent model 
    2221//     </text> 
    2322// [FIXED] =  
  • src/sas/models/sas_extension/__init__.py

    rfb3f9af r79492222  
    1 """ 
    2 This is an empty package - should probably delete 
    3 """ 
  • src/sas/perspectives/fitting/fitpage.py

    r098f3d2 rd06c34c  
    22182218        """ 
    22192219        # compute weight for the current data 
     2220        from sas.perspectives.fitting.utils import get_weight 
    22202221        flag_weight = self.get_weight_flag() 
    22212222        if is_2D == None: 
    22222223            is_2D = self._is_2D() 
     2224        weight = get_weight(data=self.data, 
     2225                            is2d=is_2D, 
     2226                            flag=flag_weight) 
    22232227        self._manager.set_fit_weight(uid=self.uid, 
    22242228                                     flag=flag_weight, 
     
    22382242        self._update_paramv_on_fit() 
    22392243 
     2244        # msg default 
     2245        msg = None 
    22402246        if event != None: 
    22412247            tcrtl = event.GetEventObject() 
     
    22512257        # if any value is changed 
    22522258        if is_new_pinhole: 
    2253             self._set_pinhole_smear() 
     2259            msg = self._set_pinhole_smear() 
    22542260        # hide all silt sizer 
    22552261        self._hide_all_smear_info() 
  • src/sas/perspectives/fitting/fitting.py

    r098f3d2 rf21d496  
    539539                        self.add_fit_page(data=[data]) 
    540540            except: 
    541                 msg = "Fitting set_data: " + str(sys.exc_value) 
     541                msg = "Fitting Set_data: " + str(sys.exc_value) 
    542542                wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 
    543543 
     
    670670        :param weight: current dy data 
    671671        """ 
    672         # If we are not dealing with a specific fit problem, then 
    673         # there is no point setting the weights. 
    674         if fid is None: 
    675             return 
    676672        if uid in self.page_finder.keys(): 
    677673            self.page_finder[uid].set_weight(flag=flag, is2d=is2d) 
  • src/sas/perspectives/fitting/resultpanel.py

    r9df6a03 r2f4b430  
    99import wx.lib.newevent 
    1010from wx.aui import AuiNotebook as Notebook 
    11  
    12 from bumps.gui.convergence_view import ConvergenceView 
    13 from bumps.gui.uncertainty_view import UncertaintyView, CorrelationView, TraceView 
    14 from bumps.dream.stats import var_stats, format_vars 
    1511 
    1612from sas.guiframe.panel_base import PanelBase 
     
    5955        result = event.result[0][0] 
    6056        if hasattr(result, 'convergence'): 
     57            from bumps.gui.convergence_view import ConvergenceView 
    6158            best, pop = result.convergence[:, 0], result.convergence[:, 1:] 
    62             self._get_view(ConvergenceView).update(best, pop) 
    63         else: 
    64             self._del_view(ConvergenceView) 
     59            self.get_panel(ConvergenceView).update(best, pop) 
    6560        if hasattr(result, 'uncertainty_state'): 
     61            from bumps.gui.uncertainty_view import UncertaintyView, CorrelationView, TraceView 
     62            from bumps.dream.stats import var_stats, format_vars 
    6663            stats = var_stats(result.uncertainty_state.draw()) 
    6764            msg = format_vars(stats) 
    68             self._get_view(CorrelationView).update(result.uncertainty_state) 
    69             self._get_view(UncertaintyView).update((result.uncertainty_state, stats)) 
    70             self._get_view(TraceView).update(result.uncertainty_state) 
     65            self.get_panel(CorrelationView).update(result.uncertainty_state) 
     66            self.get_panel(UncertaintyView).update((result.uncertainty_state, stats)) 
     67            self.get_panel(TraceView).update(result.uncertainty_state) 
    7168            # TODO: stats should be stored in result rather than computed in bumps UncertaintyView 
    7269            wx.PostEvent(self.frame.parent, 
    7370                         StatusEvent(status=msg, info="info")) 
    74         else: 
    75             for view in (CorrelationView, UncertaintyView, TraceView): 
    76                 self._del_view(view) 
     71            print 
    7772 
    7873    def get_frame(self): 
    7974        return self.frame 
    8075 
    81     def _get_view(self, view_class): 
     76    def add_panel(self, panel): 
     77        self.AddPage(panel, panel.title) 
     78 
     79    def get_panel(self, panel_class): 
    8280        for idx in range(self.PageCount): 
    83             if self.GetPageText(idx) == view_class.title: 
     81            if self.GetPageText(idx) == panel_class.title: 
    8482                return self.GetPage(idx) 
    8583        else: 
    86             panel = view_class(self) 
    87             self.AddPage(panel, panel.title) 
     84            panel = panel_class(self) 
     85            self.add_panel(panel) 
    8886            return panel 
    89  
    90     def _del_view(self, view_class): 
    91         for idx in range(self.PageCount): 
    92             if self.GetPageText(idx) == view_class.title: 
    93                 self.DeletePage(idx) 
    94  
  • src/sas/plottools/PlotPanel.py

    rd3d67f0 r7e0f9b5  
    33""" 
    44import logging 
    5 import traceback 
    65import wx 
    76# Try a normal import first 
     
    2221 
    2322from plottables import Graph 
     23from plottables import Text 
    2424from TextDialog import TextDialog 
    2525from LabelDialog import LabelDialog 
     
    3232import numpy 
    3333 
    34 from ..guiframe.events import StatusEvent 
    35 from .toolbar import NavigationToolBar, PlotPrintout, bind 
     34from sas.guiframe.events import StatusEvent 
    3635 
    3736def show_tree(obj, d=0): 
     
    8988            lo, hi = math.pow(10., lo), math.pow(10., hi) 
    9089    return (lo, hi) 
     90 
     91 
     92def CopyImage(canvas): 
     93    """ 
     94    0: matplotlib plot 
     95    1: wx.lib.plot 
     96    2: other 
     97    """ 
     98    bmp = wx.BitmapDataObject() 
     99    bmp.SetBitmap(canvas.bitmap) 
     100 
     101    wx.TheClipboard.Open() 
     102    wx.TheClipboard.SetData(bmp) 
     103    wx.TheClipboard.Close() 
    91104 
    92105 
     
    320333        """ 
    321334        self.enable_toolbar = True 
     335        from toolbar import NavigationToolBar 
    322336        self.toolbar = NavigationToolBar(parent=self, canvas=self.canvas) 
    323         bind(self.toolbar, wx.EVT_TOOL, self.onResetGraph, id=self.toolbar._NTB2_RESET) 
    324         bind(self.toolbar, wx.EVT_TOOL, self.onContextMenu, id=self.toolbar._NTB2_HOME) 
    325337        self.toolbar.Realize() 
    326338        ## The 'SetToolBar()' is not working on MAC: JHC 
     
    622634        when clicking on linear Fit on context menu , display Fitting Dialog 
    623635        """ 
    624         plot_dict = {} 
     636        list = {} 
    625637        menu = event.GetEventObject() 
    626         event_id = event.GetId() 
    627         self.set_selected_from_menu(menu, event_id) 
     638        id = event.GetId() 
     639        self.set_selected_from_menu(menu, id) 
    628640        plotlist = self.graph.returnPlottable() 
    629641        if self.graph.selected_plottable is not None: 
    630642            for item in plotlist: 
    631643                if item.id == self.graph.selected_plottable: 
    632                     plot_dict[item] = plotlist[item] 
     644                    list[item] = plotlist[item] 
    633645        else: 
    634             plot_dict = plotlist 
     646            list = plotlist 
    635647        from fitDialog import LinearFit 
    636648 
    637         if len(plot_dict.keys()) > 0: 
    638             first_item = plot_dict.keys()[0] 
     649        if len(list.keys()) > 0: 
     650            first_item = list.keys()[0] 
    639651            dlg = LinearFit(parent=None, plottable=first_item, 
    640652                            push_data=self.onFitDisplay, 
     
    850862        Implement save image 
    851863        """ 
    852         self.toolbar.save_figure(evt) 
     864        self.toolbar.save(evt) 
    853865 
    854866    def onContextMenu(self, event): 
     
    858870        """ 
    859871        # Slicer plot popup menu 
    860         wx_id = wx.NewId() 
     872        id = wx.NewId() 
    861873        slicerpop = wx.Menu() 
    862         slicerpop.Append(wx_id, '&Save image', 'Save image as PNG') 
    863         wx.EVT_MENU(self, wx_id, self.onSaveImage) 
    864  
    865         wx_id = wx.NewId() 
    866         slicerpop.Append(wx_id, '&Printer setup', 'Set image size') 
    867         wx.EVT_MENU(self, wx_id, self.onPrinterSetup) 
    868  
    869         wx_id = wx.NewId() 
    870         slicerpop.Append(wx_id, '&Print image', 'Print image ') 
    871         wx.EVT_MENU(self, wx_id, self.onPrint) 
    872  
    873         wx_id = wx.NewId() 
    874         slicerpop.Append(wx_id, '&Copy', 'Copy to the clipboard') 
    875         wx.EVT_MENU(self, wx_id, self.OnCopyFigureMenu) 
    876  
    877         wx_id = wx.NewId() 
     874        slicerpop.Append(id, '&Save image', 'Save image as PNG') 
     875        wx.EVT_MENU(self, id, self.onSaveImage) 
     876 
     877        id = wx.NewId() 
     878        slicerpop.Append(id, '&Printer setup', 'Set image size') 
     879        wx.EVT_MENU(self, id, self.onPrinterSetup) 
     880 
     881        id = wx.NewId() 
     882        slicerpop.Append(id, '&Printer Preview', 'Set image size') 
     883        wx.EVT_MENU(self, id, self.onPrinterPreview) 
     884 
     885        id = wx.NewId() 
     886        slicerpop.Append(id, '&Print image', 'Print image ') 
     887        wx.EVT_MENU(self, id, self.onPrint) 
     888 
     889        id = wx.NewId() 
     890        slicerpop.Append(id, '&Copy', 'Copy to the clipboard') 
     891        wx.EVT_MENU(self, id, self.OnCopyFigureMenu) 
     892 
     893        #id = wx.NewId() 
     894        #slicerpop.Append(id, '&Load 1D data file') 
     895        #wx.EVT_MENU(self, id, self._onLoad1DData) 
     896 
     897        id = wx.NewId() 
    878898        slicerpop.AppendSeparator() 
    879         slicerpop.Append(wx_id, '&Properties') 
    880         wx.EVT_MENU(self, wx_id, self._onProperties) 
    881  
    882         wx_id = wx.NewId() 
     899        slicerpop.Append(id, '&Properties') 
     900        wx.EVT_MENU(self, id, self._onProperties) 
     901 
     902        id = wx.NewId() 
    883903        slicerpop.AppendSeparator() 
    884         slicerpop.Append(wx_id, '&Linear Fit') 
    885         wx.EVT_MENU(self, wx_id, self.onFitting) 
    886  
    887         wx_id = wx.NewId() 
     904        slicerpop.Append(id, '&Linear Fit') 
     905        wx.EVT_MENU(self, id, self.onFitting) 
     906 
     907        id = wx.NewId() 
    888908        slicerpop.AppendSeparator() 
    889         slicerpop.Append(wx_id, '&Toggle Legend On/Off', 'Toggle Legend On/Off') 
    890         wx.EVT_MENU(self, wx_id, self.onLegend) 
     909        slicerpop.Append(id, '&Toggle Legend On/Off', 'Toggle Legend On/Off') 
     910        wx.EVT_MENU(self, id, self.onLegend) 
    891911 
    892912        loc_menu = wx.Menu() 
    893913        for label in self._loc_labels: 
    894             wx_id = wx.NewId() 
    895             loc_menu.Append(wx_id, str(label), str(label)) 
    896             wx.EVT_MENU(self, wx_id, self.onChangeLegendLoc) 
    897         wx_id = wx.NewId() 
    898         slicerpop.AppendMenu(wx_id, '&Modify Legend Location', loc_menu) 
    899  
    900         wx_id = wx.NewId() 
    901         slicerpop.Append(wx_id, '&Modify Y Axis Label') 
    902         wx.EVT_MENU(self, wx_id, self._on_yaxis_label) 
    903         wx_id = wx.NewId() 
    904         slicerpop.Append(wx_id, '&Modify X Axis Label') 
    905         wx.EVT_MENU(self, wx_id, self._on_xaxis_label) 
     914            id = wx.NewId() 
     915            loc_menu.Append(id, str(label), str(label)) 
     916            wx.EVT_MENU(self, id, self.onChangeLegendLoc) 
     917        id = wx.NewId() 
     918        slicerpop.AppendMenu(id, '&Modify Legend Location', loc_menu) 
     919 
     920        id = wx.NewId() 
     921        slicerpop.Append(id, '&Modify Y Axis Label') 
     922        wx.EVT_MENU(self, id, self._on_yaxis_label) 
     923        id = wx.NewId() 
     924        slicerpop.Append(id, '&Modify X Axis Label') 
     925        wx.EVT_MENU(self, id, self._on_xaxis_label) 
    906926 
    907927        try: 
     
    19021922        self.xmax = xmax 
    19031923        #In case need to change the range of data plotted 
    1904         for item in self.graph.returnPlottable(): 
     1924        list = [] 
     1925        list = self.graph.returnPlottable() 
     1926        for item in list: 
     1927            #item.onFitRange(xminView,xmaxView) 
    19051928            item.onFitRange(None, None) 
    19061929        # Create new data plottable with result 
     
    19461969        Reset the graph by plotting the full range of data 
    19471970        """ 
    1948         for item in self.graph.returnPlottable(): 
     1971        list = [] 
     1972        list = self.graph.returnPlottable() 
     1973        for item in list: 
    19491974            item.onReset() 
    19501975        self.graph.render(self) 
     
    19531978        self.toolbar.update() 
    19541979 
    1955     def onPrint(self, event=None): 
    1956         self.toolbar.print_figure(event) 
    1957  
    19581980    def onPrinterSetup(self, event=None): 
    19591981        """ 
     
    19641986    def onPrinterPreview(self, event=None): 
    19651987        """ 
    1966         Matplotlib camvas can no longer print itself.  Thus need to do 
    1967         everything ourselves: need to create a printpreview frame to to 
    1968         see the preview but needs a parent frame object.  Also needs a 
    1969         printout object (just as any printing task). 
    19701988        """ 
    19711989        try: 
    1972             #check if parent is a frame.  If not keep getting the higher 
    1973             #parent till we find a frame 
    1974             _plot = self 
    1975             while not isinstance(_plot, wx.Frame): 
    1976                 _plot = _plot.GetParent() 
    1977                 assert _plot is not None 
    1978  
    1979             #now create the printpeview object 
    1980             _preview = wx.PrintPreview(PlotPrintout(self.canvas), 
    1981                                        PlotPrintout(self.canvas)) 
    1982             #and tie it to a printpreview frame then show it 
    1983             _frame = wx.PreviewFrame(_preview, _plot, "Print Preview", wx.Point(100, 100), wx.Size(600, 650)) 
    1984             _frame.Centre(wx.BOTH) 
    1985             _frame.Initialize() 
    1986             _frame.Show(True) 
     1990            self.canvas.Printer_Preview(event=event) 
     1991            self.Update() 
    19871992        except: 
    1988             traceback.print_exc() 
    19891993            pass 
    19901994 
     1995    def onPrint(self, event=None): 
     1996        """ 
     1997        """ 
     1998        try: 
     1999            self.canvas.Printer_Print(event=event) 
     2000            self.Update() 
     2001        except: 
     2002            pass 
     2003 
    19912004    def OnCopyFigureMenu(self, evt): 
    19922005        """ 
     
    19942007        """ 
    19952008        try: 
    1996             self.toolbar.copy_figure() 
     2009            CopyImage(self.canvas) 
    19972010        except: 
    19982011            print "Error in copy Image" 
  • src/sas/plottools/TextDialog.py

    r649806d r3477478  
    88    FONT_VARIANT = 1 
    99    PNL_WIDTH = 500 
    10 FAMILY = ['serif', 'sans-serif', 'fantasy', 'monospace'] 
     10FAMILY = ['serif', 'sas-serif', 'fantasy', 'monospace'] 
    1111SIZE = [8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72] 
    1212STYLE = ['normal', 'italic'] 
     
    2020        Dialog window pops- up when selecting 'Add Text' on the toolbar 
    2121        """ 
    22         wx.Dialog.__init__(self, parent, id, title, size=(PNL_WIDTH, 300)) 
     22        wx.Dialog.__init__(self, parent, id, title, size=(PNL_WIDTH, 280)) 
    2323        self.parent = parent 
    2424        # Font 
     
    3535        text_box = wx.BoxSizer(wx.HORIZONTAL) 
    3636        sizer = wx.GridBagSizer(1, 3) 
    37         _BOX_WIDTH = 70 
    38         font_description = wx.StaticBox(self, -1, 'Font') 
     37        _BOX_WIDTH = 60 
     38        font_description = wx.StaticBox(self, -1, 'Font', size=(PNL_WIDTH - 20, 70)) 
    3939        font_box = wx.StaticBoxSizer(font_description, wx.VERTICAL) 
    4040        family_box = wx.BoxSizer(wx.HORIZONTAL) 
     
    103103        self.font_style.SetToolTipString("Font style of the text.") 
    104104        # font color 
    105         self.font_color = wx.ComboBox(self, -1, style = wx.CB_READONLY) 
     105        self.font_color = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
    106106        wx.EVT_COMBOBOX(self.font_color, -1, self.on_color) 
    107107        self.font_color.SetMinSize((_BOX_WIDTH, -1)) 
     
    111111        # Buttons on the bottom 
    112112        self.static_line_1 = wx.StaticLine(self, -1) 
    113         self.ok_button = wx.Button(self, wx.ID_OK, 'OK', 
    114                                    size = (_BOX_WIDTH, 25)) 
    115         self.close_button = wx.Button(self, wx.ID_CANCEL, 'Cancel', 
    116                                       size = (_BOX_WIDTH, 25)) 
     113        self.ok_button = wx.Button(self, wx.ID_OK, 'OK', size=(_BOX_WIDTH, 25)) 
     114        self.close_button = wx.Button(self, wx.ID_CANCEL, 'Cancel', size=(_BOX_WIDTH, 25)) 
    117115 
    118116        # Intro 
     
    123121        sizer.Add(wx.StaticText(self, -1, explanation), (iy, ix), 
    124122                  (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    125         family_box.Add(wx.StaticText(self, -1, 'Family :', size = (50, -1)), 
    126                        0, wx.TOP, 5) 
    127         family_box.Add(self.font_family, 0, 0) 
     123        family_box.Add(wx.StaticText(self, -1, 'Family :'), -1, 0) 
     124        family_box.Add(self.font_family, -1, 0) 
    128125        family_box.Add((_BOX_WIDTH / 2, -1)) 
    129         family_box.Add(wx.StaticText(self, -1, 'Size :', size = (50, -1)), 
    130                        0, wx.TOP, 5) 
    131         family_box.Add(self.font_size, 0, 0) 
     126        family_box.Add(wx.StaticText(self, -1, 'Size :'), -1, 0) 
     127        family_box.Add(self.font_size, -1, 0) 
    132128        if unit_box != None: 
    133129            family_box.Add((_BOX_WIDTH / 2, -1)) 
    134             family_box.Add(tick_label_text, 0, 0) 
    135             family_box.Add(self.tick_label_check, 0, 0) 
    136         style_box.Add(wx.StaticText(self, -1, 'Style :', size = (50, -1)), 
    137                       0, wx.TOP, 5) 
    138         style_box.Add(self.font_style, 0, 0) 
     130            family_box.Add(tick_label_text, -1, 0) 
     131            family_box.Add(self.tick_label_check, -1, 0) 
     132        style_box.Add(wx.StaticText(self, -1, 'Style :'), -1, 0) 
     133        style_box.Add(self.font_style, -1, 0) 
    139134        style_box.Add((_BOX_WIDTH / 2, -1)) 
    140         style_box.Add(wx.StaticText(self, -1, 'Weight :', size = (50, -1)), 
    141                       0, wx.TOP, 5) 
    142         style_box.Add(self.font_weight, 0, 0) 
     135        style_box.Add(wx.StaticText(self, -1, 'Weight :'), -1, 0) 
     136        style_box.Add(self.font_weight, -1, 0) 
    143137        style_box.Add((_BOX_WIDTH / 2, -1)) 
    144         style_box.Add(wx.StaticText(self, -1, 'Color :', size = (45, -1)), 
    145                       0, wx.TOP, 5) 
    146         style_box.Add(self.font_color, 0, 0) 
    147         font_box.Add(family_box, 0, 10) 
    148         font_box.Add((0,5)) 
    149         font_box.Add(style_box, 0, 10) 
     138        style_box.Add(wx.StaticText(self, -1, 'Color :'), -1, 0) 
     139        style_box.Add(self.font_color, -1, 0) 
     140        font_box.Add(family_box, -1, 10) 
     141        font_box.Add(style_box, -1, 10) 
    150142        iy += 1 
    151143        ix = 0 
     
    160152        vbox.Add(text_box, 0, wx.EXPAND, 15) 
    161153        if unit_box != None: 
    162             unit_box.Add(unit_text, 0, 0) 
    163             unit_box.Add(self.unit_ctrl, 0, 0) 
     154            unit_box.Add(unit_text, -1, 0) 
     155            unit_box.Add(self.unit_ctrl, -1, 0) 
    164156            vbox.Add((5, 5)) 
    165157            vbox.Add(unit_box, 0, wx.LEFT, 15) 
  • src/sas/plottools/config.py

    rd3d67f0 r79492222  
    5858matplotlib.rcParams[param] = 0.05 
    5959matplotlib.rcParams['legend.numpoints'] = 1 
    60  
    61 # this should happen after initial matplotlib configuration 
    62 from .toolbar import NavigationToolBar 
    63 from matplotlib.backends import backend_wxagg 
    64 backend_wxagg.NavigationToolbar2WxAgg = NavigationToolBar 
    65  
    66 # CRUFT: bumps 0.7.5.6 and older uses wrong toolbar 
    67 backend_wxagg.NavigationToolbar2Wx = NavigationToolBar 
  • src/sas/plottools/toolbar.py

    rd3d67f0 r3477478  
    3131    def _init_toolbar(self): 
    3232        self._parent = self.canvas.GetParent() 
    33         self._NTB2_HOME = wx.NewId() 
     33        _NTB2_HOME = wx.NewId() 
    3434        self._NTB2_BACK = wx.NewId() 
    3535        self._NTB2_FORWARD = wx.NewId() 
    3636        self._NTB2_PAN = wx.NewId() 
    3737        self._NTB2_ZOOM = wx.NewId() 
    38         self._NTB2_SAVE = wx.NewId() 
    39         self._NTB2_PRINT = wx.NewId() 
    40         self._NTB2_RESET = wx.NewId() 
     38        _NTB2_SAVE = wx.NewId() 
     39        _NTB2_PRINT = wx.NewId() 
     40        _NTB2_RESET = wx.NewId() 
    4141 
    4242        # for mpl 1.2+ compatibility 
     
    5353        context_tip += '    right-click the data symbols.' 
    5454        context = wx.ArtProvider.GetBitmap(wx.ART_LIST_VIEW, wx.ART_TOOLBAR) 
    55         self.AddSimpleTool(self._NTB2_HOME, context, context_tip, context_tip) 
     55        self.AddSimpleTool(_NTB2_HOME, context, context_tip, context_tip) 
    5656 
    5757        self.InsertSeparator(1) 
     
    6969 
    7070        self.AddSeparator() 
    71         self.AddSimpleTool(self._NTB2_SAVE, _load_bitmap('filesave.png'), 
     71        self.AddSimpleTool(_NTB2_SAVE, _load_bitmap('filesave.png'), 
    7272                           'Save', 'Save plot contents to file') 
    7373 
    7474        print_bmp = wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_TOOLBAR) 
    75         self.AddSimpleTool(self._NTB2_PRINT, print_bmp, 'Print', 'Print plot') 
     75        self.AddSimpleTool(_NTB2_PRINT, print_bmp, 'Print', 'Print plot') 
    7676 
    7777        reset_bmp = wx.ArtProvider.GetBitmap(wx.ART_GO_HOME, wx.ART_TOOLBAR) 
    78         self.AddSimpleTool(self._NTB2_RESET, reset_bmp, 'Reset', 'Reset graph range') 
     78        self.AddSimpleTool(_NTB2_RESET, reset_bmp, 'Reset', 'Reset graph range') 
    7979 
    80         bind(self, wx.EVT_TOOL, self.context_menu, id=self._NTB2_HOME) 
     80        bind(self, wx.EVT_TOOL, self.on_menu, id=_NTB2_HOME) 
    8181        bind(self, wx.EVT_TOOL, self.forward, id=self._NTB2_FORWARD) 
    8282        bind(self, wx.EVT_TOOL, self.back, id=self._NTB2_BACK) 
    8383        bind(self, wx.EVT_TOOL, self.zoom, id=self._NTB2_ZOOM) 
    8484        bind(self, wx.EVT_TOOL, self.pan, id=self._NTB2_PAN) 
    85         bind(self, wx.EVT_TOOL, self.save_figure, id=self._NTB2_SAVE) 
    86         bind(self, wx.EVT_TOOL, self.print_figure, id=self._NTB2_PRINT) 
    87         bind(self, wx.EVT_TOOL, self.home, id=self._NTB2_RESET) 
     85        bind(self, wx.EVT_TOOL, self.save_figure, id=_NTB2_SAVE) 
     86        bind(self, wx.EVT_TOOL, self.on_print, id=_NTB2_PRINT) 
     87        bind(self, wx.EVT_TOOL, self.on_reset, id=_NTB2_RESET) 
    8888 
    8989        self.Realize() 
    9090 
    9191    def on_menu(self, event): 
     92        """ 
     93            Plot menu 
     94        """ 
    9295        try: 
    9396            self._parent.onToolContextMenu(event=event) 
     
    9598            logging.error("Plot toolbar could not show menu") 
    9699 
    97     def context_menu(self, event): 
     100    def on_reset(self, event): 
    98101        """ 
    99         Default context menu for a plot panel 
     102            Reset plot 
     103        """ 
     104        try: 
     105            self._parent.onResetGraph(event=event) 
     106        except: 
     107            logging.error("Plot toolbar could not reset plot") 
    100108 
     109    def on_print(self, event): 
    101110        """ 
    102         # Slicer plot popup menu 
    103         wx_id = wx.NewId() 
    104         popup = wx.Menu() 
    105         popup.Append(wx_id, '&Save image', 'Save image as PNG') 
    106         wx.EVT_MENU(self, wx_id, self.save_figure) 
    107  
    108         wx_id = wx.NewId() 
    109         popup.Append(wx_id, '&Print image', 'Print image ') 
    110         wx.EVT_MENU(self, wx_id, self.print_figure) 
    111  
    112         wx_id = wx.NewId() 
    113         popup.Append(wx_id, '&Copy to Clipboard', 'Copy image to the clipboard') 
    114         wx.EVT_MENU(self, wx_id, self.copy_figure) 
    115  
    116         # Show the popup menu relative to the location of the toolbar 
    117         self.PopupMenu(popup, (0,0)) 
    118  
    119  
    120     def print_figure(self, event): 
     111            Print 
     112        """ 
    121113        try: 
    122             _printer = wx.Printer() 
    123             _printer.Print(self.canvas, PlotPrintout(self.canvas), True) 
     114            self.canvas.Printer_Preview(event=event) 
    124115        except: 
    125             import traceback 
    126             logging.error(traceback.format_exc()) 
    127  
    128     def copy_figure(self, event): 
    129         copy_image_to_clipboard(self.canvas) 
    130  
    131 class PlotPrintout(wx.Printout): 
    132     """ 
    133     Create the wx.Printout object for matplotlib figure from the PlotPanel. 
    134     Provides the required OnPrintPage and HasPage overrides.  Other methods 
    135     may be added/overriden in the future. 
    136     :TODO: this needs LOTS of TLC .. but fixes immediate problem 
    137     """ 
    138     def __init__(self, canvas): 
    139         """ 
    140         Initialize wx.Printout and get passed figure object 
    141         """ 
    142         wx.Printout.__init__(self) 
    143         self.canvas = canvas 
    144  
    145     def OnPrintPage(self, page): 
    146         """ 
    147         Most rudimentry OnPrintPage overide.  instatiates a dc object, gets 
    148         its size, gets the size of the figure object, scales it to the dc 
    149         canvas size keeping the aspect ratio intact, then prints as bitmap 
    150         """ 
    151         _dc = self.GetDC() 
    152         (_dcX, _dcY) = _dc.GetSizeTuple() 
    153         (_bmpX,_bmpY) = self.canvas.GetSize() 
    154         _scale = min(_dcX/_bmpX, _dcY/_bmpY) 
    155         _dc.SetUserScale(_scale, _scale) 
    156         _dc.DrawBitmap(self.canvas.bitmap, 0, 0, False,) 
    157         return True 
    158  
    159     def GetPageInfo(self): 
    160         """ 
    161         just sets the page to 1 - no flexibility for now 
    162         """ 
    163         return (1, 1, 1, 1) 
    164  
    165  
    166 def copy_image_to_clipboard(canvas): 
    167     bmp = wx.BitmapDataObject() 
    168     bmp.SetBitmap(canvas.bitmap) 
    169  
    170     wx.TheClipboard.Open() 
    171     wx.TheClipboard.SetData(bmp) 
    172     wx.TheClipboard.Close() 
    173  
    174  
     116            logging.error("Plot toolbar could not print") 
Note: See TracChangeset for help on using the changeset viewer.