def onSaveFile(self):

        if self.__file == None:
            # Save as new file
            self.__file = AskSaveAsFilename(initialfile='Untitled.txt',
                                            defaultextension=".txt",
                                            filetypes=[("All Files", "*.*"),
                                                       ("Text Documents",
                                                        "*.txt")])

            if self.__file == "":
                self.__file = None
            else:

                # Try to save the file
                file = open(self.__file, "w")
                file.write(self.TextArea.get(1.0, END))
                file.close()

                # Change the window title
                self.__root.title(os.path.basename(self.__file) + " - Notepad")

        else:
            file = open(self.__file, "w")
            file.write(self.TextArea.get(1.0, tk.END))
            file.close()
Example #2
0
 def onTouched(self,event):
     fp=FileParts(self.fileparts.AbsoluteFilePath()+'/'+self.project[self.projectPath])
     filename=AskSaveAsFilename(filetypes=[('txt', '.txt')],
                                initialdir=fp.AbsoluteFilePath(),
                                initialfile=fp.FileNameWithExtension('txt'))
     if filename is None:
         return
     filename=ConvertFileNameToRelativePath(filename)
     self.project[self.projectPath]=filename
     self.UpdateStrings()
Example #3
0
 def onWriteImageToFile(self):
     if self.parent.parent.fileparts.filename=='':
         filename=self.name
     else:
         filename=self.parent.parent.fileparts.filename+'_'+self.name
     filename=AskSaveAsFilename(parent=self,filetypes=[('Images',('.png','.bmp','.jpg','.gif','.tiff'))],
                     defaultextension='.png',
                     initialdir=self.parent.parent.fileparts.AbsoluteFilePath(),
                     initialfile=filename+'.png')
     if filename is None:
         return
     self.eyeDiagram.img.save(filename)
Example #4
0
 def onWriteSParametersToFile(self):
     ports=self.sp.m_P
     extension='.s'+str(ports)+'p'
     filename=AskSaveAsFilename(filetypes=[('s-parameters', extension)],
                 defaultextension=extension,
                 initialdir=self.fileparts.AbsoluteFilePath(),
                 initialfile=self.fileparts.FileNameWithExtension(extension),
                 parent=self)
     if filename is None:
         return
     self.fileparts=FileParts(filename)
     self.sp.WriteToFile(filename,'R '+str(self.sp.m_Z0))
Example #5
0
 def onWriteSimulatorToFile(self):
     for wfi in range(len(self.waveformNamesList)):
         outputWaveformName=self.waveformNamesList[wfi]
         outputWaveform=self.waveformList[wfi]
         if self.parent.parent.fileparts.filename=='':
             filename=outputWaveformName
         else:
             filename=self.parent.parent.fileparts.filename+'_'+outputWaveformName
         preferLeCroyWaveforms=SignalIntegrity.App.Preferences['ProjectFiles.PreferSaveWaveformsLeCroyFormat']
         if preferLeCroyWaveforms:
             filename=AskSaveAsFilename(parent=self,filetypes=[('LeCroy','.trc'),('waveform', '.txt')],
                             defaultextension='.trc',
                             initialdir=self.parent.parent.fileparts.AbsoluteFilePath(),
                             initialfile=filename+'.trc')
         else:
             filename=AskSaveAsFilename(parent=self,filetypes=[('waveform', '.txt'),('LeCroy','.trc')],
                             defaultextension='.txt',
                             initialdir=self.parent.parent.fileparts.AbsoluteFilePath(),
                             initialfile=filename+'.txt')
         if filename is None:
             continue
         outputWaveform.WriteToFile(filename)
Example #6
0
 def onMatplotlib2TikZ(self):
     filename = AskSaveAsFilename(
         parent=self,
         filetypes=[('tex', '.tex')],
         defaultextension='.tex',
         initialdir=self.parent.parent.fileparts.AbsoluteFilePath(),
         initialfile=self.parent.parent.fileparts.filename +
         'Waveforms.tex')
     if filename is None:
         return
     try:
         PlotTikZ(filename, self.f)
     except:
         messagebox.showerror('Export LaTeX',
                              'LaTeX could not be generated or written ')
