python编程控制示波器设备_基于Python的示波器的截屏GUI界面

importtime

importtkinter astk

fromtkinter import*

fromtkinter importttk

classScreenCapture(object):

def__init__(self):

self.idn = self.__class__.__name__

# Instrument Initialisation

# self.instr = MyInstruments()

self.timestamp = time.strftime('%d-%b-%Y_%I.%M.%S_%p')

self.results_folder = '%s%s%s'% ('./EvalData/', self.timestamp, '/')

defgui_setup(self):

# Title and window size

win = tk.Tk()

win.title("Screen Capture GUI")

win.geometry('550x400')

# CH Name Setting

label1 = ttk.Label(win, text='CH1:LABEL:NAME').grid(column=0, row=0)

text1 = tk.Text(width = 10, height = 1)

text1.grid(column=1, row=0)

text1.insert(INSERT,'LX1')

label2 = ttk.Label(win, text='CH2:LABEL:NAME').grid(column=0, row=1)

text2 = tk.Text(width = 10, height = 1)

text2.grid(column=1, row=1)

text2.insert(INSERT,'VOUT')

label3 = ttk.Label(win, text='CH3:LABEL:NAME').grid(column=0, row=2)

text3 = tk.Text(width = 10, height = 1)

text3.grid(column=1, row=2)

text3.insert(INSERT,'LX2')

label4 = ttk.Label(win, text='CH4:LABEL:NAME').grid(column=0, row=3)

text4 = tk.Text(width = 10, height = 1)

text4.grid(column=1, row=3)

text4.insert(INSERT, 'IOUT')

# CH Offset Setting

ttk.Label(win, text="CH1 Offset").grid(column=2, row=0)

ch1offset = StringVar()

ch1offset_set = Scale(win, from_=0, to=2, orient=HORIZONTAL, resolution=0.01, tickinterval=100, length=100, variable=ch1offset)

ch1offset_set.grid(column=3, row=0)

ttk.Label(win, text="CH2 Offset").grid(column=2, row=1)

ch2offset = StringVar()

ch2offset_set = Scale(win, from_=0, to=2, orient=HORIZONTAL, resolution=0.01, tickinterval=10, length=100, variable=ch2offset)

ch2offset_set.grid(column=3, row=1)

ttk.Label(win, text="CH3 Offset").grid(column=2, row=2)

ch3offset = StringVar()

ch3offset_set = Scale(win, from_=0, to=2, orient=HORIZONTAL, resolution=0.01, tickinterval=10, length=100, variable=ch2offset)

ch3offset_set.grid(column=3, row=2)

ttk.Label(win, text="CH4 Offset").grid(column=2, row=3)

ch4offset = StringVar()

ch4offset_set = Scale(win, from_=0, to=2, orient=HORIZONTAL, resolution=0.01, tickinterval=10, length=100, variable=ch4offset)

ch4offset_set.grid(column=3, row=3)

# Input Voltage setting

ttk.Label(win, text="INPUT VOLTAGE[V]").grid(column=0, row=4)

vin = tk.StringVar()

vin_set = ttk.Combobox(win, width=10, textvariable=vin)

vin_set['values'] = (2.5, 3.0, 3.5, 3.7, 4.0, 4.5, 5.0, 5.5)

vin_set.grid(column=1, row=4)

vin_set.current(3)

# Output Current Setting

ttk.Label(win, text="LOAD CURRENT[A]").grid(column=0, row=5)

iout = tk.StringVar()

iout_set = ttk.Combobox(win, width=10, textvariable=iout)

iout_set['values'] = (0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0)

iout_set.grid(column=1, row=5)

iout_set.current(0)

# Trigger choose and type setting

ttk.Label(win, text="CH Num of Trigger").grid(column=0, row=6)

number = tk.StringVar()

numberChosen = ttk.Combobox(win, width=10, textvariable=number)

numberChosen['values'] = ('CH1','CH2', 'CH3', 'CH4')

numberChosen.grid(column=1, row=6)

numberChosen.current(3)

riseorfall = tk.StringVar()

riseorfallChosen = ttk.Combobox(win, width=10, textvariable=riseorfall)

riseorfallChosen['values'] = ('Rise','Fall')

riseorfallChosen.grid(column=2, row=6)

riseorfallChosen.current(1)

# Screen Capture button

action = ttk.Button(win, text="Screen Capture")

action.grid(column=1, row=10)

tk.mainloop()

if__name__ == '__main__':

meas = ScreenCapture()

try:

meas.gui_setup()

finally:

pass

你可能感兴趣的:(python编程控制示波器设备)