Changeset 67fb83b in sasview
- Timestamp:
- Jul 12, 2012 8:44:35 AM (12 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/local_perspectives/plotting/graphAppearance.py
r8a687cfd r67fb83b 18 18 19 19 import wx 20 from matplotlib.font_manager import FontProperties21 20 from danse.common.plottools.SimpleFont import SimpleFont 22 21 … … 26 25 class graphAppearance(wx.Frame): 27 26 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)) 30 29 31 30 self.legend = legend … … 56 55 if self.legend: 57 56 legendLocText = wx.StaticText(panel, label='Legend location: ') 58 self.legend LocCombo = 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)) 59 58 self.fillLegendLocs() 60 59 else: 61 self.legend LocCombo = None62 63 64 if self.legend: 65 self.toggle Legend = 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') 66 65 else: 67 self.toggle Legend = None68 69 self.toggle Grid = 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') 70 69 71 70 72 x StaticBox = wx.StaticBox(panel,-1, 'x-axis label')73 x StaticBoxSizer = wx.StaticBoxSizer(xStaticBox, wx.VERTICAL)74 y StaticBox = wx.StaticBox(panel,-1, 'y-axis label')75 y StaticBoxSizer = wx.StaticBoxSizer(yStaticBox, wx.VERTICAL)76 77 78 xaxis Label = wx.StaticText(panel, label='X-axis: ')79 yaxis Label = wx.StaticText(panel, label='Y-axis: ')80 unit Label1 = wx.StaticText(panel, label='Units: ')81 unit Label2 = wx.StaticText(panel, label='Units: ')82 83 self.xaxis Text = wx.TextCtrl(panel,-1,"",size=(220,-1))84 self.yaxis Text = wx.TextCtrl(panel,-1,"",size=(220,-1))85 86 self.xaxis UnitText = wx.TextCtrl(panel,-1,"",size=(100,-1))87 self.yaxis UnitText = 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)) 88 87 89 88 90 89 91 90 xcolorLabel = wx.StaticText(panel, label='Font color: ') 92 self.xfont Color = wx.ComboBox(panel,size=(100,-1),style=wx.CB_READONLY)93 self.xfill Colors()94 self.xfont Color.SetSelection(0)95 xfont Button = wx.Button(panel, label='Font')96 xfont Button.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) 97 96 98 97 ycolorLabel = wx.StaticText(panel, label='Font color: ') 99 self.yfont Color = wx.ComboBox(panel,size=(100,-1),style=wx.CB_READONLY)100 self.yfill Colors()101 self.yfont Color.SetSelection(0)102 yfont Button = wx.Button(panel, label='Font')103 yfont Button.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) 104 103 105 104 106 105 107 self.cancel Button = wx.Button(panel, label='Cancel')108 self.ok Button = wx.Button(panel, label='OK')109 110 self.cancel Button.Bind(wx.EVT_BUTTON,self.onCancel)111 self.ok Button.Bind(wx.EVT_BUTTON,self.onOK)112 113 114 xhbox1.Add(xaxis Label,flag= wx.ALL | wx.EXPAND | wx.ALIGN_LEFT,border=10)115 xhbox1.Add(self.xaxis Text,flag=wx.ALL | wx.EXPAND | wx.ALIGN_LEFT,border=10)116 xhbox1.Add(unit Label1,flag=wx.ALL | wx.EXPAND | wx.ALIGN_RIGHT,border=10)117 xhbox1.Add(self.xaxis UnitText, flag=wx.ALL | wx.EXPAND | wx.ALIGN_RIGHT,border=10)118 119 yhbox1.Add(yaxis Label,flag= wx.ALL | wx.EXPAND | wx.ALIGN_LEFT,border=10)120 yhbox1.Add(self.yaxis Text,flag=wx.ALL | wx.EXPAND | wx.ALIGN_LEFT,border=10)121 yhbox1.Add(unit Label2,flag=wx.ALL | wx.EXPAND | wx.ALIGN_RIGHT,border=10)122 yhbox1.Add(self.yaxis UnitText, 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.xfont Color,flag=wx.ALL | wx.ALIGN_RIGHT, border=5)126 xhbox2.Add(xfont Button,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.yfont Color,flag=wx.ALL | wx.ALIGN_RIGHT, border=5)130 yhbox2.Add(yfont Button,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) 131 130 132 131 if self.legend: 133 132 hbox1.Add(legendLocText, flag = wx.ALL | wx.EXPAND | wx.ALIGN_LEFT, border=5) 134 hbox1.Add(self.legend LocCombo, flag = wx.ALL | wx.EXPAND | wx.ALIGN_LEFT, border=5)135 136 if self.legend: 137 hbox1.Add((5, -1))138 hbox1.Add(self.toggle Legend, flag = wx.ALL | wx.EXPAND | wx.ALIGN_LEFT, border=5)139 140 hbox2.Add(self.ok Button, flag = wx.ALL | wx.ALIGN_RIGHT, border=5)141 hbox2.Add(self.cancel Button, flag = wx.ALL | wx.ALIGN_RIGHT, border=5)142 hbox2.Add((15, -1))143 144 x StaticBoxSizer.Add(xhbox1,flag= wx.EXPAND ,border=5)145 x StaticBoxSizer.Add(xhbox2, flag=wx.ALL | wx.ALIGN_RIGHT, border=5)146 y StaticBoxSizer.Add(yhbox1,flag= wx.EXPAND ,border=5)147 y StaticBoxSizer.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)) 150 149 vbox.Add(hbox1, flag = wx.EXPAND | wx.ALL, border=5) 151 vbox.Add(x StaticBoxSizer, flag = wx.ALL | wx.EXPAND, border=10)152 vbox.Add(y StaticBoxSizer, flag = wx.ALL | wx.EXPAND, border=10)153 154 vbox.Add(self.toggle Grid, 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) 155 154 vbox.Add(hbox2, flag = wx.ALIGN_RIGHT | wx.ALL , border=5) 156 155 … … 158 157 panel.SetSizer(vbox) 159 158 160 def xfill Colors(self):161 list = COLOR162 for idx in range(len( list)):163 self.xfont Color.Append(list[idx],idx)164 165 def yfill Colors(self):166 list = COLOR167 for idx in range(len( list)):168 self.yfont Color.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): 171 170 title = 'Modify x axis font' 172 171 173 fonty = SimpleFont(self, wx.NewId(),title)172 fonty = SimpleFont(self, wx.NewId(), title) 174 173 fonty.set_default_font(self.xfont) 175 174 if(fonty.ShowModal() == wx.ID_OK): 176 175 self.xfont = fonty.get_font() 177 176 178 def onyFont(self, e):177 def onyFont(self, e): 179 178 title = 'Modify y axis font' 180 fonty = SimpleFont(self, wx.NewId(),title)179 fonty = SimpleFont(self, wx.NewId(), title) 181 180 fonty.set_default_font(self.yfont) 182 181 if(fonty.ShowModal() == wx.ID_OK): 183 182 self.yfont = fonty.get_font() 184 183 185 def on OK(self,e):184 def on_ok(self, e): 186 185 self.Close() 187 186 … … 227 226 228 227 # for label in reversed(labels): 229 # self.legend LocCombo.Append(label)228 # self.legend_loc_combo.Append(label) 230 229 for label in self.get_loc_label(): 231 self.legend LocCombo.Append(label)230 self.legend_loc_combo.Append(label) 232 231 233 232 … … 235 234 xaxis_font,yaxis_font,legend_loc, 236 235 xcolor,ycolor): 237 self.toggle Grid.SetValue(grid)238 if self.legend: 239 self.toggle Legend.SetValue(legend)240 self.xaxis Text.SetValue(xlab)241 self.yaxis Text.SetValue(ylab)242 self.xaxis UnitText.SetValue(xunit)243 self.yaxis UnitText.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) 244 243 self.xfont = xaxis_font 245 244 self.yfont = yaxis_font 246 245 247 246 if not xcolor: 248 self.xfont Color.SetSelection(0)247 self.xfont_color.SetSelection(0) 249 248 else: 250 self.xfont Color.SetStringSelection(xcolor)249 self.xfont_color.SetStringSelection(xcolor) 251 250 252 251 if not ycolor: 253 self.yfont Color.SetSelection(0)252 self.yfont_color.SetSelection(0) 254 253 else: 255 self.yfont Color.SetStringSelection(ycolor)254 self.yfont_color.SetStringSelection(ycolor) 256 255 257 256 258 257 if self.legend: 259 self.legend LocCombo.SetStringSelection(legend_loc)258 self.legend_loc_combo.SetStringSelection(legend_loc) 260 259 261 260 262 261 # get whether grid is toggled on/off 263 262 def get_togglegrid(self): 264 return self.toggle Grid.GetValue()263 return self.toggle_grid.GetValue() 265 264 266 265 # get whether legend is toggled on/off 267 266 def get_togglelegend(self): 268 return self.toggle Legend.GetValue()267 return self.toggle_legend.GetValue() 269 268 270 269 # get x label 271 270 def get_xlab(self): 272 return self.xaxis Text.GetValue()271 return self.xaxis_text.GetValue() 273 272 274 273 # get y label 275 274 def get_ylab(self): 276 return self.yaxis Text.GetValue()275 return self.yaxis_text.GetValue() 277 276 278 277 # get x unit 279 278 def get_xunit(self): 280 return self.xaxis UnitText.GetValue()279 return self.xaxis_unit_text.GetValue() 281 280 282 281 # get y unit 283 282 def get_yunit(self): 284 return self.yaxis UnitText.GetValue()283 return self.yaxis_unit_text.GetValue() 285 284 286 285 # get legend location 287 286 def get_legend_loc(self): 288 return self.get_loc_label()[self.legend LocCombo.GetStringSelection()]287 return self.get_loc_label()[self.legend_loc_combo.GetStringSelection()] 289 288 290 289 # get x axis label color 291 290 def get_xcolor(self): 292 return self.xfont Color.GetValue()291 return self.xfont_color.GetValue() 293 292 294 293 # get y axis label color 295 294 def get_ycolor(self): 296 return self.yfont Color.GetValue()295 return self.yfont_color.GetValue() 297 296 298 297 # get x axis font (type is FontProperties)
Note: See TracChangeset
for help on using the changeset viewer.