Changeset 34f23c8 in sasview


Ignore:
Timestamp:
Mar 20, 2019 8:06:22 AM (5 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
ticket-1249
Children:
9305b46
Parents:
09d7021
Message:

py3/wx4 compatibility changes for gui. Refs #1249

Location:
src/sas/sasgui
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/gui_manager.py

    r82d88d5 r34f23c8  
    282282        toolbar = self.GetToolBar() 
    283283        if toolbar is not None: 
    284             _, tb_h = toolbar.GetSizeTuple() 
     284            _, tb_h = toolbar.GetSize() 
    285285            height -= tb_h 
    286286        return width, height 
     
    948948                if panel_class.CENTER_PANE: 
    949949                    self.panels[str(wx_id)] = panel_class 
    950                     _, pos_y = frame.GetPositionTuple() 
     950                    _, pos_y = frame.GetPosition() 
    951951                    frame.SetPosition((d_panel_width + 1, pos_y)) 
    952952                    frame.SetSize((w, h)) 
     
    11161116        if not IS_WIN: 
    11171117            p.frame.Center() 
    1118             x_pos, _ = p.frame.GetPositionTuple() 
     1118            x_pos, _ = p.frame.GetPosition() 
    11191119            p.frame.SetPosition((x_pos, 112)) 
    11201120        p.frame.Show(True) 
     
    30113011        if self.GetToolBar() is not None and self.GetToolBar().IsShown(): 
    30123012            if not IS_LINUX: 
    3013                 _, size_y = self.GetToolBar().GetSizeTuple() 
     3013                _, size_y = self.GetToolBar().GetSize() 
    30143014        return size_y 
    30153015 
     
    31303130        :rtype: tuple 
    31313131        """ 
    3132         width, height = self.GetSizeTuple() 
     3132        width, height = self.GetSize() 
    31333133        if not IS_WIN: 
    31343134            # Subtract toolbar height to get real window side 
  • src/sas/sasgui/guiframe/gui_statusbar.py

    r5251ec6 r34f23c8  
    112112        Method to send an arbitrary number of messages to the console log 
    113113 
    114         :param messages: A list of strings to be sent to the console log.  
     114        :param messages: A list of strings to be sent to the console log. 
    115115        """ 
    116116        if messages: 
     
    234234        If the window is resized, redraw the window. 
    235235        """ 
    236         self.reposition()  
     236        self.reposition() 
    237237        self.size_changed = True 
    238238 
     
    360360        if hasattr(event, "status"): 
    361361            self.SetStatusText(text=str(event.status), event=event) 
    362    
     362 
    363363    def set_gauge(self, event): 
    364364        """ 
     
    423423        self.SetFieldsCount(1) 
    424424        self.timeout = timeout 
    425         width, height = parent.GetSizeTuple() 
     425        width, height = parent.GetSize() 
    426426        self.gauge = wx.Gauge(self, style=wx.GA_HORIZONTAL, 
    427427                              size=(width, height/10)) 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/AnnulusSlicer.py

    r5251ec6 r34f23c8  
    161161        new_plot.detector = self.base.data2D.detector 
    162162        # If the data file does not tell us what the axes are, just assume... 
    163         new_plot.xaxis("\\rm{\phi}", 'degrees') 
    164         new_plot.yaxis("\\rm{Intensity} ", "cm^{-1}") 
    165         if hasattr(data, "scale") and data.scale == 'linear' and \ 
    166                 self.base.data2D.name.count("Residuals") > 0: 
     163        new_plot.xaxis(r"\rm{\phi}", 'degrees') 
     164        new_plot.yaxis(r"\rm{Intensity} ", "cm^{-1}") 
     165        if (hasattr(data, "scale") and data.scale == 'linear' 
     166                and self.base.data2D.name.count("Residuals") > 0): 
    167167            new_plot.ytransform = 'y' 
    168             new_plot.yaxis("\\rm{Residuals} ", "/") 
     168            new_plot.yaxis(r"\rm{Residuals} ", "/") 
    169169 
    170170        new_plot.group_id = "AnnulusPhi" + self.base.data2D.name 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter1D.py

    r5251ec6 r34f23c8  
    205205        self.canvas.set_resizing(self.resizing) 
    206206        self.parent.set_schedule(True) 
    207         pos_x, pos_y = self.GetPositionTuple() 
     207        pos_x, pos_y = self.GetPosition() 
    208208        if pos_x != 0 and pos_y != 0: 
    209             self.size, _ = self.GetClientSizeTuple() 
     209            self.size, _ = self.GetClientSize() 
    210210        self.SetSizer(self.sizer) 
    211211        wx.CallAfter(self.parent.disable_app_menu, self) 
     
    714714            pos = self.ScreenToClient(pos_evt) 
    715715        except: 
    716             pos_x, pos_y = self.toolbar.GetPositionTuple() 
     716            pos_x, pos_y = self.toolbar.GetPosition() 
    717717            pos = (pos_x, pos_y + 5) 
    718718        self.PopupMenu(self._slicerpop, pos) 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter2D.py

    r5251ec6 r34f23c8  
    179179        # On Windows platform, default window size is incorrect, so set 
    180180        # toolbar width to figure width. 
    181         _, th = self.toolbar.GetSizeTuple() 
    182         fw, _ = self.canvas.GetSizeTuple() 
     181        _, th = self.toolbar.GetSize() 
     182        fw, _ = self.canvas.GetSize() 
    183183        self.toolbar.SetSize(wx.Size(fw, th)) 
    184184        self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) 
     
    400400            pos = self.ScreenToClient(pos_evt) 
    401401        except: 
    402             pos_x, pos_y = self.toolbar.GetPositionTuple() 
     402            pos_x, pos_y = self.toolbar.GetPosition() 
    403403            pos = (pos_x, pos_y + 5) 
    404404        self.PopupMenu(slicerpop, pos) 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/SimplePlot.py

    r7432acb r34f23c8  
    8484            pos = self.ScreenToClient(pos_evt) 
    8585        except: 
    86             pos_x, pos_y = self.toolbar.GetPositionTuple() 
     86            pos_x, pos_y = self.toolbar.GetPosition() 
    8787            pos = (pos_x, pos_y + 5) 
    8888        self.PopupMenu(slicerpop, pos) 
     
    135135        # set the resizing flag 
    136136        self.canvas.set_resizing(self.resizing) 
    137         pos_x, pos_y = self.GetPositionTuple() 
     137        pos_x, pos_y = self.GetPosition() 
    138138        if pos_x != 0 and pos_y != 0: 
    139             self.size, _ = self.GetClientSizeTuple() 
     139            self.size, _ = self.GetClientSize() 
    140140        self.SetSizer(self.sizer) 
    141141 
  • src/sas/sasgui/guiframe/plugin_base.py

    r5251ec6 r34f23c8  
    105105    def delete_data(self, data_id): 
    106106        """ 
    107         Delete all references of data which id are in data_list.  
     107        Delete all references of data which id are in data_list. 
    108108        """ 
    109109 
     
    142142        """ 
    143143        Create and return the list of application menu 
    144         items for the plug-in.  
     144        items for the plug-in. 
    145145 
    146146        :param parent: parent window 
     
    238238        if self.frame is not None: 
    239239            if old_frame is not None: 
    240                 pos_x, pos_y = old_frame.GetPositionTuple() 
     240                pos_x, pos_y = old_frame.GetPosition() 
    241241                self.frame.SetPosition((pos_x, pos_y)) 
    242242            if not self.frame.IsShown(): 
     
    254254        need to be overwritten by the derivated class 
    255255        """ 
    256      
     256 
    257257    def post_init(self): 
    258258        """ 
     
    261261        pass 
    262262 
    263     def set_state(self, state=None, datainfo=None):     
     263    def set_state(self, state=None, datainfo=None): 
    264264        """ 
    265265        update state 
  • src/sas/sasgui/guiframe/startup_configuration.py

    r5251ec6 r34f23c8  
    127127            for panel in self.parent.plot_panels.values(): 
    128128                #p_panel = self.parent._mgr.GetPane(panel.window_name) 
    129                 width, _ = panel.frame.GetSizeTuple() 
     129                width, _ = panel.frame.GetSize() 
    130130                if panel.frame.IsShown(): 
    131131                    if p_size is None or width > p_size: 
     
    137137            try: 
    138138                control_frame = self.parent.get_current_perspective().frame 
    139                 control_w, control_h = control_frame.GetSizeTuple() 
     139                control_w, control_h = control_frame.GetSize() 
    140140                self.current_string['CONTROL_WIDTH'] = control_w 
    141141                self.current_string['CONTROL_HEIGHT'] = control_h 
     
    144144                self.current_string['CONTROL_HEIGHT'] = -1 
    145145 
    146             data_pw, _ = self.parent.panels["data_panel"].frame.GetSizeTuple() 
     146            data_pw, _ = self.parent.panels["data_panel"].frame.GetSize() 
    147147            if data_pw is None: 
    148148                data_pw = CURRENT_STRINGS['DATAPANEL_WIDTH'] 
  • src/sas/sasgui/perspectives/calculator/data_operator.py

    r5251ec6 r34f23c8  
    866866        except: 
    867867            # toolbar event 
    868             pos_x, pos_y = self.toolbar.GetPositionTuple() 
     868            pos_x, pos_y = self.toolbar.GetPosition() 
    869869            pos = (pos_x, pos_y + 5) 
    870870        self.PopupMenu(slicerpop, pos) 
  • src/sas/sasgui/perspectives/calculator/gen_scatter_panel.py

    r5251ec6 r34f23c8  
    4343 
    4444_BOX_WIDTH = 76 
    45 #Slit length panel size  
     45#Slit length panel size 
    4646if sys.platform.count("win32") > 0: 
    4747    PANEL_TOP = 0 
     
    133133        #kwds['style'] = wx.SUNKEN_BORDER 
    134134        PanelBase.__init__(self) 
    135         #Font size  
     135        #Font size 
    136136        self.SetWindowVariant(variant=FONT_VARIANT) 
    137137        self.SetupScrolling() 
    138         #thread to read data  
     138        #thread to read data 
    139139        self.reader = None 
    140140        self.ext = None 
     
    218218        iy = 0 
    219219        param_title = wx.StaticText(self, -1, 'Parameter') 
    220         sizer.Add(param_title, (iy, ix), (1, 1), \ 
    221                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     220        sizer.Add(param_title, (iy, ix), (1, 1), 
     221                  wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    222222        ix += 1 
    223223        value_title = wx.StaticText(self, -1, 'Value') 
    224         sizer.Add(value_title, (iy, ix), (1, 1), \ 
    225                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     224        sizer.Add(value_title, (iy, ix), (1, 1), 
     225                  wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    226226        ix += 1 
    227227        unit_title = wx.StaticText(self, -1, 'Unit') 
    228         sizer.Add(unit_title, (iy, ix), (1, 1), \ 
    229                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     228        sizer.Add(unit_title, (iy, ix), (1, 1), 
     229                  wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    230230        for param in sorted(params.keys()): 
    231231            iy += 1 
    232232            ix = 0 
    233233            p_name = wx.StaticText(self, -1, param) 
    234             sizer.Add(p_name, (iy, ix), (1, 1), \ 
    235                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     234            sizer.Add(p_name, (iy, ix), (1, 1), 
     235                      wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    236236            ## add parameter value 
    237237            ix += 1 
     
    239239            ctl = InputTextCtrl(self, -1, size=(_BOX_WIDTH * 2, 20), 
    240240                                style=wx.TE_PROCESS_ENTER) 
    241             #ctl.SetToolTipString(\ 
     241            #ctl.SetToolTipString( 
    242242            #            "Hit 'Enter' after typing to update the plot.") 
    243243            ctl.SetValue(format_number(value, True)) 
     
    246246            ix += 1 
    247247            unit = wx.StaticText(self, -1, details[param][0]) 
    248             sizer.Add(unit, (iy, ix), (1, 1), \ 
    249                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     248            sizer.Add(unit, (iy, ix), (1, 1), 
     249                      wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    250250            self.parameters.append([p_name, ctl, unit]) 
    251251 
     
    340340        iy = 0 
    341341        name = wx.StaticText(self, -1, 'No. of Qx (Qy) bins: ') 
    342         sizer.Add(name, (iy, ix), (1, 1), \ 
    343                         wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     342        sizer.Add(name, (iy, ix), (1, 1), 
     343                  wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    344344        ## add parameter value 
    345345        ix += 1 
    346346        self.npt_ctl = InputTextCtrl(self, -1, size=(_BOX_WIDTH * 1.5, 20), 
    347                             style=wx.TE_PROCESS_ENTER) 
     347                                     style=wx.TE_PROCESS_ENTER) 
    348348        self.npt_ctl.Bind(wx.EVT_TEXT, self._onparamEnter) 
    349349        self.npt_ctl.SetValue(format_number(self.npts_x, True)) 
     
    352352        ix += 1 
    353353        unit = wx.StaticText(self, -1, '') 
    354         sizer.Add(unit, (iy, ix), (1, 1), \ 
    355                         wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     354        sizer.Add(unit, (iy, ix), (1, 1), 
     355                  wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    356356        iy += 1 
    357357        ix = 0 
    358358        name = wx.StaticText(self, -1, 'Qx (Qy) Max: ') 
    359         sizer.Add(name, (iy, ix), (1, 1), \ 
    360                         wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     359        sizer.Add(name, (iy, ix), (1, 1), 
     360                  wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    361361        ## add parameter value 
    362362        ix += 1 
     
    369369        ix += 1 
    370370        unit = wx.StaticText(self, -1, '[1/A]') 
    371         sizer.Add(unit, (iy, ix), (1, 1), \ 
    372                         wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     371        sizer.Add(unit, (iy, ix), (1, 1), 
     372                  wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    373373        self.qrange_sizer.Add(sizer, 0, wx.LEFT, 10) 
    374374 
     
    684684        self.sld_data = self.parent.get_sld_from_omf() 
    685685        output = self.sld_data 
    686         #frame_size = wx.Size(470, 470)     
     686        #frame_size = wx.Size(470, 470) 
    687687        self.plot_frame = PlotFrame(self, -1, 'testView') 
    688688        frame = self.plot_frame 
     
    703703        panel.dimension = 3 
    704704        graph_title = self._sld_plot_helper(ax, output, has_arrow) 
    705         # Use y, z axes (in mpl 3d) as z, y axes  
     705        # Use y, z axes (in mpl 3d) as z, y axes 
    706706        # that consistent with our SAS detector coords. 
    707         ax.set_xlabel('x ($\A%s$)' % output.pos_unit) 
    708         ax.set_ylabel('z ($\A%s$)' % output.pos_unit) 
    709         ax.set_zlabel('y ($\A%s$)' % output.pos_unit) 
     707        # Format Angstrom units (A) as latex $\AA$ 
     708        units = output.pos_unit if output.pos_unit != "A" else r"$\AA$" 
     709        ax.set_xlabel('x (%s)' % units) 
     710        ax.set_ylabel('z (%s)' % units) 
     711        ax.set_zlabel('y (%s)' % units) 
    710712        panel.subplot.figure.subplots_adjust(left=0.05, right=0.95, 
    711713                                             bottom=0.05, top=0.96) 
     
    741743            marker = 'o' 
    742744            m_size = 3.5 
    743         sld_tot = (np.fabs(sld_mx) + np.fabs(sld_my) + \ 
    744                    np.fabs(sld_mz) + np.fabs(output.sld_n)) 
     745        sld_tot = (np.fabs(sld_mx) + np.fabs(sld_my) 
     746                   + np.fabs(sld_mz) + np.fabs(output.sld_n)) 
    745747        is_nonzero = sld_tot > 0.0 
    746748        is_zero = sld_tot == 0.0 
     
    766768                        pos_y[chosen_color], marker, c=color, alpha=0.5, 
    767769                        markeredgecolor=color, markersize=m_size, label=key) 
    768         # III. Plot All others         
     770        # III. Plot All others 
    769771        if np.any(other_color): 
    770772            a_name = '' 
     
    10281030        self.data = Data2D() 
    10291031        qmax = self.qmax_x #/ np.sqrt(2) 
    1030         self.data.xaxis('\\rm{Q_{x}}', '\AA^{-1}') 
    1031         self.data.yaxis('\\rm{Q_{y}}', '\AA^{-1}') 
     1032        self.data.xaxis(r'\rm{Q_{x}}', r'\AA^{-1}') 
     1033        self.data.yaxis(r'\rm{Q_{y}}', r'\AA^{-1}') 
    10321034        self.data.is_data = False 
    10331035        self.data.id = str(self.uid) + " GenData" 
     
    11201122        new_plot.dx = data.dx 
    11211123        new_plot.dy = data.dy 
    1122         new_plot.xaxis('\\rm{Q_{x}}', '\AA^{-1}') 
    1123         new_plot.yaxis('\\rm{Intensity}', 'cm^{-1}') 
     1124        new_plot.xaxis(r'\rm{Q_{x}}', r'\AA^{-1}') 
     1125        new_plot.yaxis(r'\rm{Intensity}', 'cm^{-1}') 
    11241126        new_plot.is_data = False 
    11251127        new_plot.id = str(self.uid) + " GenData1D" 
     
    11271129        new_plot.name = model.name + '1d' 
    11281130        new_plot.title = "Generic model1D " 
    1129         new_plot.id = str(page_id) + ': ' + self.file_name \ 
    1130                         + ' #%s' % str(self.graph_num) + "_1D" 
    1131         new_plot.group_id = str(page_id) + " Model1D" + \ 
    1132                              ' #%s' % str(self.graph_num) + "_1D" 
     1131        new_plot.id = (str(page_id) + ': ' + self.file_name 
     1132                       + ' #%s' % str(self.graph_num) + "_1D") 
     1133        new_plot.group_id = (str(page_id) + " Model1D" 
     1134                             + ' #%s' % str(self.graph_num) + "_1D") 
    11331135        new_plot.is_data = False 
    11341136 
     
    11751177        new_plot.name = model.name + '2d' 
    11761178        new_plot.title = "Generic model 2D " 
    1177         new_plot.id = str(page_id) + ': ' + self.file_name \ 
    1178                         + ' #%s' % str(self.graph_num) + "_2D" 
    1179         new_plot.group_id = str(page_id) + " Model2D" \ 
    1180                         + ' #%s' % str(self.graph_num) + "_2D" 
     1179        new_plot.id = (str(page_id) + ': ' + self.file_name 
     1180                       + ' #%s' % str(self.graph_num) + "_2D") 
     1181        new_plot.group_id = (str(page_id) + " Model2D" 
     1182                             + ' #%s' % str(self.graph_num) + "_2D") 
    11811183        new_plot.detector = data.detector 
    11821184        new_plot.source = data.source 
     
    12431245                               *args, **kwds) 
    12441246        PanelBase.__init__(self) 
    1245         #Font size  
     1247        #Font size 
    12461248        self.SetWindowVariant(variant=FONT_VARIANT) 
    12471249        self.SetupScrolling() 
     
    14461448            ix = 0 
    14471449            name = wx.StaticText(self, -1, key) 
    1448             sizer.Add(name, (iy, ix), (1, 1), \ 
    1449                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     1450            sizer.Add(name, (iy, ix), (1, 1), 
     1451                      wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    14501452            ## add parameter value 
    14511453            ix += 1 
     
    14591461            s_unit = '[' + omfdata.sld_unit + ']' 
    14601462            unit = wx.StaticText(self, -1, s_unit) 
    1461             sizer.Add(unit, (iy, ix), (1, 1), \ 
    1462                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     1463            sizer.Add(unit, (iy, ix), (1, 1), 
     1464                      wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    14631465            self.slds.append([key, ctl, unit]) 
    14641466        self.sld_sizer.Add(sizer, 0, wx.LEFT, 10) 
     
    14811483            ix = 0 
    14821484            name = wx.StaticText(self, -1, key) 
    1483             sizer.Add(name, (iy, ix), (1, 1), \ 
    1484                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     1485            sizer.Add(name, (iy, ix), (1, 1), 
     1486                      wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    14851487            ## add parameter value 
    14861488            ix += 1 
     
    14941496            ix += 1 
    14951497            unit = wx.StaticText(self, -1, '') 
    1496             sizer.Add(unit, (iy, ix), (1, 1), \ 
    1497                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     1498            sizer.Add(unit, (iy, ix), (1, 1), 
     1499                      wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    14981500            self.nodes.append([key, ctl, unit]) 
    14991501        self.node_sizer.Add(sizer, 0, wx.LEFT, 10) 
     
    15161518            ix = 0 
    15171519            name = wx.StaticText(self, -1, key) 
    1518             sizer.Add(name, (iy, ix), (1, 1), \ 
    1519                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     1520            sizer.Add(name, (iy, ix), (1, 1), 
     1521                      wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    15201522            ## add parameter value 
    15211523            ix += 1 
     
    15301532            p_unit = '[' + omfdata.pos_unit + ']' 
    15311533            unit = wx.StaticText(self, -1, p_unit) 
    1532             sizer.Add(unit, (iy, ix), (1, 1), \ 
    1533                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     1534            sizer.Add(unit, (iy, ix), (1, 1), 
     1535                      wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    15341536            self.stepsize.append([key, ctl, unit]) 
    15351537        self.step_sizer.Add(sizer, 0, wx.LEFT, 10) 
     
    16261628            for ctr_list in self.slds: 
    16271629                ctr_list[1].Enable(False) 
    1628                 #break    
     1630                #break 
    16291631            return 
    16301632 
     
    16371639                    max_val = np.max(sld_list[key]) 
    16381640                    mean_val = np.mean(sld_list[key]) 
    1639                     enable = (min_val == max_val) and \ 
    1640                              sld_data.pix_type == 'pixel' 
     1641                    enable = ((min_val == max_val) 
     1642                              and sld_data.pix_type == 'pixel') 
    16411643                    ctr_list[1].SetValue(format_number(mean_val, True)) 
    16421644                    ctr_list[1].Enable(enable) 
  • src/sas/sasgui/perspectives/calculator/image_viewer.py

    r5251ec6 r34f23c8  
    6262                # Any other formats (tiff, jpeg, etc) are passed 
    6363                # to PIL which seems to have a problem in version 
    64                 # 1.1.7 that causes a close error which shows up in  
     64                # 1.1.7 that causes a close error which shows up in 
    6565                # the log file.  This does not seem to have any adverse 
    6666                # effects.  PDB   --- September 17, 2017. 
     
    383383                print(err_msg) 
    384384 
    385         self.OnClose(event) 
     385        self.EndModal(wx.ID_OK) 
    386386 
    387387    def convert_image(self, rgb, xmin, xmax, ymin, ymax, zscale): 
     
    417417        output.ymin = ymin 
    418418        output.ymax = ymax 
    419         output.xaxis('\\rm{Q_{x}}', '\AA^{-1}') 
    420         output.yaxis('\\rm{Q_{y}}', '\AA^{-1}') 
     419        output.xaxis(r'\rm{Q_{x}}', r'\AA^{-1}') 
     420        output.yaxis(r'\rm{Q_{y}}', r'\AA^{-1}') 
    421421        # Store loading process information 
    422422        output.meta_data['loader'] = self.title.split('.')[-1] + "Reader" 
     
    451451        # clear event 
    452452        event.Skip() 
    453         self.Destroy() 
     453        self.EndModal(wx.ID_CANCEL) 
     454        #self.Destroy() 
    454455 
    455456if __name__ == "__main__": 
  • src/sas/sasgui/perspectives/pr/explore_dialog.py

    r5251ec6 r34f23c8  
    5050    window_caption = "D Explorer" 
    5151 
    52     def __init__(self, d_min, d_max, parent, id= -1, color=None, \ 
     52    def __init__(self, d_min, d_max, parent, id= -1, color=None, 
    5353                 dpi=None, style=wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs): 
    5454        """ 
     
    7777        self.plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 
    7878 
    79         # Graph         
     79        # Graph 
    8080        self.graph = Graph() 
    81         self.graph.xaxis("\\rm{D_{max}}", 'A') 
    82         self.graph.yaxis("\\rm{%s}" % DEFAULT_OUTPUT, "") 
     81        self.graph.xaxis(r"\rm{D_{max}}", 'A') 
     82        self.graph.yaxis(r"\rm{%s}" % DEFAULT_OUTPUT, "") 
    8383        self.graph.add(self.plot) 
    8484        self.graph.render(self) 
     
    133133        # Dictionary of outputs 
    134134        self.outputs = {} 
    135         self.outputs['Chi2/dof'] = ["\chi^2/dof", "a.u.", self.chi2] 
     135        self.outputs['Chi2/dof'] = [r"\chi^2/dof", "a.u.", self.chi2] 
    136136        self.outputs['Oscillation parameter'] = ["Osc", "a.u.", self.osc] 
    137137        self.outputs['Positive fraction'] = ["P^+", "a.u.", self.pos] 
    138         self.outputs['1-sigma positive fraction'] = ["P^+_{1\ \sigma}", 
     138        self.outputs['1-sigma positive fraction'] = [r"P^+_{1\ \sigma}", 
    139139                                                     "a.u.", self.pos_err] 
    140140        self.outputs['Rg'] = ["R_g", "A", self.rg] 
  • src/sas/sasgui/perspectives/simulation/SimCanvas.py

    r959eb01 r34f23c8  
    22This software was developed by the University of Tennessee as part of the 
    33Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    4 project funded by the US National Science Foundation.  
     4project funded by the US National Science Foundation. 
    55 
    66See the license text in license.txt 
     
    3232except ImportError: 
    3333    haveOpenGL = False 
    34      
     34 
    3535# Color set 
    36 DEFAULT_COLOR = [1.0, 1.0, 0.0, .2]     
     36DEFAULT_COLOR = [1.0, 1.0, 0.0, .2] 
    3737COLOR_RED     = [1.0, 0.0, 0.0, .2] 
    3838COLOR_GREEN   = [0.0, 1.0, 0.0, .2] 
     
    4848class SimPanel(wx.Panel): 
    4949    """ 
    50         3D viewer to support real-space simulation.  
     50        3D viewer to support real-space simulation. 
    5151    """ 
    5252    window_name = "3dview" 
    5353    window_caption = "3D viewer" 
    54      
     54 
    5555    def __init__(self, parent, id = -1, plots = None, standalone=False, **kwargs): 
    5656        wx.Panel.__init__(self, parent, id = id, **kwargs) 
    5757        self.parent = parent 
    58      
     58 
    5959        #Add a sizer 
    6060        mainSizer = wx.BoxSizer(wx.VERTICAL) 
    6161        sliderSizer = wx.BoxSizer(wx.HORIZONTAL) 
    62      
    63         self.canvas    = CanvasBase(self)  
     62 
     63        self.canvas    = CanvasBase(self) 
    6464        self.canvas.SetMinSize((200,2100)) 
    6565 
     
    7272        self.SetSizer(mainSizer) 
    7373        self.Bind(wx.EVT_CONTEXT_MENU, self._on_context_menu) 
    74          
    75   
     74 
     75 
    7676    def _on_context_menu(self, event): 
    7777        """ 
     
    8383        slicerpop.Append(id, '&Reset 3D View') 
    8484        wx.EVT_MENU(self, id, self.canvas.resetView) 
    85         
     85 
    8686        pos = event.GetPosition() 
    8787        pos = self.ScreenToClient(pos) 
    88         self.PopupMenu(slicerpop, pos)         
    89      
     88        self.PopupMenu(slicerpop, pos) 
     89 
    9090class CanvasBase(glcanvas.GLCanvas): 
    9191    """ 
     
    9494    window_name = "Simulation" 
    9595    window_caption = "Simulation" 
    96      
     96 
    9797    def __init__(self, parent): 
    9898        glcanvas.GLCanvas.__init__(self, parent, -1) 
     
    113113        self.Bind(wx.EVT_MOTION, self.OnMouseMotion) 
    114114        self.Bind(wx.EVT_MOUSEWHEEL, self._onMouseWheel) 
    115          
     115 
    116116        self.initialized = False 
    117117        self.shapes = [] 
    118118        self.parent = parent 
    119          
     119 
    120120        # Reference vectors 
    121121        self.x_vec = [1,0,0] 
    122122        self.y_vec = [0,1,0] 
    123          
     123 
    124124        self.mouse_down = False 
    125125        self.scale = 1.0 
    126126        self.zoom  = 1.0 
    127127        self.translation = [0,0,0] 
    128          
     128 
    129129        # Bind to Edit events 
    130130        self.parent.Bind(ShapeParameters.EVT_EDIT_SHAPE, self._onEditShape) 
    131          
     131 
    132132    def resetView(self, evt=None): 
    133133        """ 
     
    140140        glLoadIdentity() 
    141141        self.Refresh() 
    142                  
     142 
    143143    def _onEditShape(self, evt): 
    144144        evt.Skip() 
     
    158158        event.Skip() 
    159159 
    160     def OnPaint(self, event):      
     160    def OnPaint(self, event): 
    161161        size = self.GetClientSize() 
    162162        side = size.width 
    163163        if size.height<size.width: 
    164164            side = size.height 
    165          
     165 
    166166        if self.GetContext(): 
    167167            glViewport(0, 0, side, side) 
    168168            self.SetMinSize((side,side)) 
    169              
     169 
    170170        dc = wx.PaintDC(self) 
    171171        self.SetCurrent() 
     
    174174            self.init = True 
    175175        self.OnDraw() 
    176         event.Skip()         
    177          
     176        event.Skip() 
     177 
    178178    def _onMouseWheel(self, evt): 
    179179        # Initialize mouse position so we don't have unwanted rotation 
    180180        self.x, self.y = self.lastx, self.lasty = evt.GetPosition() 
    181181        self.tr_x, self.tr_y = self.tr_lastx, self.tr_lasty = evt.GetPosition() 
    182          
     182 
    183183        scale = 1.15 
    184184        if evt.GetWheelRotation()<0: 
    185185            scale = 1.0/scale 
    186               
    187         self.zoom *= scale              
    188               
     186 
     187        self.zoom *= scale 
     188 
    189189        glScale(scale, scale, scale) 
    190190        self.Refresh(False) 
    191          
     191 
    192192    def OnMouseDown(self, evt): 
    193193        self.SetFocus() 
     
    214214        slicerpop.Append(id, '&Reset 3D View') 
    215215        wx.EVT_MENU(self, id, self.resetView) 
    216         
     216 
    217217        pos = event.GetPosition() 
    218218        #pos = self.ScreenToClient(pos) 
    219         self.PopupMenu(slicerpop, pos)         
     219        self.PopupMenu(slicerpop, pos) 
    220220 
    221221    def OnMouseMotion(self, evt): 
     
    223223            self.tr_lastx, self.tr_lasty = self.tr_x, self.tr_y 
    224224            x, y = evt.GetPosition() 
    225              
     225 
    226226            # Min distance to do anything 
    227227            if math.fabs(self.lastx-x)>10 or math.fabs(self.lasty-y)>10: 
    228                  
     228 
    229229                self.lastx, self.lasty = self.x, self.y 
    230          
    231                  
     230 
     231 
    232232                if math.fabs(self.lastx-x)>math.fabs(self.lasty-y): 
    233233                    self.x = x 
    234234                else: 
    235235                    self.y = y 
    236                  
     236 
    237237                #self.x, self.y = evt.GetPosition() 
    238238                self.Refresh(False) 
    239                  
     239 
    240240        elif evt.Dragging() and evt.RightIsDown(): 
    241241            self.lastx, self.lasty = self.x, self.y 
     
    243243            self.tr_x, self.tr_y = evt.GetPosition() 
    244244            self.Refresh(False) 
    245              
    246     def InitGL( self ):       
     245 
     246    def InitGL( self ): 
    247247        glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA) 
    248248        #glShadeModel(GL_FLAT); 
    249          
     249 
    250250        glMatrixMode(GL_PROJECTION) 
    251          
     251 
    252252        glLight(GL_LIGHT0, GL_AMBIENT, [.2, .2, .2, 0]) 
    253          
     253 
    254254        # Object color 
    255255        #glLight(GL_LIGHT0, GL_DIFFUSE, COLOR_BLUE) 
    256          
     256 
    257257        glLight(GL_LIGHT0, GL_POSITION, [1.0, 1.0, -1.0, 0.0]) 
    258          
    259          
     258 
     259 
    260260        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, [1, 1, 1, 0]) 
    261261        glEnable(GL_LIGHTING) 
     
    263263        glEnable(GL_BLEND) 
    264264        glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
    265          
     265 
    266266        glEnable ( GL_ALPHA_TEST ) ; 
    267267        glAlphaFunc ( GL_GREATER, 0 ) ; 
    268268        glPixelStorei(GL_PACK_ALIGNMENT, 1) 
    269269        glPixelStorei(GL_UNPACK_ALIGNMENT, 1) 
    270          
     270 
    271271        glEnable(GL_NORMALIZE) 
    272272        glDepthFunc(GL_LESS) 
     
    276276        #glClear (GL_COLOR_BUFFER_BIT); 
    277277        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) 
    278          
    279          
     278 
     279 
    280280        gluPerspective(0, 1.0, 0.1, 60.0); 
    281281 
     
    296296        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) 
    297297        # use a fresh transformation matrix 
    298          
     298 
    299299        # get the max object size to re-scale 
    300300        max_size = 1.0 
     
    305305            if l>max_size: 
    306306                max_size = l 
    307          
     307 
    308308        max_size *= 1.05 
    309309        scale = self.scale/max_size 
    310310        glScale(scale, scale, scale) 
    311311        self.scale = max_size 
    312          
     312 
    313313        self.drawAxes() 
    314          
     314 
    315315        if self.mouse_down: 
    316316            if math.fabs((self.x - self.lastx))>math.fabs((self.y - self.lasty)): 
    317                 angle = 10.0*(self.x - self.lastx) / math.fabs(self.x - self.lastx)  
     317                angle = 10.0*(self.x - self.lastx) / math.fabs(self.x - self.lastx) 
    318318                glRotate(angle, self.y_vec[0], self.y_vec[1], self.y_vec[2]); 
    319319                self._rot_y(angle) 
    320320            elif math.fabs(self.y - self.lasty)>0: 
    321                 angle = 10.0*(self.y - self.lasty) / math.fabs(self.y - self.lasty)  
     321                angle = 10.0*(self.y - self.lasty) / math.fabs(self.y - self.lasty) 
    322322                glRotate(angle, self.x_vec[0], self.x_vec[1], self.x_vec[2]); 
    323323                self._rot_x(angle) 
     
    325325            self.lasty = self.y 
    326326            self.lastx = self.x 
    327          
    328             w,h = self.GetVirtualSizeTuple() 
    329          
     327 
     328            w, h = self.GetVirtualSize() 
     329 
    330330            # Translate in the x-y plane 
    331331            vx = self.x_vec[0] * 2.0*float(self.tr_x - self.tr_lastx)/w \ 
     
    335335            vz = self.x_vec[2] * 2.0*float(self.tr_x - self.tr_lastx)/w \ 
    336336               + self.y_vec[2] * 2.0*float(self.tr_lasty - self.tr_y)/h 
    337              
    338             glTranslate(self.scale*vx/self.zoom, self.scale*vy/self.zoom, self.scale*vz/self.zoom)     
    339                  
     337 
     338            glTranslate(self.scale*vx/self.zoom, self.scale*vy/self.zoom, self.scale*vz/self.zoom) 
     339 
    340340        # push into visible buffer 
    341341        self.SwapBuffers() 
    342          
     342 
    343343    def _matrix_mult(self, v, axis, angle): 
    344344        c = math.cos(angle) 
    345         s = math.sin(angle)  
     345        s = math.sin(angle) 
    346346        x = axis[0] 
    347347        y = axis[1] 
     
    351351        vz = v[0]*(x*z*(1-c)-y*s) + v[1]*(y*z*(1-c)+x*s) + v[2]*(z*z*(1-c)+c) 
    352352        return [vx, vy, vz] 
    353      
     353 
    354354    def _rot_y(self, theta): 
    355355        """ 
    356356            Rotate the view by theta around the y-axis 
    357357        """ 
    358         angle = theta/180.0*math.pi  
     358        angle = theta/180.0*math.pi 
    359359        axis = self.y_vec 
    360360        self.x_vec = self._matrix_mult(self.x_vec, self.y_vec, -angle) 
    361          
     361 
    362362    def _rot_x(self, theta): 
    363363        """ 
     
    366366        angle = theta/180.0*math.pi 
    367367        self.y_vec = self._matrix_mult(self.y_vec, self.x_vec, -angle) 
    368          
    369          
     368 
     369 
    370370    def addShape(self, shape, name=None): 
    371371        """ 
     
    403403 
    404404    def drawAxes(self): 
    405         """  
     405        """ 
    406406            Draw 3D axes 
    407407        """ 
    408408        pos = self.scale * 0.7 
    409         
     409 
    410410        # Z-axis is red 
    411         zaxis= Arrow(x=pos, y=-pos, z=0, r_cyl=self.scale*0.005, r_cone=self.scale*0.01,  
     411        zaxis= Arrow(x=pos, y=-pos, z=0, r_cyl=self.scale*0.005, r_cone=self.scale*0.01, 
    412412                     l_cyl=self.scale*0.1, l_cone=self.scale*0.05) 
    413413        zaxis.color = COLOR_RED 
    414414        zaxis.draw() 
    415          
     415 
    416416        # Y-axis is yellow 
    417         yaxis= Arrow(x=pos, y=-pos, z=0, r_cyl=self.scale*0.005, r_cone=self.scale*0.01,  
     417        yaxis= Arrow(x=pos, y=-pos, z=0, r_cyl=self.scale*0.005, r_cone=self.scale*0.01, 
    418418                     l_cyl=self.scale*0.1, l_cone=self.scale*0.05) 
    419419        yaxis.color = COLOR_YELLOW 
    420420        yaxis.rotate(-90,0,0) 
    421421        yaxis.draw() 
    422          
     422 
    423423        # X-axis is green 
    424         xaxis= Arrow(x=pos, y=-pos, z=0, r_cyl=self.scale*0.005, r_cone=self.scale*0.01,  
     424        xaxis= Arrow(x=pos, y=-pos, z=0, r_cyl=self.scale*0.005, r_cone=self.scale*0.01, 
    425425                     l_cyl=self.scale*0.1, l_cone=self.scale*0.05) 
    426426        xaxis.color = COLOR_GREEN 
    427427        xaxis.rotate(0,-90,0) 
    428428        xaxis.draw() 
    429          
     429 
    430430        glLight(GL_LIGHT0, GL_DIFFUSE, DEFAULT_COLOR) 
    431431 
     
    445445        self.theta_y = 0 
    446446        self.theta_z = 0 
    447          
     447 
    448448        # Params 
    449449        self.params = {} 
     
    453453        self.details['contrast'] = 'A-2' 
    454454        self.details['order']    = ' ' 
    455          
     455 
    456456        self.highlighted = False 
    457457        self.color = DEFAULT_COLOR 
    458      
     458 
    459459    def get_volume(self): 
    460460        return 0 
    461      
     461 
    462462    def get_length(self): 
    463463        return 1.0 
    464      
     464 
    465465    def highlight(self, value=False): 
    466466        self.highlighted = value 
    467          
     467 
    468468    def rotate(self, alpha, beta, gamma): 
    469         """  
     469        """ 
    470470            Set the rotation angles of the shape 
    471471            @param alpha: angle around the x-axis [degrees] 
     
    476476        self.theta_y = beta 
    477477        self.theta_z = gamma 
    478          
     478 
    479479    def _rotate(self): 
    480480        """ 
    481481            Perform the OpenGL rotation 
    482              
     482 
    483483            Note that the rotation order is reversed. 
    484484            We do Y, X, Z do be compatible with simulation... 
    485485        """ 
    486          
     486 
    487487        glRotated(self.theta_z, 0, 0, 1) 
    488488        glRotated(self.theta_x, 1, 0, 0) 
    489489        glRotated(self.theta_y, 0, 1, 0) 
    490          
     490 
    491491    def _pre_draw(self): 
    492492        if self.highlighted: 
     
    506506        self.l_cyl = l_cyl 
    507507        self.l_cone = l_cone 
    508             
     508 
    509509    def draw(self): 
    510510        self._pre_draw() 
    511511        glPushMatrix() 
    512512        glTranslate(self.x, self.y, self.z) 
    513          
     513 
    514514        # Perform rotation 
    515515        glRotate(self.theta_x, 1, 0, 0) 
     
    520520        qobj = gluNewQuadric(); 
    521521        gluCylinder(qobj, self.r_cyl, self.r_cyl, self.l_cyl, 15, 5); 
    522                  
     522 
    523523        glTranslate(0, 0, self.z+self.l_cyl) 
    524          
     524 
    525525        # Draw cone of the arrow 
    526526        glutSolidCone(self.r_cone, self.l_cone, 30, 5) 
    527          
     527 
    528528        # Translate back to original position 
    529529        glTranslate(-self.x, -self.y, -self.z) 
     
    538538        self.radius = radius 
    539539        self.height = height 
    540          
     540 
    541541    def draw(self): 
    542542        glPushMatrix() 
     
    556556        self.params['radius'] = radius 
    557557        self.details['radius'] = 'A' 
    558          
     558 
    559559    def get_volume(self): 
    560560        return 4.0/3.0*math.pi*self.params['radius']*self.params['radius']*self.params['radius'] 
    561          
     561 
    562562    def get_length(self): 
    563563        return 2.0*self.params['radius'] 
    564      
     564 
    565565    def draw(self): 
    566566        self._pre_draw() 
     
    584584    """ 
    585585        Cylinder shape, by default the cylinder is oriented along 
    586         the z-axis.  
    587          
     586        the z-axis. 
     587 
    588588        The reference point of the cylinder is the center of the 
    589589        bottom circle. 
     
    596596        self.details['radius'] = 'A' 
    597597        self.details['length'] = 'A' 
    598          
     598 
    599599    def get_volume(self): 
    600600        return math.pi*self.params['radius']*self.params['radius']*self.params['length'] 
    601          
     601 
    602602    def get_length(self): 
    603603        if self.params['length']>2.0*self.params['radius']: 
     
    605605        else: 
    606606            return 2.0*self.params['radius'] 
    607          
     607 
    608608    def draw(self): 
    609609        self._pre_draw() 
    610610        glPushMatrix() 
    611          
     611 
    612612        glTranslate(self.x, self.y, self.z) 
    613         self._rotate()  
     613        self._rotate() 
    614614        qobj = gluNewQuadric(); 
    615615        # gluCylinder(qobj, r_base, r_top, L, div around z, div along z) 
     
    619619        glPopMatrix() 
    620620        glLight(GL_LIGHT0, GL_DIFFUSE, DEFAULT_COLOR) 
    621          
     621 
    622622    def accept(self, visitor): 
    623623        return visitor.fromCylinder(self) 
    624          
     624 
    625625    def accept_update(self, visitor): 
    626626        return visitor.update_cylinder(self) 
    627          
     627 
    628628# Fill the shape list 
    629629SHAPE_LIST.append(dict(name='Sphere',   id=wx.NewId(), cl=Sphere)) 
    630630SHAPE_LIST.append(dict(name='Cylinder', id=wx.NewId(), cl=Cylinder)) 
    631          
     631 
    632632def getShapes(): 
    633633    """ 
     
    635635    """ 
    636636    return SHAPE_LIST 
    637      
     637 
    638638def getShapeClass(id): 
    639639    """ 
     
    647647        return shape[0]['cl'] 
    648648    return None 
    649      
     649 
    650650def getShapeClassByName(name): 
    651651    """ 
  • src/sas/sasgui/plottools/PlotPanel.py

    r82d88d5 r34f23c8  
    339339        # On Windows platform, default window size is incorrect, so set 
    340340        # toolbar width to figure width. 
    341         tw, th = self.toolbar.GetSizeTuple() 
    342         fw, fh = self.canvas.GetSizeTuple() 
     341        tw, th = self.toolbar.GetSize() 
     342        fw, fh = self.canvas.GetSize() 
    343343        # By adding toolbar in sizer, we are able to put it at the bottom 
    344344        # of the frame - so appearance is closer to GTK version. 
     
    439439            y = hi_y 
    440440        # Move the legend from its previous location by that same amount 
    441         loc_in_canvas = self.legend_x - mouse_diff_x, \ 
    442                         self.legend_y - mouse_diff_y 
     441        loc_in_canvas = (self.legend_x - mouse_diff_x, 
     442                         self.legend_y - mouse_diff_y) 
    443443        # Transform into legend coordinate system 
    444444        trans_axes = self.legend.parent.transAxes.inverted() 
     
    630630        Return values and labels used by Fit Dialog 
    631631        """ 
    632         return self.xLabel, self.yLabel, self.Avalue, self.Bvalue, \ 
    633                 self.ErrAvalue, self.ErrBvalue, self.Chivalue 
     632        return (self.xLabel, self.yLabel, self.Avalue, self.Bvalue, 
     633                self.ErrAvalue, self.ErrBvalue, self.Chivalue) 
    634634 
    635635    def setTrans(self, xtrans, ytrans): 
     
    667667                            title='Linear Fit') 
    668668 
    669             if (self.xmin != 0.0)and (self.xmax != 0.0)\ 
    670                 and(self.xminView != 0.0)and (self.xmaxView != 0.0): 
     669            if ((self.xmin != 0.0) and (self.xmax != 0.0) 
     670                    and (self.xminView != 0.0) and (self.xmaxView != 0.0)): 
    671671                dlg.setFitRange(self.xminView, self.xmaxView, 
    672672                                self.xmin, self.xmax) 
     
    925925        except: 
    926926            # toolbar event 
    927             pos_x, pos_y = self.toolbar.GetPositionTuple() 
     927            pos_x, pos_y = self.toolbar.GetPosition() 
    928928            pos = (pos_x, pos_y + 5) 
    929929 
     
    10591059        Allows you to add text to the plot 
    10601060        """ 
    1061         xaxis_label, xaxis_unit, xaxis_font, xaxis_color, \ 
    1062                      is_ok, is_tick = self._on_axis_label(axis='x') 
     1061        xaxis_label, xaxis_unit, xaxis_font, xaxis_color, is_ok, is_tick \ 
     1062            = self._on_axis_label(axis='x') 
    10631063        if not is_ok: 
    10641064            return 
     
    10731073        if self.data is not None: 
    10741074            # 2D 
    1075             self.xaxis(self.xaxis_label, self.xaxis_unit, \ 
    1076                         self.xaxis_font, self.xaxis_color, self.xaxis_tick) 
     1075            self.xaxis(self.xaxis_label, self.xaxis_unit, 
     1076                       self.xaxis_font, self.xaxis_color, self.xaxis_tick) 
    10771077            self.subplot.figure.canvas.draw_idle() 
    10781078        else: 
     
    11061106        Allows you to add text to the plot 
    11071107        """ 
    1108         yaxis_label, yaxis_unit, yaxis_font, yaxis_color, \ 
    1109                         is_ok, is_tick = self._on_axis_label(axis='y') 
     1108        yaxis_label, yaxis_unit, yaxis_font, yaxis_color, is_ok, is_tick \ 
     1109            = self._on_axis_label(axis='y') 
    11101110        if not is_ok: 
    11111111            return 
     
    11201120        if self.data is not None: 
    11211121            # 2D 
    1122             self.yaxis(self.yaxis_label, self.yaxis_unit, \ 
     1122            self.yaxis(self.yaxis_label, self.yaxis_unit, 
    11231123                        self.yaxis_font, self.yaxis_color, self.yaxis_tick) 
    11241124            self.subplot.figure.canvas.draw_idle() 
     
    11561156                is_tick = textdial.getTickLabel() 
    11571157                label_temp = textdial.getText() 
    1158                 if label_temp.count("\%s" % "\\") > 0: 
     1158                if r"\\" in label_temp: 
     1159                    label = label_temp.replace(r"\\", r"??") 
    11591160                    if self.parent is not None: 
    1160                         msg = "Add Label: Error. Can not use double '\\' " 
     1161                        msg = r"Add Label error: Can not use double '\\' " 
    11611162                        msg += "characters..." 
    11621163                        wx.PostEvent(self.parent, StatusEvent(status=msg)) 
     
    15331534        """ 
    15341535        # No qx or qy given in a vector format 
    1535         if self.qx_data is None or self.qy_data is None \ 
    1536                 or self.qx_data.ndim != 1 or self.qy_data.ndim != 1: 
     1536        if (self.qx_data is None or self.qy_data is None 
     1537                or self.qx_data.ndim != 1 or self.qy_data.ndim != 1): 
    15371538            # do we need deepcopy here? 
    15381539            return copy.deepcopy(self.data) 
     
    15931594        """ 
    15941595        # No qx or qy given in a vector format 
    1595         if self.qx_data is None or self.qy_data is None \ 
    1596                 or self.qx_data.ndim != 1 or self.qy_data.ndim != 1: 
     1596        if (self.qx_data is None or self.qy_data is None 
     1597                or self.qx_data.ndim != 1 or self.qy_data.ndim != 1): 
    15971598            # do we need deepcopy here? 
    15981599            return copy.deepcopy(self.data) 
     
    16441645        """ 
    16451646        # No image matrix given 
    1646         if image is None or np.ndim(image) != 2 \ 
    1647                 or np.isfinite(image).all() \ 
    1648                 or weights is None: 
     1647        if (image is None or np.ndim(image) != 2 
     1648                or np.isfinite(image).all() or weights is None): 
    16491649            return image 
    16501650        # Get bin size in y and x directions 
     
    16761676                    # go 4 next nearest neighbors when no non-zero 
    16771677                    # neighbor exists 
    1678                     if n_y != 0 and n_x != 0 and \ 
    1679                             np.isfinite(image[n_y - 1][n_x - 1]): 
     1678                    if (n_y != 0 and n_x != 0 
     1679                            and np.isfinite(image[n_y - 1][n_x - 1])): 
    16801680                        temp_image[n_y][n_x] += image[n_y - 1][n_x - 1] 
    16811681                        weit[n_y][n_x] += 1 
    1682                     if n_y != len_y - 1 and n_x != 0 and \ 
    1683                             np.isfinite(image[n_y + 1][n_x - 1]): 
     1682                    if (n_y != len_y - 1 and n_x != 0 
     1683                            and np.isfinite(image[n_y + 1][n_x - 1])): 
    16841684                        temp_image[n_y][n_x] += image[n_y + 1][n_x - 1] 
    16851685                        weit[n_y][n_x] += 1 
    1686                     if n_y != len_y and n_x != len_x - 1 and \ 
    1687                             np.isfinite(image[n_y - 1][n_x + 1]): 
     1686                    if (n_y != len_y and n_x != len_x - 1 
     1687                            and np.isfinite(image[n_y - 1][n_x + 1])): 
    16881688                        temp_image[n_y][n_x] += image[n_y - 1][n_x + 1] 
    16891689                        weit[n_y][n_x] += 1 
    1690                     if n_y != len_y - 1 and n_x != len_x - 1 and \ 
    1691                             np.isfinite(image[n_y + 1][n_x + 1]): 
     1690                    if (n_y != len_y - 1 and n_x != len_x - 1 
     1691                            and np.isfinite(image[n_y + 1][n_x + 1])): 
    16921692                        temp_image[n_y][n_x] += image[n_y + 1][n_x + 1] 
    16931693                        weit[n_y][n_x] += 1 
     
    17841784                item.transformX(transform.toX2, transform.errToX2) 
    17851785                xunits = convert_unit(2, xunits) 
    1786                 self.graph._xaxis_transformed("%s^{2}" % xname, "%s" % xunits) 
     1786                self.graph._xaxis_transformed("%s^2" % xname, "%s" % xunits) 
    17871787            if self.xLabel == "x^(4)": 
    17881788                item.transformX(transform.toX4, transform.errToX4) 
    17891789                xunits = convert_unit(4, xunits) 
    1790                 self.graph._xaxis_transformed("%s^{4}" % xname, "%s" % xunits) 
     1790                self.graph._xaxis_transformed("%s^4" % xname, "%s" % xunits) 
    17911791            if self.xLabel == "ln(x)": 
    17921792                item.transformX(transform.toLogX, transform.errToLogX) 
    1793                 self.graph._xaxis_transformed("\ln{(%s)}" % xname, "%s" % xunits) 
     1793                self.graph._xaxis_transformed(r"\ln(%s)" % xname, "%s" % xunits) 
    17941794            if self.xLabel == "log10(x)": 
    17951795                item.transformX(transform.toX_pos, transform.errToX_pos) 
     
    17991799                item.transformX(transform.toX4, transform.errToX4) 
    18001800                xunits = convert_unit(4, xunits) 
    1801                 self.graph._xaxis_transformed("%s^{4}" % xname, "%s" % xunits) 
     1801                self.graph._xaxis_transformed("%s^4" % xname, "%s" % xunits) 
    18021802                _xscale = 'log' 
    18031803            if self.yLabel == "ln(y)": 
    18041804                item.transformY(transform.toLogX, transform.errToLogX) 
    1805                 self.graph._yaxis_transformed("\ln{(%s)}" % yname, "%s" % yunits) 
     1805                self.graph._yaxis_transformed(r"\ln(%s)" % yname, "%s" % yunits) 
    18061806            if self.yLabel == "y": 
    18071807                item.transformY(transform.toX, transform.errToX) 
     
    18221822                item.transformY(transform.toYX2, transform.errToYX2) 
    18231823                xunits = convert_unit(2, self.xaxis_unit) 
    1824                 self.graph._yaxis_transformed("%s \ \ %s^{2}" % (yname, xname), 
     1824                self.graph._yaxis_transformed(r"%s \ \ %s^2" % (yname, xname), 
    18251825                                              "%s%s" % (yunits, xunits)) 
    18261826            if self.yLabel == "y*x^(4)": 
    18271827                item.transformY(transform.toYX4, transform.errToYX4) 
    18281828                xunits = convert_unit(4, self.xaxis_unit) 
    1829                 self.graph._yaxis_transformed("%s \ \ %s^{4}" % (yname, xname), 
     1829                self.graph._yaxis_transformed(r"%s \ \ %s^4" % (yname, xname), 
    18301830                                              "%s%s" % (yunits, xunits)) 
    18311831            if self.yLabel == "1/sqrt(y)": 
     
    18331833                                transform.errOneOverSqrtX) 
    18341834                yunits = convert_unit(-0.5, yunits) 
    1835                 self.graph._yaxis_transformed("1/\sqrt{%s}" % yname, 
     1835                self.graph._yaxis_transformed(r"1/\sqrt{%s}" % yname, 
    18361836                                              "%s" % yunits) 
    18371837            if self.yLabel == "ln(y*x)": 
    18381838                item.transformY(transform.toLogXY, transform.errToLogXY) 
    1839                 self.graph._yaxis_transformed("\ln{(%s \ \ %s)}" % (yname, xname), 
     1839                self.graph._yaxis_transformed(r"\ln(%s \ \ %s)" % (yname, xname), 
    18401840                                              "%s%s" % (yunits, self.xaxis_unit)) 
    18411841            if self.yLabel == "ln(y*x^(2))": 
    18421842                item.transformY(transform.toLogYX2, transform.errToLogYX2) 
    18431843                xunits = convert_unit(2, self.xaxis_unit) 
    1844                 self.graph._yaxis_transformed("\ln (%s \ \ %s^{2})" % (yname, xname), 
     1844                self.graph._yaxis_transformed(r"\ln(%s \ \ %s^2)" % (yname, xname), 
    18451845                                              "%s%s" % (yunits, xunits)) 
    18461846            if self.yLabel == "ln(y*x^(4))": 
    18471847                item.transformY(transform.toLogYX4, transform.errToLogYX4) 
    18481848                xunits = convert_unit(4, self.xaxis_unit) 
    1849                 self.graph._yaxis_transformed("\ln (%s \ \ %s^{4})" % (yname, xname), 
     1849                self.graph._yaxis_transformed(r"\ln(%s \ \ %s^4)" % (yname, xname), 
    18501850                                              "%s%s" % (yunits, xunits)) 
    18511851            if self.yLabel == "log10(y*x^(4))": 
     
    18531853                xunits = convert_unit(4, self.xaxis_unit) 
    18541854                _yscale = 'log' 
    1855                 self.graph._yaxis_transformed("%s \ \ %s^{4}" % (yname, xname), 
     1855                self.graph._yaxis_transformed(r"%s \ \ %s^4" % (yname, xname), 
    18561856                                              "%s%s" % (yunits, xunits)) 
    18571857            item.transformView() 
     
    18971897        # Saving value to redisplay in Fit Dialog when it is opened again 
    18981898        self.Avalue, self.Bvalue, self.ErrAvalue, \ 
    1899                       self.ErrBvalue, self.Chivalue = func 
     1899            self.ErrBvalue, self.Chivalue = func 
    19001900        self.xminView = xminView 
    19011901        self.xmaxView = xmaxView 
  • src/sas/sasgui/plottools/canvas.py

    r5251ec6 r34f23c8  
    5353        ppw = 1 
    5454        pph = 1 
    55     (pgw, _) = self.GetPageSizePixels()  # page size in pixels 
    56     (dcw, _) = dc.GetSize() 
    57     (grw, _) = self.canvas.GetSizeTuple() 
     55    pgw, _ = self.GetPageSizePixels()  # page size in pixels 
     56    dcw, _ = dc.GetSize() 
     57    grw, _ = self.canvas.GetSize() 
    5858 
    5959    # save current figure dpi resolution and bg color, 
     
    152152        Render after a delay if no other render requests have been made. 
    153153        """ 
    154         self.panel.subplot.grid(self.panel.grid_on) 
    155         if self.panel.legend is not None and self.panel.legend_pos_loc: 
    156             self.panel.legend._loc = self.panel.legend_pos_loc 
     154        if self.panel is not None: 
     155            # TODO: grid/panel manip doesn't belong here 
     156            self.panel.subplot.grid(self.panel.grid_on) 
     157            if self.panel.legend is not None and self.panel.legend_pos_loc: 
     158                self.panel.legend._loc = self.panel.legend_pos_loc 
    157159        self.idletimer.Restart(5, *args, **kwargs)  # Delay by 5 ms 
    158160 
  • src/sas/sasgui/plottools/toolbar.py

    rcb64d86 r34f23c8  
    158158        """ 
    159159        _dc = self.GetDC() 
    160         (_dcX, _dcY) = _dc.GetSizeTuple() 
    161         (_bmpX,_bmpY) = self.canvas.GetSize() 
     160        _dcX, _dcY = _dc.GetSize() 
     161        _bmpX, _bmpY = self.canvas.GetSize() 
    162162        _scale = min(_dcX/_bmpX, _dcY/_bmpY) 
    163163        _dc.SetUserScale(_scale, _scale) 
Note: See TracChangeset for help on using the changeset viewer.