- Timestamp:
- Jul 2, 2014 2:20:23 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/GSASIIgrid.py ¶
r1402 r1403 135 135 ] = [wx.NewId() for item in range(9)] 136 136 137 [ wxID_ SAVESEQSEL,wxID_SAVESEQSELCSV,wxID_PLOTSEQSEL,137 [ wxID_RENAMESEQSEL,wxID_SAVESEQSEL,wxID_SAVESEQSELCSV,wxID_PLOTSEQSEL, 138 138 wxADDSEQVAR,wxDELSEQVAR,wxEDITSEQVAR, 139 139 wxADDPARFIT,wxDELPARFIT,wxEDITPARFIT,wxDOPARFIT, 140 ] = [wx.NewId() for item in range(1 0)]140 ] = [wx.NewId() for item in range(11)] 141 141 142 142 [ wxID_MODELCOPY,wxID_MODELFIT,wxID_MODELADD,wxID_ELEMENTADD,wxID_ELEMENTDELETE, … … 1470 1470 ''' 1471 1471 return self.value 1472 1473 ################################################################################ 1474 class MultiStringDialog(wx.Dialog): 1475 '''Dialog to obtain a multi string values from user 1476 1477 :param wx.Frame parent: name of parent frame 1478 :param str title: title string for dialog 1479 :param str prompts: strings to tell use what they are inputting 1480 :param str values: default input values, if any 1481 ''' 1482 def __init__(self,parent,title,prompts,values=[]): #,size=(200,-1)? 1483 1484 wx.Dialog.__init__(self,parent,wx.ID_ANY,title, 1485 pos=wx.DefaultPosition, 1486 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) 1487 self.values = values 1488 self.prompts = prompts 1489 self.CenterOnParent() 1490 self.panel = wx.Panel(self) 1491 mainSizer = wx.BoxSizer(wx.VERTICAL) 1492 promptSizer = wx.FlexGridSizer(0,2,5,5) 1493 self.Indx = {} 1494 for prompt,value in zip(prompts,values): 1495 promptSizer.Add(wx.StaticText(self.panel,-1,prompt),0,WACV) 1496 valItem = wx.TextCtrl(self.panel,-1,value=value,style=wx.TE_PROCESS_ENTER) 1497 self.Indx[valItem.GetId()] = prompt 1498 valItem.Bind(wx.EVT_TEXT,self.newValue) 1499 promptSizer.Add(valItem,0,WACV) 1500 mainSizer.Add(promptSizer,0) 1501 btnsizer = wx.StdDialogButtonSizer() 1502 OKbtn = wx.Button(self.panel, wx.ID_OK) 1503 OKbtn.SetDefault() 1504 btnsizer.AddButton(OKbtn) 1505 btn = wx.Button(self.panel, wx.ID_CANCEL) 1506 btnsizer.AddButton(btn) 1507 btnsizer.Realize() 1508 mainSizer.Add(btnsizer,0,wx.ALIGN_CENTER) 1509 self.panel.SetSizer(mainSizer) 1510 self.panel.Fit() 1511 self.Fit() 1512 1513 def newValue(self,event): 1514 Obj = event.GetEventObject() 1515 item = self.Indx[Obj.GetId()] 1516 id = self.prompts.index(item) 1517 self.values[id] = Obj.GetValue() 1518 1519 def Show(self): 1520 '''Use this method after creating the dialog to post it 1521 :returns: True if the user pressed OK; False if the User pressed Cancel 1522 ''' 1523 if self.ShowModal() == wx.ID_OK: 1524 return True 1525 else: 1526 return False 1527 1528 def GetValues(self): 1529 '''Use this method to get the value entered by the user 1530 :returns: string entered by user 1531 ''' 1532 return self.values 1472 1533 1473 1534 ################################################################################ … … 2541 2602 self.SequentialFile = wx.Menu(title='') 2542 2603 self.SequentialMenu.Append(menu=self.SequentialFile, title='Selected Cols') 2604 self.SequentialFile.Append(id=wxID_RENAMESEQSEL, kind=wx.ITEM_NORMAL,text='Rename', 2605 help='Rename selected sequential refinement columns') 2543 2606 self.SequentialFile.Append(id=wxID_SAVESEQSEL, kind=wx.ITEM_NORMAL,text='Save as text', 2544 2607 help='Save selected sequential refinement results as a text file') … … 3755 3818 'No columns or rows selected in table. Click on row or column labels to select fields for plotting.' 3756 3819 ) 3820 3821 def OnRenameSelSeq(event): 3822 cols = sorted(G2frame.dataDisplay.GetSelectedCols()) # ignore selection order 3823 colNames = [G2frame.SeqTable.GetColLabelValue(c) for c in cols] 3824 newNames = colNames[:] 3825 for i,name in enumerate(colNames): 3826 if name in variableLabels: 3827 newNames[i] = variableLabels[name] 3828 if not cols: 3829 G2frame.ErrorDialog('Select columns', 3830 'No columns selected in table. Click on column labels to select fields for rename.') 3831 return 3832 dlg = MultiStringDialog(G2frame.dataDisplay,'Set column names',colNames,newNames) 3833 if dlg.Show(): 3834 newNames = dlg.GetValues() 3835 variableLabels.update(dict(zip(colNames,newNames))) 3836 dlg.Destroy() 3837 UpdateSeqResults(G2frame,data,G2frame.dataDisplay.GetSize()) # redisplay variables 3838 G2plt.PlotSelectedSequence(G2frame,cols,GetColumnInfo,SelectXaxis) 3757 3839 3758 3840 def OnSaveSelSeqCSV(event): … … 4256 4338 return u'\u03c3 = '+str(colSigs[col][row]) 4257 4339 return '' 4340 4258 4341 def GridColLblToolTip(col): 4259 4342 '''Define a tooltip for a column. This will be the user-entered value … … 4265 4348 var = colLabels[col] 4266 4349 return variableLabels.get(var,G2obj.fmtVarDescr(var)) 4350 4267 4351 def SetLabelString(event): 4268 4352 '''Define or edit the label for a column in the table, to be used … … 4278 4362 if dlg.Show(): 4279 4363 variableLabels[var] = dlg.GetValue() 4280 print variableLabels4281 4364 dlg.Destroy() 4282 4365 … … 4372 4455 Status = G2frame.dataFrame.CreateStatusBar() 4373 4456 Status.SetStatusText('') 4457 G2frame.dataFrame.Bind(wx.EVT_MENU, OnRenameSelSeq, id=wxID_RENAMESEQSEL) 4374 4458 G2frame.dataFrame.Bind(wx.EVT_MENU, OnSaveSelSeq, id=wxID_SAVESEQSEL) 4375 4459 G2frame.dataFrame.Bind(wx.EVT_MENU, OnSaveSelSeqCSV, id=wxID_SAVESEQSELCSV) -
TabularUnified trunk/GSASIIplot.py ¶
r1402 r1403 2407 2407 number (or None) as the X-axis selection 2408 2408 ''' 2409 global Title,xLabel,yLabel 2410 xLabel = yLabel = Title = '' 2409 2411 def OnMotion(event): 2410 2412 if event.xdata and event.ydata: #avoid out of frame errors … … 2415 2417 2416 2418 def OnKeyPress(event): 2419 global Title,xLabel,yLabel 2417 2420 if event.key == 's': 2418 2421 G2frame.seqXaxis = G2frame.seqXselect() 2419 2422 Draw() 2423 elif event.key == 't': 2424 dlg = G2gd.MultiStringDialog(G2frame,'Set titles & labels',[' Title ',' x-Label ',' y-Label '], 2425 [Title,xLabel,yLabel]) 2426 if dlg.Show(): 2427 Title,xLabel,yLabel = dlg.GetValues() 2428 dlg.Destroy() 2429 Draw() 2420 2430 2421 2431 def Draw(): 2432 global Title,xLabel,yLabel 2422 2433 Page.SetFocus() 2423 G2frame.G2plotNB.status.SetStatusText('press s to select X axis ',1)2434 G2frame.G2plotNB.status.SetStatusText('press s to select X axis, t to change titles',1) 2424 2435 Plot.clear() 2425 2436 if G2frame.seqXaxis is not None: … … 2446 2457 2447 2458 Plot.legend(loc='best') 2448 Plot.set_ylabel('Parameter values') 2449 Plot.set_xlabel(xName) 2459 if Title: 2460 Plot.set_title(Title) 2461 else: 2462 Plot.set_title('') 2463 if xLabel: 2464 Plot.set_xlabel(xLabel) 2465 else: 2466 Plot.set_xlabel(xName) 2467 if yLabel: 2468 Plot.set_ylabel(yLabel) 2469 else: 2470 Plot.set_ylabel('Parameter values') 2450 2471 Page.canvas.draw() 2451 2472 … … 2473 2494 Page.canvas.mpl_connect('key_press_event', OnKeyPress) 2474 2495 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 2475 Page.Choice = ['s to select plot x-axis',]2496 Page.Choice = ['s - select x-axis','t - change titles',] 2476 2497 Page.keyPress = OnKeyPress 2477 2498 Page.seqYaxisList = ColumnList
Note: See TracChangeset
for help on using the changeset viewer.