From 9ccdfe4daa6a7f4d1016215e95a70f315c92e999 Mon Sep 17 00:00:00 2001 From: Martin Lim Date: Sat, 25 Jul 2020 19:12:02 -0700 Subject: [PATCH] pylint --- projects/DebugTool.py | 22 +++--- projects/IQConvert.py | 28 +++---- projects/RS_Options.py | 136 +++++++++++++++++++++++++++++++++ projects/VSA_VSG_Sweep.py | 14 ++-- projects/helloworld.py | 2 +- projects/helloworld_tkinter.py | 6 +- 6 files changed, 168 insertions(+), 40 deletions(-) create mode 100644 projects/RS_Options.py diff --git a/projects/DebugTool.py b/projects/DebugTool.py index e284808..5f9cf99 100644 --- a/projects/DebugTool.py +++ b/projects/DebugTool.py @@ -27,16 +27,14 @@ """ ############################################################################### -### Code Import +### Code Import ############################################################################### -from guiblox import buttonRow, entryCol, theme, listWindow - -### Code specific imports -from rssd.yaVISA_socket import jaVisa -from tkinter import messagebox import datetime import socket import os +from guiblox import buttonRow, entryCol, theme, listWindow +from rssd.yaVISA_socket import jaVisa +# from tkinter import messagebox ############################################################################### ### Function Definition @@ -94,12 +92,12 @@ def instr1(root): Instr.debug = 0 Instr.jav_Open(RS.IP1) for scpi in RS.SCPI1: - if '?' in scpi: + if '?' in scpi: rdStr = Instr.query(scpi) Output = Output + ',' + rdStr else: Instr.write(scpi) - Output = datetime.datetime.now().strftime("%y%m%d,%H:%M:%S.%f") + Output + Output = datetime.datetime.now().strftime("%y%m%d,%H:%M:%S.%f") + Output print(Output) f = open(__file__+'.txt','a') f.write(Output+'\n') @@ -113,13 +111,13 @@ def instr2(root): Instr.debug = 0 Instr.jav_Open(RS.IP2) for scpi in RS.SCPI2: - if '?' in scpi: + if '?' in scpi: rdStr = Instr.query(scpi) Output = Output + ',' + rdStr else: Instr.write(scpi) f = open(__file__+'.txt','a') - Output = datetime.datetime.now().strftime("%y%m%d,%H:%M:%S.%f") + Output + Output = datetime.datetime.now().strftime("%y%m%d,%H:%M:%S.%f") + Output print(Output) f.write(Output+'\n') f.close() @@ -148,7 +146,7 @@ def SaveSetts(root): ### GUI Main ############################################################################### def main(): - global root + # global root root = theme().addColor() root.title('Socket Test Program') root.resizable(0,0) @@ -206,4 +204,4 @@ def main(): root.mainloop() if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/projects/IQConvert.py b/projects/IQConvert.py index 502ed07..5c67475 100644 --- a/projects/IQConvert.py +++ b/projects/IQConvert.py @@ -8,16 +8,14 @@ ##################################################################### ##################################################################### -### OOGUI Import +### OOGUI Import ##################################################################### -from guiblox import buttonRow, entryCol, theme, listWindow - -### Code specific imports +import time import tkinter as tk from tkinter.filedialog import askopenfilename -from rssd import jaVisa -import time -import os +# import os +from guiblox import buttonRow, entryCol, theme, listWindow +# from rssd import jaVisa from rssd.iqdata import IQ ##################################################################### @@ -34,8 +32,6 @@ def convert(root): duration = time.time() - start print(f"IQ:{iq.NumberOfSamples} samples in {duration*1e3:2.2f} ms --> {iq.NumberOfSamples/1e6/duration:3.2f} MSamples/s") - pass - def getFilename(tkEvent): fny = askopenfilename() tkEvent.widget.delete(0,tk.END) @@ -46,7 +42,7 @@ def getFilename(tkEvent): ### GUI Layout ##################################################################### def main(): - global root + # global root root = theme().addColor() root.title('Socket Test Program') root.resizable(0,0) @@ -62,12 +58,12 @@ def main(): root.files.chg2Enum('entry1', ['iq.tar','iqw','wv']) root.files.chg2Enum('entry3', ['iq.tar','iqw','wv']) - root.files.entry0.bind("",getFilename) #pylint: disable=E1101 - root.files.entry2.bind("",getFilename) #pylint: disable=E1101 - root.files.entry0.config(width = widdy) #pylint: disable=E1101 - root.files.entry1.config(width = widdy-7) #pylint: disable=E1101 - root.files.entry2.config(width = widdy) #pylint: disable=E1101 - root.files.entry3.config(width = widdy-7) #pylint: disable=E1101 + root.files.entry0.bind("",getFilename) #pylint: disable=E1101 + root.files.entry2.bind("",getFilename) #pylint: disable=E1101 + root.files.entry0.config(width = widdy) #pylint: disable=E1101 + root.files.entry1.config(width = widdy-7) #pylint: disable=E1101 + root.files.entry2.config(width = widdy) #pylint: disable=E1101 + root.files.entry3.config(width = widdy-7) #pylint: disable=E1101 root.bottWind.listWindow.config(height= 5,width=50) root.buttnRow.button0.config(text='Convert' ,command=lambda: convert(root)) #pylint: disable=E1101 diff --git a/projects/RS_Options.py b/projects/RS_Options.py new file mode 100644 index 0000000..6e7a3a2 --- /dev/null +++ b/projects/RS_Options.py @@ -0,0 +1,136 @@ +############################################################################### +### Purpose: Object Oriented Python Tkinter example +### Author : Martin C Lim +### Date : 2019.02.01 +############################################################################### +### User Inputs +############################################################################### +SCPIWidth = 50 +SCPIHeigh = 5 + +############################################################################## +### Code Import +############################################################################### +import datetime +import os + +from guiblox import buttonRow, entryCol, theme, listWindow +from rssd.yaVISA_socket import jaVisa +# from tkinter import messagebox + +############################################################################### +### Function Definition +############################################################################### +def clrBottom(root): + root.bottWind.clear() + # root.bottWind.writeH('2xLt:IDN Rt:SystError 2xRt:SystInfo') + +def fopen(): + os.system('notepad.exe ' + __file__ + '.txt') + +def fwrite(root): + RS = gui_reader(root) + f = open(__file__+'.txt', 'a') + f.write(datetime.datetime.now().strftime("%y%m%d-%H:%M:%S.%f")+'\n') #Date String + f.write(RS.Output) + print(f'Text Written to {__file__}') + f.close() + +def gui_reader(root): + ### Read values from GUI + RS = lambda: None + RS.IP1 = root.entryCol1.entry0.get() #pylint:disable=E1101 + RS.SCPI1 = root.SCPI1.getlist() + RS.Output = root.bottWind.getstr() + return RS + +def IDN(tkEvent): + ipAddy = tkEvent.widget.get() + print(f'IDN : {ipAddy}') + instr = jaVisa().jav_Open(ipAddy) #pylint:disable=E1101 + instr.jav_Close() + +def SYSTERR(tkEvent): + ipAddy = tkEvent.widget.get() + print(f'SYS Err : {ipAddy}') + instr = jaVisa().jav_Open(ipAddy) #pylint:disable=E1101 + instr.jav_ClrErr() + print(f'SYS Err : No Error') + instr.jav_Close() + +def SYSTNFO(tkEvent): + ipAddy = tkEvent.widget.get() + print(f'SYS INFO : {ipAddy}') + instr = jaVisa().jav_Open(ipAddy) #pylint:disable=E1101 + instr.query('SYST:DFPR?') + instr.jav_Close() + +def instr1(root): + Output = "" + RS = gui_reader(root) + Instr = jaVisa() + Instr.debug = 0 + Instr.jav_Open(RS.IP1) + for scpi in RS.SCPI1: + if '?' in scpi: + rdStr = Instr.query(scpi) + Output = Output + ', ' + rdStr + else: + Instr.write(scpi) + Output = datetime.datetime.now().strftime("%y%m%d, %H:%M:%S.%f") + Output + print(Output) + f = open(__file__+'.txt', 'a') + f.write(Output+'\n') + f.close() + Instr.jav_Close() + +############################################################################### +### GUI Main +############################################################################### +def main(): + root = theme().addColor() + root.title('Rohde & Schwarz Options') + root.resizable(0, 0) + + ########################################################################### + ### guiBlox: Create Widgets + ########################################################################### + root.entryCol1 = entryCol(root, {'Instr': '10.0.0.10'}) + root.SCPI1 = listWindow(root).writeN('*IDN?\n*OPT?\nSYST:DFPR?\n') + + root.bottWind = listWindow(root) + root.bottWind.stdOut() #Stdout --> window + root.btnRowTop = buttonRow(root, 1, makequit=0) #pylint: disable=unused-variable + root.btnRowBot = buttonRow(root, 3) #pylint: disable=unused-variable + clrBottom(root) + + ########################################################################### + ### guiBlox: Customize Widgets + ########################################################################### + root.entryCol1.entry0.bind("", IDN) #pylint: disable=E1101 + root.entryCol1.entry0.bind("", SYSTERR) #pylint: disable=E1101 + root.entryCol1.entry0.bind("", SYSTNFO) #pylint: disable=E1101 + + root.SCPI1.listWindow.config(width=SCPIWidth, height=5) + + root.bottWind.listWindow.config(height= 15, width=(SCPIWidth)) + root.btnRowTop.button0.config(text='Query', command=lambda: instr1(root)) #pylint: disable=E1101 + + root.btnRowBot.button0.config(text='write File', command=lambda: fwrite(root)) #pylint: disable=E1101 + root.btnRowBot.button1.config(text='open File', command=lambda: fopen()) #pylint: disable=E1101 + root.btnRowBot.button2.config(text='clear', command=lambda: clrBottom(root))#pylint: disable=E1101 + + ########################################################################### + ### guiBlox: Place Widgets + ########################################################################### + root.grid_rowconfigure(2, weight=1) + root.entryCol1.frame.grid(row=0, column=0, sticky="ns") + root.SCPI1.frame.grid(row=1, column=0, sticky='ew') + root.btnRowTop.frame.grid(row=2, column=0, columnspan=2, sticky="nsew") + root.bottWind.frame.grid(row=3, column=0, columnspan=2, sticky='nsew') + root.btnRowBot.frame.grid(row=10, column=0, columnspan=2, sticky="nsew") + + root.mainloop() + +if __name__ == '__main__': + main() diff --git a/projects/VSA_VSG_Sweep.py b/projects/VSA_VSG_Sweep.py index e1d4ef2..a8a018e 100644 --- a/projects/VSA_VSG_Sweep.py +++ b/projects/VSA_VSG_Sweep.py @@ -6,7 +6,7 @@ ##################################################################### ### User Inputs ##################################################################### -entryDict = {} +entryDict = {} entryDict['SMW IP'] = '192.168.1.114' entryDict['FSW IP'] = '192.168.1.109' entryDict['Freq Start'] = '24e9' @@ -17,15 +17,13 @@ entryDict['Filename'] = 'Output' ##################################################################### -### OOGUI Import +### OOGUI Import ##################################################################### +import time +import os from guiblox import buttonRow, entryCol, theme, listWindow - -### Code specific imports from rssd.VST.Common import VST #pylint:disable=E0611,E0401 from rssd.FileIO import FileIO -import time -import os ##################################################################### ### Function Definition @@ -35,7 +33,7 @@ def IDN(root): print(Instr.SMW.query('*IDN?')) print(Instr.FSW.query('*IDN?')) Instr.jav_Close() - + def run(root): Instr = VST().jav_Open(root.entryCol.entry0.get(),root.entryCol.entry1.get()) #pylint:disable=E1101 OFileCSV = FileIO().makeFile(root.entryCol.entry7.get()+'csv') @@ -108,4 +106,4 @@ def main(): root.mainloop() if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/projects/helloworld.py b/projects/helloworld.py index 9ac80b3..6681b73 100644 --- a/projects/helloworld.py +++ b/projects/helloworld.py @@ -3,4 +3,4 @@ def main(): print('Hello World') if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/projects/helloworld_tkinter.py b/projects/helloworld_tkinter.py index 6a402f9..3159362 100644 --- a/projects/helloworld_tkinter.py +++ b/projects/helloworld_tkinter.py @@ -1,9 +1,9 @@ -from tkinter import * +from tkinter import Tk def main(): window = Tk() - window.title("Hello World") + window.title("Hello World") window.mainloop() if __name__ == '__main__': - main() \ No newline at end of file + main()