Changeset 3770

Show
Ignore:
Timestamp:
05/10/07 12:33:01 (6 years ago)
Author:
DrewCormier
Message:

additional support for write buffer button

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • experimental/write_to_file/trunk/write_to_file/write_to_file.py

    r3769 r3770  
    3232 
    3333#generate wx ids for my wx controls 
    34 [wxID_MAINFRAME, wxID_SPLITTERWINDOW1, wxID_WRITEPACKETBTN, wxID_IFILENAMEEDITOR, wxID_QFILENAMEEDITOR, wxID_IFILESTATICTEXT,wxID_QFILESTATICTEXT] = [wx.NewId() for _init_ctrls in range(7)] 
     34[wxID_MAINFRAME, wxID_SPLITTERWINDOW1, wxID_WRITEPACKETBTN, wxID_WRITEBUFFERBTN, wxID_IFILENAMEEDITOR, wxID_QFILENAMEEDITOR, wxID_IFILESTATICTEXT,wxID_QFILESTATICTEXT] = [wx.NewId() for _init_ctrls in range(8)] 
    3535 
    3636 
     
    3939 
    4040        self._init_ctrls(parent) 
     41 
     42        self.I_data = [] 
     43        self.Q_data = [] 
    4144          
    4245        self.parent = parent 
     
    7477    def _init_ctrls(self, prnt): 
    7578        wx.Frame.__init__(self, id=wxID_MAINFRAME, name='', parent=prnt, 
    76               pos=wx.Point(530, 570), size=wx.Size(520, 270), 
     79              pos=wx.Point(530, 680), size=wx.Size(520, 270), 
    7780              style=wx.DEFAULT_FRAME_STYLE, title='Arbitrary Waveform Generator') 
    7881 
     
    8588        self.WritePacketBtn = wx.Button(id=wxID_WRITEPACKETBTN, label='Write Packet', 
    8689              name='WritePacketBtn', parent=self.splitterWindow1, pos=wx.Point(155, 150), 
    87               size=wx.Size(145, 50)) 
     90              size=wx.Size(165, 50)) 
    8891        self.WritePacketBtn.SetFont(wx.Font(16, wx.SWISS, wx.NORMAL, wx.BOLD, False)) 
    8992        self.WritePacketBtn.SetBackgroundColour("green") 
    9093        self.WritePacketBtn.Bind(wx.EVT_BUTTON, self.OnWritePacketBtnButton, 
    9194              id=wxID_WRITEPACKETBTN) 
    92   
     95 
     96        self.WriteBufferBtn = wx.Button(id=wxID_WRITEBUFFERBTN, label='Write BUFFER', 
     97              name='WriteBufferBtn', parent=self.splitterWindow1, pos=wx.Point(155, 210), 
     98              size=wx.Size(165, 50)) 
     99        self.WriteBufferBtn.SetFont(wx.Font(16, wx.SWISS, wx.NORMAL, wx.BOLD, False)) 
     100        self.WriteBufferBtn.SetBackgroundColour("green") 
     101        self.WriteBufferBtn.Bind(wx.EVT_BUTTON, self.OnWriteBufferBtnButton, 
     102              id=wxID_WRITEBUFFERBTN) 
     103 
    93104        ##### 
    94105        ## if you want an image on the button 
     
    139150        open_file.close() 
    140151 
     152    def OnWriteBufferBtnButton(self,event): 
     153        #get the file names from the file name editors in the GUI 
     154        self.i_file_name = self.iFileNameEditor.GetLineText(0) 
     155        self.q_file_name = self.qFileNameEditor.GetLineText(0) 
     156 
     157        #write the data out 
     158        open_file = open(self.i_file_name, 'w')   #open the file for writing 
     159        open_file.write(str(self.I_data)) 
     160        open_file.close() 
     161 
     162        open_file = open(self.q_file_name, 'w')   #open the file for writing 
     163        open_file.write(str(self.Q_data)) 
     164        open_file.close() 
    141165 
    142166    def OnFileExit(self, event):