Example #7
0
 def onMatplotlib2TikZ(self):
     if self.ViewTimeDomainDoer.Bool():
         suffix='Waveforms'
     elif self.ViewSpectralContentDoer.Bool():
         suffix='SpectralContent'
     elif self.ViewSpectralDensityDoer.Bool():
         suffix='SpectralDensity'
     filename=AskSaveAsFilename(parent=self,filetypes=[('tex', '.tex')],
                                defaultextension='.tex',
                                initialdir=self.parent.parent.fileparts.AbsoluteFilePath(),
                                initialfile=self.parent.parent.fileparts.filename+suffix+'.tex')
     if filename is None:
         return
     try:
         PlotTikZ(filename,self.f)
     except:
         messagebox.showerror('Export LaTeX','LaTeX could not be generated or written ')
Example #8
0
 def onWriteSimulatorToFile(self):
     for wfi in range(len(self.waveformNamesList)):
         outputWaveformName = self.waveformNamesList[wfi]
         outputWaveform = self.waveformList[wfi]
         if self.parent.parent.fileparts.filename == '':
             filename = outputWaveformName
         else:
             filename = self.parent.parent.fileparts.filename + '_' + outputWaveformName
         filename = AskSaveAsFilename(
             parent=self,
             filetypes=[('waveform', '.txt')],
             defaultextension='.txt',
             initialdir=self.parent.parent.fileparts.AbsoluteFilePath(),
             initialfile=filename + '.txt')
         if filename is None:
             continue
         outputWaveform.WriteToFile(filename)
Example #9
0
    def ok(self, event=None):
        extension='.txt'
        filename=AskSaveAsFilename(parent=self,
                                   filetypes=[('text', extension)],
                                   defaultextension='.txt',
                                   initialdir=self.parent.fileparts.AbsoluteFilePath(),
                                   initialfile=self.parent.fileparts.filename+'.txt')
        if filename is None:
            self.initial_focus.focus_set() # put focus back
            return
        with open(filename,"w") as f:
            for line in self.textToShow:
                f.write(line+'\n')

        self.withdraw()
        self.update_idletasks()

        self.apply()

        self.cancel()
Example #10
0
    def onMatplotlib2TikZ(self):
        filename=AskSaveAsFilename(parent=self,filetypes=[('tex', '.tex')],
                                   defaultextension='.tex',
                                   initialdir=self.fileparts.AbsoluteFilePath(),
                                   initialfile=self.fileparts.filename+'Magnitude.tex')
        if filename is None:
            return

        try:
            PlotTikZ(filename,self.topLeftFigure)
        except:
            messagebox.showerror('Export LaTeX','LaTeX could not be generated or written ')                
        fp=FileParts(filename.replace('Magnitude.tex', ''))
        filename=fp.filename

        filename=AskSaveAsFilename(parent=self,filetypes=[('tex', '.tex')],
                                   defaultextension='.tex',
                                   initialdir=self.fileparts.AbsoluteFilePath(),
                                   initialfile=filename+'Phase.tex')
        if filename is None:
            return

        try:
            PlotTikZ(filename,self.topRightFigure)
        except:
            messagebox.showerror('Export LaTeX','LaTeX could not be generated or written ')                
        fp=FileParts(filename.replace('Phase.tex', ''))
        filename=fp.filename

        filename=AskSaveAsFilename(parent=self,filetypes=[('tex', '.tex')],
                                   defaultextension='.tex',
                                   initialdir=self.fileparts.AbsoluteFilePath(),
                                   initialfile=filename+'ImpulseResponse.tex')
        if filename is None:
            return

        try:
            PlotTikZ(filename,self.bottomLeftFigure)
        except:
            messagebox.showerror('Export LaTeX','LaTeX could not be generated or written ')                
        fp=FileParts(filename.replace('ImpulseResponse.tex', ''))
        filename=fp.filename

        filename=AskSaveAsFilename(parent=self,filetypes=[('tex', '.tex')],
                                   defaultextension='.tex',
                                   initialdir=self.fileparts.AbsoluteFilePath(),
                                   initialfile=filename+'StepResponse.tex')
        if filename is None:
            return

        try:
            PlotTikZ(filename,self.bottomRightFigure)
        except:
            messagebox.showerror('Export LaTeX','LaTeX could not be generated or written ')