import graph = tk.Button(self, text=”Generate graph”,font=(None,20,’bold’),fg=’purple’, command=self.parent.frames[Graph].tkraise)

import tkinter as tkimport mathclass LRexperiment(tk.Tk):      def __init__(self):               tk.Tk.__init__(self)                frames = (MainPage, Circuit, Graph)        self.frames = {}        for F in frames:            frame = F(self)            self.framesF = frame                                    frame.grid(row=0, column=0, sticky=”nsew”)        for F in self.frames.values():            F.interface()        self.framesMainPage.tkraise()             class MainPage(tk.Frame):         def __init__(self, parent):        tk.Frame.__init__(self, parent)        self.parent= parent        def interface(self):#######        label = tk.Label(self, text=”L-R cirucit experiment”,font=(None,20,’bold’))        circuit = tk.Button(self, text=”L-R circuit and calculator”,font=(None,20,’bold’),fg=’purple’, command=self.parent.framesCircuit.tkraise)        graph = tk.Button(self, text=”Generate graph”,font=(None,20,’bold’),fg=’purple’, command=self.parent.framesGraph.tkraise)        label.place(x=400, y=200, anchor=”center”)        circuit.place(x=400, y=300, anchor=”center”)        graph.place(x=400, y=400, anchor=”center”)             class Circuit(tk.Frame):     def __init__(self,parent):               tk.Frame.__init__(self,parent)        self.parent = parent        self.grid()     def interface(self):#######        label = tk.Label(self, text=”L-R circuit experiment” ,fg=”blue”,font=(‘gothic’,23,’bold’))        label.grid(row = 1,column = 0)                self.labelTheory = tk.Label(self, text=”Theory of filters “,font=(None,15,’bold’),fg=’magenta’)          self.labelTheory.grid(row = 2,column = 1,sticky=’W’)                        self.img = tk.PhotoImage(file = “LRcircuit.GIF” )#.subsample(2,2)        self.Label1 = tk.Label( self,image = self.img)        self.Label1.grid(row = 3,column = 0)        #Generating label R,L,f        self.labelR = tk.Label(self, text=”Resistance R (Ohm)”,font=(None,15))          self.labelR.grid(row = 4,column = 0)                        self.labelL = tk.Label(self, text=”Inductor impedance L (Ohm)”,font=(None,15) )         self.labelL.grid(row = 5,column = 0)        self.labelf = tk.Label(self, text=”Frequency f (Hz)”,font=(None,15))           self.labelf.grid(row = 6,column = 0)                #entry boxes        entryR = tk.Entry(self,width=40)        entryL = tk.Entry(self,width=40)        entryf = tk.Entry(self,width=40)        entryR.grid(row=4,column=1,sticky=’W’)        entryL.grid(row=5, column=1,sticky=’W’)        entryf.grid(row=6, column=1,sticky=’W’)        ## define R,L,f by the input values                #R = float(entryR.get())        #L = float(entryL.get())        #f = float(entryf.get())                # evaluate Fc and ratioH with equations        #fc = R/ (2* math.pi *L)        #w = 2*math.pi*f        #H = R/(R + (w*L*j))       #H(s) = Vo/Vi                #Genrating Button        self.runButton = tk.Button(self,text=”Calculate”,font=(None,15,’bold’),fg=’red’)        self.runButton.grid(row = 7,column = 0)        #Generating text box                self.text1 = tk.Text(self, height=15,width=50,font=(“Times New Roman”,13))        self.text1.grid(row = 3,column = 1)        self.scroll=tk.Scrollbar(self,orient=’vertical’)        self.scroll.config(command=self.text1.yview)        self.scroll.grid(row=3,column=2)        self.text1.insert(‘end’,’Filters in Frequency Domain’+’
‘)        self.text1.insert(‘end’,’We can determine the type of filter through the function of frequency:H(w)’+’
‘)        self.text1.insert(‘end’,’Since H(w)=Vo/Vi = R/(R + jwL)’+’
‘)        self.text1.insert(‘end’,’The cirucit on the left hand side is a low-pass filter’+’
‘)        self.text1.insert(‘end’,’Filters (or Filter Networks) –devices designed to pass signals with specific frequency range and reject (attenuate) signals those frequency spectrum is outside this passband.We have 4 types of filters:’+’
‘)        self.text1.insert(‘end’,’•Low-pass filter’+’
‘)        self.text1.insert(‘end’,’•High-pass filter’+’
‘)        self.text1.insert(‘end’,’•Band-pass filter’+’
‘)        self.text1.insert(‘end’,’•Band-stop filter’+’
‘)        self.text1.insert(‘end’,’THEORY: Whilst resistors simply dissipate electrical energy, inductors and capacitors also store energy in magnetic and electric fields.When a sinusoidally varying source (of a given frequency) is connected to a circuit, the various voltages and currents around the circuit will also vary sinusoidally at the same frequency. The voltage(V) across each resistor and the current(I) through it will be in phase with each other and related in amplitude by the value of the resistance.When reactive components are also present in the circuit, the V and I will still vary sinusoidally at the same frequency as the driving source. The V across each reactive component and the I through it will however no longer be in phase with each other and the ratio of their amplitudes will become a FUNCTION OF FREQUENCY: H(w). Networks containing reactive components are therefore inherently frequency selective – these networks are often used as FILTERS; circuits that can selectively remove certain frequency components from a signal.’+’
‘)        self.text1.config(state=’disabled’)                        self.text2 = tk.Text(self, height=8,width=40,font=(“Times New Roman”,13))        self.text2.grid(row = 8,column=0, sticky = “nsew”)        self.text2.insert(‘end’, ‘Fc = R / (2*pi*L) = ‘+’
‘)   #+  str(fc)        ##insert(‘end’,): Jul 25 ’14 at 22:12 author: renzowesterbeek https://stackoverflow.com/questions/3842155/is-there-a-way-to-make-the-tkinter-text-widget-read-only        self.text2.insert(‘end’,’H(s) = R/(R + (w*L*j)) = ‘+’
‘ )  #+ str(H)        ButtonG = tk.Button(self, text=’Graph analysis’,font=(None,15,’bold’),fg=’red’,command=self.parent.framesGraph.tkraise)        ButtonG.grid(row=11, column=0)        class Graph(tk.Frame):     def __init__(self, parent):        tk.Frame.__init__(self, parent)        self.parent = parent        self.grid()     def interface(self):                 label = tk.Label(self, text=”Graph analysis”,font=(None,25,’bold’))         label.place(x=400, y=200, anchor=”center”)                  backbutton = tk.Button(self, text=’Go back to main page’,font=(None,20,’bold’),fg=’purple’,command=self.parent.framesMainPage.tkraise)         backbutton.place(x=400, y=300, anchor=”center”)m= LRexperiment()m.mainloop

Go Top
x

Hi!
I'm Rita!

Would you like to get a custom essay? How about receiving a customized one?

Check it out