Changeset 67fb83b in sasview


Ignore:
Timestamp:
Jul 12, 2012 6:44:35 AM (12 years ago)
Author:
Kieran Campbell <kieranrcampbell@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
5e5704d
Parents:
4f0376d
Message:

A gift for pylint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansguiframe/src/sans/guiframe/local_perspectives/plotting/graphAppearance.py

    r8a687cfd r67fb83b  
    1818 
    1919import wx 
    20 from matplotlib.font_manager import FontProperties 
    2120from danse.common.plottools.SimpleFont import SimpleFont 
    2221 
     
    2625class graphAppearance(wx.Frame): 
    2726 
    28     def __init__(self,parent,title,legend=True): 
    29         super(graphAppearance,self).__init__(parent, title=title,size=(520,435)) 
     27    def __init__(self, parent, title, legend=True): 
     28        super(graphAppearance, self).__init__(parent, title=title, size=(520, 435)) 
    3029 
    3130        self.legend = legend 
     
    5655        if self.legend: 
    5756            legendLocText = wx.StaticText(panel, label='Legend location: ') 
    58             self.legendLocCombo = wx.ComboBox(panel,style = wx.CB_READONLY, size=(180,-1)) 
     57            self.legend_loc_combo = wx.ComboBox(panel,style = wx.CB_READONLY, size=(180,-1)) 
    5958            self.fillLegendLocs() 
    6059        else: 
    61             self.legendLocCombo = None 
    62  
    63  
    64         if self.legend: 
    65             self.toggleLegend = wx.CheckBox(panel, label='Toggle legend on/off') 
     60            self.legend_loc_combo = None 
     61 
     62 
     63        if self.legend: 
     64            self.toggle_legend = wx.CheckBox(panel, label='Toggle legend on/off') 
    6665        else: 
    67             self.toggleLegend = None 
    68  
    69         self.toggleGrid = wx.CheckBox(panel, label='Toggle grid on/off') 
     66            self.toggle_legend = None 
     67 
     68        self.toggle_grid = wx.CheckBox(panel, label='Toggle grid on/off') 
    7069 
    7170         
    72         xStaticBox = wx.StaticBox(panel,-1, 'x-axis label') 
    73         xStaticBoxSizer = wx.StaticBoxSizer(xStaticBox, wx.VERTICAL) 
    74         yStaticBox = wx.StaticBox(panel,-1, 'y-axis label') 
    75         yStaticBoxSizer = wx.StaticBoxSizer(yStaticBox, wx.VERTICAL) 
    76  
    77  
    78         xaxisLabel = wx.StaticText(panel, label='X-axis: ') 
    79         yaxisLabel = wx.StaticText(panel, label='Y-axis: ') 
    80         unitLabel1 = wx.StaticText(panel, label='Units: ') 
    81         unitLabel2 = wx.StaticText(panel, label='Units: ') 
    82  
    83         self.xaxisText = wx.TextCtrl(panel,-1,"",size=(220,-1)) 
    84         self.yaxisText = wx.TextCtrl(panel,-1,"",size=(220,-1)) 
    85  
    86         self.xaxisUnitText = wx.TextCtrl(panel,-1,"",size=(100,-1)) 
    87         self.yaxisUnitText = wx.TextCtrl(panel,-1,"",size=(100,-1)) 
     71        xstatic_box = wx.StaticBox(panel, -1, 'x-axis label') 
     72        xstatic_box_sizer = wx.StaticBoxSizer(xstatic_box, wx.VERTICAL) 
     73        ystatic_box = wx.StaticBox(panel, -1, 'y-axis label') 
     74        ystatic_box_sizer = wx.StaticBoxSizer(ystatic_box, wx.VERTICAL) 
     75 
     76 
     77        xaxis_label = wx.StaticText(panel, label='X-axis: ') 
     78        yaxis_label = wx.StaticText(panel, label='Y-axis: ') 
     79        unitlabel_1 = wx.StaticText(panel, label='Units: ') 
     80        unitlabel_2 = wx.StaticText(panel, label='Units: ') 
     81 
     82        self.xaxis_text = wx.TextCtrl(panel, -1, "",size=(220, -1)) 
     83        self.yaxis_text = wx.TextCtrl(panel, -1, "",size=(220, -1)) 
     84 
     85        self.xaxis_unit_text = wx.TextCtrl(panel, -1,"",size=(100, -1)) 
     86        self.yaxis_unit_text = wx.TextCtrl(panel, -1,"",size=(100, -1)) 
    8887 
    8988 
    9089 
    9190        xcolorLabel = wx.StaticText(panel, label='Font color: ') 
    92         self.xfontColor = wx.ComboBox(panel,size=(100,-1),style=wx.CB_READONLY) 
    93         self.xfillColors() 
    94         self.xfontColor.SetSelection(0) 
    95         xfontButton = wx.Button(panel, label='Font') 
    96         xfontButton.Bind(wx.EVT_BUTTON,self.onxFont) 
     91        self.xfont_color = wx.ComboBox(panel, size=(100, -1), style=wx.CB_READONLY) 
     92        self.xfill_colors() 
     93        self.xfont_color.SetSelection(0) 
     94        xfont_button = wx.Button(panel, label='Font') 
     95        xfont_button.Bind(wx.EVT_BUTTON, self.onxFont) 
    9796 
    9897        ycolorLabel = wx.StaticText(panel, label='Font color: ') 
    99         self.yfontColor = wx.ComboBox(panel,size=(100,-1),style=wx.CB_READONLY) 
    100         self.yfillColors() 
    101         self.yfontColor.SetSelection(0) 
    102         yfontButton = wx.Button(panel, label='Font') 
    103         yfontButton.Bind(wx.EVT_BUTTON,self.onyFont) 
     98        self.yfont_color = wx.ComboBox(panel, size=(100, -1),style=wx.CB_READONLY) 
     99        self.yfill_colors() 
     100        self.yfont_color.SetSelection(0) 
     101        yfont_button = wx.Button(panel, label='Font') 
     102        yfont_button.Bind(wx.EVT_BUTTON, self.onyFont) 
    104103 
    105104         
    106105 
    107         self.cancelButton = wx.Button(panel, label='Cancel') 
    108         self.okButton = wx.Button(panel, label='OK') 
    109  
    110         self.cancelButton.Bind(wx.EVT_BUTTON,self.onCancel) 
    111         self.okButton.Bind(wx.EVT_BUTTON,self.onOK) 
    112  
    113  
    114         xhbox1.Add(xaxisLabel,flag= wx.ALL | wx.EXPAND  | wx.ALIGN_LEFT,border=10) 
    115         xhbox1.Add(self.xaxisText,flag=wx.ALL | wx.EXPAND  | wx.ALIGN_LEFT,border=10) 
    116         xhbox1.Add(unitLabel1,flag=wx.ALL | wx.EXPAND  | wx.ALIGN_RIGHT,border=10) 
    117         xhbox1.Add(self.xaxisUnitText, flag=wx.ALL | wx.EXPAND  | wx.ALIGN_RIGHT,border=10) 
    118  
    119         yhbox1.Add(yaxisLabel,flag= wx.ALL | wx.EXPAND  | wx.ALIGN_LEFT,border=10) 
    120         yhbox1.Add(self.yaxisText,flag=wx.ALL | wx.EXPAND  | wx.ALIGN_LEFT,border=10) 
    121         yhbox1.Add(unitLabel2,flag=wx.ALL | wx.EXPAND  | wx.ALIGN_RIGHT,border=10) 
    122         yhbox1.Add(self.yaxisUnitText, flag=wx.ALL | wx.EXPAND  | wx.ALIGN_RIGHT,border=10) 
    123  
    124         xhbox2.Add(xcolorLabel,flag=wx.ALL | wx.ALIGN_RIGHT, border=10) 
    125         xhbox2.Add(self.xfontColor,flag=wx.ALL | wx.ALIGN_RIGHT, border=5) 
    126         xhbox2.Add(xfontButton,flag=wx.ALL | wx.ALIGN_RIGHT, border=5) 
    127  
    128         yhbox2.Add(ycolorLabel,flag=wx.ALL | wx.ALIGN_RIGHT, border=10) 
    129         yhbox2.Add(self.yfontColor,flag=wx.ALL | wx.ALIGN_RIGHT, border=5) 
    130         yhbox2.Add(yfontButton,flag=wx.ALL | wx.ALIGN_RIGHT, border=5) 
     106        self.cancel_button = wx.Button(panel, label='Cancel') 
     107        self.ok_button = wx.Button(panel, label='OK') 
     108 
     109        self.cancel_button.Bind(wx.EVT_BUTTON, self.onCancel) 
     110        self.ok_button.Bind(wx.EVT_BUTTON, self.on_ok) 
     111 
     112 
     113        xhbox1.Add(xaxis_label, flag= wx.ALL | wx.EXPAND  | wx.ALIGN_LEFT, border=10) 
     114        xhbox1.Add(self.xaxis_text, flag=wx.ALL | wx.EXPAND  | wx.ALIGN_LEFT, border=10) 
     115        xhbox1.Add(unitlabel_1, flag=wx.ALL | wx.EXPAND  | wx.ALIGN_RIGHT, border=10) 
     116        xhbox1.Add(self.xaxis_unit_text, flag=wx.ALL | wx.EXPAND  | wx.ALIGN_RIGHT, border=10) 
     117 
     118        yhbox1.Add(yaxis_label, flag= wx.ALL | wx.EXPAND  | wx.ALIGN_LEFT, border=10) 
     119        yhbox1.Add(self.yaxis_text, flag=wx.ALL | wx.EXPAND  | wx.ALIGN_LEFT, border=10) 
     120        yhbox1.Add(unitlabel_2, flag=wx.ALL | wx.EXPAND  | wx.ALIGN_RIGHT, border=10) 
     121        yhbox1.Add(self.yaxis_unit_text, flag=wx.ALL | wx.EXPAND  | wx.ALIGN_RIGHT, border=10) 
     122 
     123        xhbox2.Add(xcolorLabel, flag=wx.ALL | wx.ALIGN_RIGHT, border=10) 
     124        xhbox2.Add(self.xfont_color, flag=wx.ALL | wx.ALIGN_RIGHT, border=5) 
     125        xhbox2.Add(xfont_button, flag=wx.ALL | wx.ALIGN_RIGHT, border=5) 
     126 
     127        yhbox2.Add(ycolorLabel, flag=wx.ALL | wx.ALIGN_RIGHT, border=10) 
     128        yhbox2.Add(self.yfont_color, flag=wx.ALL | wx.ALIGN_RIGHT, border=5) 
     129        yhbox2.Add(yfont_button, flag=wx.ALL | wx.ALIGN_RIGHT, border=5) 
    131130 
    132131        if self.legend: 
    133132            hbox1.Add(legendLocText, flag =  wx.ALL | wx.EXPAND  | wx.ALIGN_LEFT, border=5) 
    134             hbox1.Add(self.legendLocCombo, flag =  wx.ALL | wx.EXPAND  | wx.ALIGN_LEFT, border=5) 
    135  
    136         if self.legend: 
    137             hbox1.Add((5,-1)) 
    138             hbox1.Add(self.toggleLegend, flag = wx.ALL | wx.EXPAND  | wx.ALIGN_LEFT, border=5) 
    139  
    140         hbox2.Add(self.okButton, flag = wx.ALL | wx.ALIGN_RIGHT, border=5) 
    141         hbox2.Add(self.cancelButton, flag = wx.ALL | wx.ALIGN_RIGHT, border=5) 
    142         hbox2.Add((15,-1)) 
    143  
    144         xStaticBoxSizer.Add(xhbox1,flag= wx.EXPAND ,border=5) 
    145         xStaticBoxSizer.Add(xhbox2, flag=wx.ALL | wx.ALIGN_RIGHT, border=5) 
    146         yStaticBoxSizer.Add(yhbox1,flag= wx.EXPAND ,border=5) 
    147         yStaticBoxSizer.Add(yhbox2, flag=wx.ALL | wx.ALIGN_RIGHT, border=5) 
    148  
    149         vbox.Add((-1,20)) 
     133            hbox1.Add(self.legend_loc_combo, flag =  wx.ALL | wx.EXPAND  | wx.ALIGN_LEFT, border=5) 
     134 
     135        if self.legend: 
     136            hbox1.Add((5, -1)) 
     137            hbox1.Add(self.toggle_legend, flag = wx.ALL | wx.EXPAND  | wx.ALIGN_LEFT, border=5) 
     138 
     139        hbox2.Add(self.ok_button, flag = wx.ALL | wx.ALIGN_RIGHT, border=5) 
     140        hbox2.Add(self.cancel_button, flag = wx.ALL | wx.ALIGN_RIGHT, border=5) 
     141        hbox2.Add((15, -1)) 
     142 
     143        xstatic_box_sizer.Add(xhbox1, flag= wx.EXPAND , border=5) 
     144        xstatic_box_sizer.Add(xhbox2, flag=wx.ALL | wx.ALIGN_RIGHT, border=5) 
     145        ystatic_box_sizer.Add(yhbox1, flag= wx.EXPAND, border=5) 
     146        ystatic_box_sizer.Add(yhbox2, flag=wx.ALL | wx.ALIGN_RIGHT, border=5) 
     147 
     148        vbox.Add((-1, 20)) 
    150149        vbox.Add(hbox1, flag = wx.EXPAND | wx.ALL, border=5) 
    151         vbox.Add(xStaticBoxSizer, flag = wx.ALL | wx.EXPAND, border=10) 
    152         vbox.Add(yStaticBoxSizer, flag = wx.ALL | wx.EXPAND, border=10) 
    153  
    154         vbox.Add(self.toggleGrid, flag = wx.ALIGN_RIGHT | wx.RIGHT, border=20) 
     150        vbox.Add(xstatic_box_sizer, flag = wx.ALL | wx.EXPAND, border=10) 
     151        vbox.Add(ystatic_box_sizer, flag = wx.ALL | wx.EXPAND, border=10) 
     152 
     153        vbox.Add(self.toggle_grid, flag = wx.ALIGN_RIGHT | wx.RIGHT, border=20) 
    155154        vbox.Add(hbox2, flag = wx.ALIGN_RIGHT | wx.ALL , border=5) 
    156155 
     
    158157        panel.SetSizer(vbox) 
    159158 
    160     def xfillColors(self): 
    161         list = COLOR 
    162         for idx in range(len(list)): 
    163             self.xfontColor.Append(list[idx],idx) 
    164  
    165     def yfillColors(self): 
    166         list = COLOR 
    167         for idx in range(len(list)): 
    168             self.yfontColor.Append(list[idx],idx) 
    169  
    170     def onxFont(self,e): 
     159    def xfill_colors(self): 
     160        c_list = COLOR 
     161        for idx in range(len(c_list)): 
     162            self.xfont_color.Append(c_list[idx], idx) 
     163 
     164    def yfill_colors(self): 
     165        c_list = COLOR 
     166        for idx in range(len(c_list)): 
     167            self.yfont_color.Append(c_list[idx], idx) 
     168 
     169    def onxFont(self, e): 
    171170        title = 'Modify x axis font' 
    172171 
    173         fonty = SimpleFont(self,wx.NewId(),title) 
     172        fonty = SimpleFont(self, wx.NewId(), title) 
    174173        fonty.set_default_font(self.xfont) 
    175174        if(fonty.ShowModal() == wx.ID_OK): 
    176175            self.xfont = fonty.get_font() 
    177176 
    178     def onyFont(self,e): 
     177    def onyFont(self, e): 
    179178        title = 'Modify y axis font' 
    180         fonty = SimpleFont(self,wx.NewId(),title) 
     179        fonty = SimpleFont(self, wx.NewId(), title) 
    181180        fonty.set_default_font(self.yfont) 
    182181        if(fonty.ShowModal() == wx.ID_OK): 
    183182            self.yfont = fonty.get_font() 
    184183 
    185     def onOK(self,e): 
     184    def on_ok(self, e): 
    186185        self.Close() 
    187186 
     
    227226 
    228227        # for label in reversed(labels): 
    229         #     self.legendLocCombo.Append(label) 
     228        #     self.legend_loc_combo.Append(label) 
    230229        for label in self.get_loc_label(): 
    231             self.legendLocCombo.Append(label) 
     230            self.legend_loc_combo.Append(label) 
    232231 
    233232 
     
    235234                    xaxis_font,yaxis_font,legend_loc, 
    236235                    xcolor,ycolor): 
    237         self.toggleGrid.SetValue(grid) 
    238         if self.legend: 
    239             self.toggleLegend.SetValue(legend) 
    240         self.xaxisText.SetValue(xlab) 
    241         self.yaxisText.SetValue(ylab) 
    242         self.xaxisUnitText.SetValue(xunit) 
    243         self.yaxisUnitText.SetValue(yunit) 
     236        self.toggle_grid.SetValue(grid) 
     237        if self.legend: 
     238            self.toggle_legend.SetValue(legend) 
     239        self.xaxis_text.SetValue(xlab) 
     240        self.yaxis_text.SetValue(ylab) 
     241        self.xaxis_unit_text.SetValue(xunit) 
     242        self.yaxis_unit_text.SetValue(yunit) 
    244243        self.xfont = xaxis_font 
    245244        self.yfont = yaxis_font 
    246245 
    247246        if not xcolor: 
    248             self.xfontColor.SetSelection(0) 
     247            self.xfont_color.SetSelection(0) 
    249248        else: 
    250             self.xfontColor.SetStringSelection(xcolor) 
     249            self.xfont_color.SetStringSelection(xcolor) 
    251250 
    252251        if not ycolor: 
    253             self.yfontColor.SetSelection(0) 
     252            self.yfont_color.SetSelection(0) 
    254253        else: 
    255             self.yfontColor.SetStringSelection(ycolor) 
     254            self.yfont_color.SetStringSelection(ycolor) 
    256255             
    257256 
    258257        if self.legend: 
    259             self.legendLocCombo.SetStringSelection(legend_loc) 
     258            self.legend_loc_combo.SetStringSelection(legend_loc) 
    260259 
    261260 
    262261    # get whether grid is toggled on/off 
    263262    def get_togglegrid(self): 
    264         return self.toggleGrid.GetValue() 
     263        return self.toggle_grid.GetValue() 
    265264 
    266265    # get whether legend is toggled on/off 
    267266    def get_togglelegend(self): 
    268         return self.toggleLegend.GetValue() 
     267        return self.toggle_legend.GetValue() 
    269268 
    270269    # get x label 
    271270    def get_xlab(self): 
    272         return self.xaxisText.GetValue() 
     271        return self.xaxis_text.GetValue() 
    273272 
    274273    # get y label 
    275274    def get_ylab(self): 
    276         return self.yaxisText.GetValue() 
     275        return self.yaxis_text.GetValue() 
    277276 
    278277    # get x unit 
    279278    def get_xunit(self): 
    280         return self.xaxisUnitText.GetValue() 
     279        return self.xaxis_unit_text.GetValue() 
    281280 
    282281    # get y unit 
    283282    def get_yunit(self): 
    284         return self.yaxisUnitText.GetValue() 
     283        return self.yaxis_unit_text.GetValue() 
    285284 
    286285    # get legend location 
    287286    def get_legend_loc(self): 
    288         return self.get_loc_label()[self.legendLocCombo.GetStringSelection()] 
     287        return self.get_loc_label()[self.legend_loc_combo.GetStringSelection()] 
    289288 
    290289    # get x axis label color 
    291290    def get_xcolor(self): 
    292         return self.xfontColor.GetValue() 
     291        return self.xfont_color.GetValue() 
    293292 
    294293    # get y axis label color 
    295294    def get_ycolor(self): 
    296         return self.yfontColor.GetValue() 
     295        return self.yfont_color.GetValue() 
    297296 
    298297    # get x axis font (type is FontProperties) 
Note: See TracChangeset for help on using the changeset viewer.