aboutsummaryrefslogtreecommitdiff
path: root/funcGenerator.py
diff options
context:
space:
mode:
Diffstat (limited to 'funcGenerator.py')
-rw-r--r--funcGenerator.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/funcGenerator.py b/funcGenerator.py
index 4cbef0c..b4aa5f2 100644
--- a/funcGenerator.py
+++ b/funcGenerator.py
@@ -113,7 +113,7 @@ class Sweeper:
if stop > deadline:
runTime = (stop-start).seconds + float((stop-start).microseconds)/1000000
print("Overrun: Callbacks took %s seconds instead of %s" % (runTime, self.dTmS/1000) )
- self.widget.after(0, self.onTic)
+ self.after(0, self.onTic)
idleTime_mS = round((deadline-stop).seconds * 1000 + (deadline-stop).microseconds/1000)
# print("Will idle for %s" % (idleTime_mS) )
@@ -163,16 +163,15 @@ class Sweeper:
def getRelPos(self):
return self.relPos
-def testSweeper(sweeper):
+def testOnTicTk(sweeper):
print( sweeper.getPos() )
if sweeper.getPos() == sweeper.Npoints:
- print("Done")
+ print("Tk sweeper is done")
sweeper.cmdStop()
sweeper.widget.destroy()
sweeper.widget.quit()
-if __name__ == '__main__':
- from tkinter import Tk
+def testSweeperTk():
root=Tk()
root.geometry("800x600")
root.withdraw(); # do not show window
@@ -180,7 +179,16 @@ if __name__ == '__main__':
Np = 10
SweepTime = Np
print(f'Test sweeper: you should see a sequence of {Np} numbers updating about every {SweepTime/Np} seconds')
- sweeper = Sweeper(root, Npoints=Np, SweepTime=SweepTime, onTicCallbacks=[testSweeper])
+ sweeper = Sweeper(root, Npoints=Np, SweepTime=SweepTime, onTicCallbacks=[testOnTicTk])
sweeper.cmdStart()
root.mainloop()
+
+if __name__ == '__main__':
+ try:
+ from tkinter import Tk
+ testSweeperTk()
+ except ModuleNotFoundError:
+ print("Tk module not found, skipping testSweeperTk")
+ print("Done with tests")
+