Changeset 3768

Show
Ignore:
Timestamp:
05/10/07 10:36:29 (6 years ago)
Author:
DrewCormier
Message:

file is now written when the button is pushed. this way when you close the tool you don't run into the problem of the tool being half way through writing a file.

Files:
1 modified

Legend:

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

    r3724 r3768  
    2121 
    2222    def pushPacket(self, I_data, Q_data): 
    23         #get the file names from the file name editors in the GUI 
    24         self.i_file_name = self.gui.iFileNameEditor.GetLineText(0) 
    25         self.q_file_name = self.gui.qFileNameEditor.GetLineText(0) 
    26  
    27         #write the data out 
    28         open_file = open(self.i_file_name, 'w')   #open the file for writing 
    29         open_file.write(str(I_data)) 
    30         open_file.close() 
    31  
    32         open_file = open(self.q_file_name, 'w')   #open the file for writing 
    33         open_file.write(str(Q_data)) 
    34         open_file.close() 
     23        '''Store the data to be written to file when the Write Packet button is bushed''' 
     24        self.gui.I_data = I_data 
     25        self.gui.Q_data = Q_data 
     26   
    3527 
    3628 
     
    4032 
    4133#generate wx ids for my wx controls 
    42 [wxID_MAINFRAME, wxID_SPLITTERWINDOW1, wxID_PUSHPACKETBTN, wxID_IFILENAMEEDITOR, wxID_QFILENAMEEDITOR, wxID_IFILESTATICTEXT,wxID_QFILESTATICTEXT] = [wx.NewId() for _init_ctrls in range(7)] 
     34[wxID_MAINFRAME, wxID_SPLITTERWINDOW1, wxID_WRITEPACKETBTN, wxID_IFILENAMEEDITOR, wxID_QFILENAMEEDITOR, wxID_IFILESTATICTEXT,wxID_QFILESTATICTEXT] = [wx.NewId() for _init_ctrls in range(7)] 
    4335 
    4436 
     
    9183              True, True, True, True)) 
    9284 
    93         self.PushPacketBtn = wx.Button(id=wxID_PUSHPACKETBTN, label='Do Nothing', 
    94               name='PushPacketBtn', parent=self.splitterWindow1, pos=wx.Point(155, 150), 
     85        self.WritePacketBtn = wx.Button(id=wxID_WRITEPACKETBTN, label='Write Packet', 
     86              name='WritePacketBtn', parent=self.splitterWindow1, pos=wx.Point(155, 150), 
    9587              size=wx.Size(145, 50)) 
    96         self.PushPacketBtn.SetFont(wx.Font(16, wx.SWISS, wx.NORMAL, wx.BOLD, False)) 
    97         self.PushPacketBtn.SetBackgroundColour("grey") 
    98         self.PushPacketBtn.Bind(wx.EVT_BUTTON, self.OnPushPacketBtnButton, 
     88        self.WritePacketBtn.SetFont(wx.Font(16, wx.SWISS, wx.NORMAL, wx.BOLD, False)) 
     89        self.WritePacketBtn.SetBackgroundColour("green") 
     90        self.WritePacketBtn.Bind(wx.EVT_BUTTON, self.OnWritePacketBtnButton, 
    9991              id=wxID_PUSHPACKETBTN) 
    10092  
     
    10294        ## if you want an image on the button 
    10395        # button_bmp = wx.Image("../AWG/my_image.bmp", wx.BITMAP_TYPE_BMP).ConvertToBitmap() 
    104         # self.PushPacketBtn = buttons.GenBitmapTextButton(self.splitterWindow1, 
    105         #       wxID_PUSHPACKETBTN,button_bmp, 'Push Packet', 
    106         #       name='PushPacketBtn', pos=wx.Point(155, 250), 
     96        # self.WritePacketBtn = buttons.GenBitmapTextButton(self.splitterWindow1, 
     97        #       wxID_PUSHPACKETBTN,button_bmp, 'Write Packet', 
     98        #       name='WritePacketBtn', pos=wx.Point(155, 250), 
    10799        #       size=wx.Size(300, 100), style=0) 
    108         # self.PushPacketBtn.Bind(wx.EVT_BUTTON, self.OnPushPacketBtnButton, 
     100        # self.WritePacketBtn.Bind(wx.EVT_BUTTON, self.OnWritePacketBtnButton, 
    109101        #       id=wxID_PUSHPACKETBTN) 
    110102        ##### 
     
    133125  
    134126 
    135         
    136  
    137     def OnPushPacketBtnButton(self,event): 
    138         '''This button is not supported yet''' 
    139         print "this button is not supported at the moment" 
    140  
     127    def OnWritePacketBtnButton(self,event): 
     128        #get the file names from the file name editors in the GUI 
     129        self.i_file_name = self.iFileNameEditor.GetLineText(0) 
     130        self.q_file_name = self.qFileNameEditor.GetLineText(0) 
     131 
     132        #write the data out 
     133        open_file = open(self.i_file_name, 'w')   #open the file for writing 
     134        open_file.write(str(self.I_data)) 
     135        open_file.close() 
     136 
     137        open_file = open(self.q_file_name, 'w')   #open the file for writing 
     138        open_file.write(str(self.Q_data)) 
     139        open_file.close() 
    141140 
    142141