slider.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 # -*- Python -*-
00004 
00005 from Tkinter import *
00006 #import thread
00007 import dummy_threading
00008 import time
00009 
00010 class SliderMulti(Frame):
00011         def __init__(self, channels, master=None):
00012                 Frame.__init__(self, master)
00013                 self.init(channels)
00014                 self.pack()
00015 
00016 
00017         def init(self, channels):
00018                 self._channels = channels
00019                 self.var = [] * len(self._channels)
00020                 self.scales = []
00021                 
00022                 i = 0
00023                 for channel in self._channels:
00024                         self.var.append(DoubleVar(0))
00025                         self.scales.append(
00026                                 Scale(self, label=channel[0], variable=self.var[i],
00027                                           to=channel[1], orient=VERTICAL))
00028                         self.scales[i]["from"] = channel[2]
00029                         self.scales[i]["resolution"] = channel[3]
00030                         self.scales[i]["length"] = channel[4]
00031                         self.scales[i].pack(side=LEFT)
00032                         i = i + 1
00033 
00034         def get(self):
00035                 val = []
00036                 for s in self.scales:
00037                         val.append(s.get())
00038 
00039                 return val
00040 
00041         def set(self, value):
00042                 i = 0
00043                 for v in value:
00044                         self.scales[i].set(v)
00045                         i = i + 1
00046                 return
00047 
00048 
00049 
00050 
00051 def test ():
00052         channels = (("angle", 0, 360, 0.1, 200), ("velocity", -100, 100, 0.1, 200))
00053         slider = SliderMulti(channels)
00054         sth = dummy_threading.Thread(target=slider.mainloop, args=())
00055         sth.start()
00056 #       thread.start_new_thread(slider.mainloop, ())
00057 
00058         while (1):
00059                 print slider.get()
00060                 time.sleep(0.5)
00061 #               slider.update()
00062 
00063 if  __name__ == '__main__': test()


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Aug 27 2015 14:17:28