当前位置: 首页>>代码示例>>Python>>正文


Python Scale.get方法代码示例

本文整理汇总了Python中Tkinter.Scale.get方法的典型用法代码示例。如果您正苦于以下问题:Python Scale.get方法的具体用法?Python Scale.get怎么用?Python Scale.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tkinter.Scale的用法示例。


在下文中一共展示了Scale.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TimeBase

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import get [as 别名]
class TimeBase(Frame):
    """controleur pour la base de temps

    scale : controle de la valeur de la base de temps
    """
    def __init__(self, parent=None):
        """ initialisation

        parent : oscilloscope
        """
        Frame.__init__(self)
        self.configure(bd=1, relief="sunken")
        self.parent = parent
        self.scale = Scale(self, length=300, orient="horizontal",
                label="Temps", showvalue=1, from_=1, to=10,
                tickinterval=1, command=self.update_time_base)
        self.scale.pack(expand="yes", fill="both")

    def get_time(self):
        """valeur courante de la base de temps"""
        return self.scale.get()

    def update_time_base(self, event):
        """mise a jour de la base de temps"""
        print("TimeBase.update_time_base()")
        print("Base de temps : ", self.scale.get())
        if not isinstance(self.parent, Tk):
            self.parent.update_time(self.scale.get())
开发者ID:Akanoa,项目名称:CAI2014,代码行数:30,代码来源:timebase.py

示例2: FDL

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import get [as 别名]
def FDL(k,fName):
    """Infitie loop function which constantly runs the display given
    the file name of the sequences and an initial k"""

    global kInput
    #Gets the initial de Bruijn Graph
    fdlNodes,minSeqLen = getFDLNodes(k,fName)  
    #Sets up kInput to the appriate scale (3 to the shortest length - 1 ) to ensure
    #   all sequence reads are always included
    if not kInput:
        minSeqLen -= 1 
        kInput = Scale(root, from_=3, to=minSeqLen,orient=HORIZONTAL,label="K",relief = FLAT)
        kInput.set(k) #sets the initial k value
        kInput.pack(side=LEFT, padx=50, pady=10)

    #generates all lines from the initial graph    
    lines = addLines(fdlNodes)
    #starts inifinite recursive loop for redraw function
    move_nodes(fdlNodes, kInput.get(), kInput.get(), lines, root,fName)
    #starts display
    root.mainloop()
开发者ID:dgriff03,项目名称:deBruijnFDL,代码行数:23,代码来源:debruijn.py

示例3: JoystickFrame

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import get [as 别名]
class JoystickFrame(LabelFrame):
    def __init__(self, master, tracker, text="Joystick", **options):
        LabelFrame.__init__(self, master, text=text, **options)
        self.tracker = tracker

        self.width = 400
        self.height = 400
        self.canvas = Canvas(self, height=self.height, width=self.width)
        self.canvas.grid()
        self.canvas.create_oval((self.width/2 - 3, self.height/2 - 3,
                                 self.width/2 + 3, self.height/2 + 3))
        self.canvas.bind("<Button-1>",
                         bg_caller(lambda event: self.move_tracker(event)))
        self.canvas.bind("<Motion>", self.update_label)

        self.motion_label = Label(self, text="",
                                  font=tkFont.Font(family="Courier"))
        self.motion_label.grid()

        f = LabelFrame(self, text="Sensitivity")
        self.sensitivity_scale = Scale(f, from_=0, to=10,
                                       resolution=0.01,
                                       orient=HORIZONTAL,
                                       length=self.width)
        self.sensitivity_scale.set(5)
        self.sensitivity_scale.grid()
        f.grid()

    @property
    def sensitivity(self):
        return self.sensitivity_scale.get() / 2000.

    def get_delta(self, event):
        dx = event.x - int(self.canvas['width'])/2.
        dy = event.y - int(self.canvas['height'])/2.
        dx_rad = dx*self.sensitivity
        dy_rad = dy*self.sensitivity
        dtheta = dy_rad
        dphi = -dx_rad
        return (dtheta, dphi)

    def update_label(self, event):
        dtheta, dphi = self.get_delta(event)
        self.motion_label.configure(text="<{:8.5f}, {:8.5f}>".format(dtheta,
                                                                     dphi))

    def move_tracker(self, event):
        dtheta, dphi = self.get_delta(event)
        self.tracker.move(0, dtheta, dphi)
        logger.info("Moved tracker by ({}, {})".format(dtheta, dphi))
开发者ID:ucsbdeepspace,项目名称:morphable-mirror-telescope-python,代码行数:52,代码来源:joystickframe.py

示例4: TimeBase

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import get [as 别名]
class TimeBase(Frame):
    """
    Base de temps

    scale_time : controle  de la base de temps
    """
    def __init__(self, parent=None):
        """
        Initialisation

        parent : oscilloscope
        """
        Frame.__init__(self)
        self.configure(bd=1, relief="sunken")
        self.parent = parent
        self.scale_time = Scale(self, length=100, orient="horizontal",
                label="Temps", showvalue=1, from_=1, to=10,
                tickinterval=1, command=self.update)
        self.scale_time.pack(expand="yes", fill="both")

        # choix d'afficher lissajoux ou pas
        self.check = Checkbutton(self,text="Afficher lissajou", selectcolor=self.parent.lissajoux.color_XY,  command=self.parent.plot_all, variable=self.parent.drawXY, onvalue = 1, offvalue = 0)
        self.check.pack(side="top",expand="yes", fill="x")
        self.check.select()

    def get_time(self):
        """
        recuperer la valeur courante de la base de temps
        """
        return self.scale_time.get()

    def update(self, event):
        """mise a jour de la base de temps"""
        print("TimeBase.update_time_base()")
        print("Base de temps : ", self.scale_time.get())
        if not isinstance(self.parent, Tk):
            self.parent.update_time(self.scale_time.get())
开发者ID:holiday2018,项目名称:python_oscilloscope,代码行数:39,代码来源:timebase.py

示例5: ObjectDialog

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import get [as 别名]
class ObjectDialog(Dialog):
    """
    A custom dialog that allows the user to configure placing objects in the virtual environment
    """
    def __init__(self, parent, x=None, y=None, populator=None):
        """
        Construct the instance of the object dialog

        :param parent:          The parent tk instance that spawns the dialog
        """
        self._entries = {
            "x_coordinate"   : None,
            "y_coordinate"   : None,
            "name"      : None,
            "mesh"      : None,
            "scale"     : None
        }
        self._scale_text = StringVar()
        self._scale_text.set(str(1))

        Dialog.__init__(self, parent, "ObjectBuilder", True, x, y, populator)

    def body(self, parent):
        """
        Define the custom body of the dialog
        :param parent:          The parent instance of the dialog
        """
        # Define the labels of all of the sub widgets that are to be used
        Label(parent, text="Name:").grid(row=0, column=0, sticky=W)
        Label(parent, text="X-Coord:").grid(row=1, column=0, sticky=W)
        Label(parent, text="Y-Coord:").grid(row=1, column=2, sticky=W)
        Label(parent, text="Mesh:").grid(row=2, column=0, sticky=W)
        Label(parent, text="Scale:").grid(row=3, column=0, sticky=W)
        Label(parent, textvariable=self._scale_text, bg="grey").grid(row=3, column=1, sticky=W)

        #Define the text entry widgets
        self._object_name = Label(parent, text=self._entries["name"])
        self._object_name.grid(column=1, row=0, sticky=W)
        self._x_coord = Label(parent, text=self._entries["x_coordinate"])
        self._x_coord.grid(column=1, row=1, sticky=W)
        self._y_coord = Label(parent, text=self._entries["y_coordinate"])
        self._y_coord.grid(column=3, row=1, stick=W)
        self._mesh = Entry(parent, width=15, text=self._entries["mesh"])
        if self._entries["mesh"] is None:
            self._mesh.insert(0, "No mesh loaded")
        else:
            self._mesh.insert(0, self._entries["mesh"])
        self._mesh.grid(column=1, row=2, columnspan=2, sticky=W)
        Button(parent, text="Load", width=5, command=self._load_mesh, default=ACTIVE).grid(column=3, row=2)

        self._scale = Scale(parent, from_=1, to=100, orient=HORIZONTAL, length=140, variable=self._scale_text, showvalue=0)
        if self._entries["scale"] is not None:
            self._scale.set(self._entries["scale"])
            self._scale_text.set(str(self._entries["scale"]))
        self._scale.grid(row=3, column=2, columnspan=2, sticky=W)

    def validate(self):
        (result, message) = DataValidator.validate(DataStore.EVENT.OBJECT_EDIT,
            {
                "name"  :   self._entries["name"],
                "mesh"  :   self._mesh.get()
            })
        if result is not True:
            tkMessageBox.showerror("Input Error", message)
        return result

    def apply(self):
        self._entries["scale"] = self._scale.get()
        self._entries["mesh"] = self._mesh.get()

    def _load_mesh(self):
        """
        Open a file dialog to load a mesh filepath
        :return:
        """
        Debug.printi("Load Mesh called", Debug.Level.INFO)
        types = \
            [
                ("DirectX", "*.x")
            ]
        dialog = tkFileDialog.Open(self, filetypes=types)
        file_path = dialog.show()

        file_path = self._move_img(file_path)

        self._mesh.delete(0, END)
        self._mesh.insert(0, str(file_path))
        Debug.printi("Mesh Filepath:" + file_path, Debug.Level.INFO)

    def _move_img(self, file_path):
        """
        Move the DirectX file to the Data folder automagically
        :param file_path:           The file path of the file to be moved
        :return:
        """
        try:
            src = file_path
            file_name = self._scrub_name(file_path)
            dest = os.path.dirname(os.path.realpath(__file__)) + "/" + file_name
            shutil.copy(src, dest)
#.........这里部分代码省略.........
开发者ID:twisty-n,项目名称:MazeBuilder,代码行数:103,代码来源:DiaDoges.py

示例6: SteeringFrame

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import get [as 别名]
class SteeringFrame(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)   
        self.parent = parent
        self.initialize()
        
    def initialize(self):
        self.grid()
        self.entryVariable = StringVar()
        self.entry = Entry(self, textvariable=self.entryVariable)
        self.entry.grid(column=0,row=0,sticky='EW')
        self.entry.bind("<Return>", self.OnPressEnter)

        button = Button(self,text="Set Steering", command=self.OnButtonClick)
        button.grid(column=1,row=0)

        self.labelVariable = StringVar()
        label = Label(self,textvariable=self.labelVariable,
                              anchor="w",fg="white",bg="green")
        label.grid(column=0,row=1,columnspan=1,sticky='EW')
        self.labelVariable.set("Start..")

        left = Button(self,text="Left", command=self.Left)
        left.grid(column=0,row=2)

        right = Button(self,text="Right", command=self.Right)
        right.grid(column=1,row=2)

        centre = Button(self,text="Centre", command=self.Centre)
        centre.grid(column=3,row=2)

        self.steerVariable = StringVar()
        steerState = Label(self,textvariable=self.steerVariable,
                           anchor="w",fg="white",bg="green")
        steerState.grid(column=0,row=3,columnspan=1,sticky='EW')
        self.steerVariable.set("Start..")
        
        self.turn_angle = steering.GetTurnAngle();
        
        self.slider = Scale(self, from_=-self.turn_angle, to=self.turn_angle, 
                            orient=HORIZONTAL, command=self.setSteerState)
        self.slider.grid(column=0, row=4, columnspan=3, sticky='EW')        

        self.grid_columnconfigure(0,weight=1)
        self.update()
        #self.geometry(self.geometry()) # caused busy wait?
        self.entry.focus_set()
        #self.entry.selection_range(0, Tkinter.END) # caused busy wait?

    def OnButtonClick(self):
        steerAngle = int(self.entryVariable.get())
        steering.SetAngle(steerAngle)
        self.slider.set(steerAngle)
        self.labelVariable.set("Steering set: " + str(steerAngle) )
        self.entry.focus_set()
        self.entry.selection_range(0, END)
        
    def OnPressEnter(self,event):
        steerAngle = int(self.entryVariable.get())
        steering.SetAngle(steerAngle)
        self.slider.set(steerAngle)
        self.labelVariable.set("Steering set: " + str(steerAngle) )
        self.entry.focus_set()
        self.entry.selection_range(0, END)


    def Left(self):
        self.steerVariable.set("LEFT")
        steering.TurnLeft()
        self.slider.set(-self.turn_angle)

    def Right(self):
        self.steerVariable.set("RIGHT")
        steering.TurnRight()
        self.slider.set(self.turn_angle)

    def Centre(self):
        self.steerVariable.set("CENTRE")
        steering.TurnStraight()
        self.slider.set(0)
        
    def setSteerState(self, val):
        val = self.slider.get()
        steering.SetAngle(val)
        steerAngle = val;
        self.steerVariable.set("Steering: " + str(val) )           
开发者ID:NissankaW,项目名称:Mariokart3,代码行数:88,代码来源:GUI.py

示例7: Vibration

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import get [as 别名]
class Vibration(Frame):
    def __init__(self, parent, name="X", color="red"):
        """
        Description :
          Calcul d'une vibration harmonique du type : e=a*sin(2*pi*f*t+p)
        Proprietes :
          -  un parent (classe Oscilloscope)
          -  controleurs d'amplitude, frequence, phase (classe Scale)
        Methodes :
          - update_vibration(self, event) : callback si modification de controleurs
          - compute(self,a,f,p) : calcul de vibration harmonique
        """
        Frame.__init__(self)
        self.configure(bd=1, relief="sunken")
        self.parent = parent
        self.name = name
        self.scale_A = Scale(self, length=300, orient="horizontal",
                label=name + " Amplitude", showvalue=1, from_=0, to=10,
                tickinterval=1, command=self.update_vibration)

        self.scale_P = Scale(self, length=300, orient="horizontal",
                label=name + " Phase", showvalue=1, from_=0, to=90,
                tickinterval=20, command=self.update_vibration)

        self.scale_F = Scale(self, length=300, orient="horizontal",
                label=name + " Fréquence", showvalue=1, from_=0, to=100,
                tickinterval=10, command=self.update_vibration)

        self.scale_A.pack(expand="yes", fill="both")
        self.scale_P.pack(expand="yes", fill="both")
        self.scale_F.pack(expand="yes", fill="both")

    def update_vibration(self, event):
        """
        mise  a jour de courbe si modifications (amplitude, frequence, phase)
        """
        print("Vibration.update_vibration()")
        print("Amplitude :", self.scale_A.get())
        curve = self.compute(self.scale_A.get(), self.scale_F.get(),self.scale_P.get(), self.parent.get_time())
        if not isinstance(self.parent, Tk):
            self.parent.draw_curve(self.name, curve)

    def compute(self, a=0, f=0, p=0, timeBase=1):
        """
        Calcul de l'elongation en fonction de base de temps, amplitude, frequence, phase
        """
        curve = []
        print("Vibration.compute()")
        if not isinstance(self.parent, Tk):
            print("Base de Temps :", timeBase)
            #t = self.parent.get_time()
            #curve.append((self.scale_A.get() + 10*t, self.scale_A.get() + 10*t))
            #curve.append((self.scale_A.get() + 20*t, self.scale_A.get() + 20*t))
            # calcul des points de la courbe en fct de la base de temps (cf poly)

            for t in range(0, 1001, 5):
                e = a*sin(2*pi*f*t/1000*timeBase-p)
                x = t
                y = e
                curve.append((x,y))
        return curve
开发者ID:Akanoa,项目名称:CAI2014,代码行数:63,代码来源:vibration.py

示例8: ToolBar

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import get [as 别名]

#.........这里部分代码省略.........
		self.bSD = Button(bottomBar, text="SD", width=BWIDTH, command=self.doSD, state=DISABLED)
		self.bSD.pack(side=LEFT, padx=2, pady=2)
		
		self.bPrintMode = PR_PRINT		
		self.bPrint = Button(bottomBar, text=printText[PR_PRINT], width=BWIDTH, command=self.doPrint, state=DISABLED)
		self.bPrint.pack(side=LEFT, padx=2, pady=2)
		
		self.bPauseMode = PM_PAUSE
		self.bPause = Button(bottomBar, text=pauseText[PM_PAUSE], width=BWIDTH, command=self.doPause, state=DISABLED)
		self.bPause.pack(side=LEFT, padx=2, pady=2)

		self.bAbandon = Button(bottomBar, text="Abandon SD Print", width=BWIDTH+8, command=self.doAbandon, state=DISABLED)
		self.bAbandon.pack(side=LEFT, padx=2, pady=2)
		
		self.cbvLiftOnPause = IntVar()
		if self.settings.liftonpause:
			self.cbvLiftOnPause.set(1)
		else:
			self.cbvLiftOnPause.set(0)
		self.cbLiftOnPause = Checkbutton(bottomBar, text="Lift Head/Retract on Pause", variable=self.cbvLiftOnPause,
			command=self.clickLiftOnPause)
		self.cbLiftOnPause.pack(side=LEFT, padx=2)

		self.cbvResumeAtPause = IntVar()
		if self.settings.resumeatpausepoint:
			self.cbvResumeAtPause.set(1)
		else:
			self.cbvResumeAtPause.set(0)
		self.cbResumeAtPause = Checkbutton(bottomBar, text="Resume print at pause point", variable=self.cbvResumeAtPause,
			command=self.clickResumeAtPause)
		self.cbResumeAtPause.pack(side=LEFT, padx=2)
		
	def clickAssertFan(self):
		if self.cbvAssertFan.get() == 1:
			self.settings.forcefanspeed = True
			self.settings.setModified()
		else:
			self.settings.forcefanspeed = False
			self.settings.setModified()
		
	def clickLiftOnPause(self):
		if self.cbvLiftOnPause.get() == 1:
			self.settings.liftonpause = True
			self.settings.setModified()
		else:
			self.settings.liftonpause = False
			self.settings.setModified()
		
	def clickResumeAtPause(self):
		if self.cbvResumeAtPause.get() == 1:
			self.settings.resumeatpausepoint = True
			self.settings.setModified()
		else:
			self.settings.resumeatpausepoint = False
			self.settings.setModified()
	
	def setSliceText(self):
		if self.settings.slicer == SLIC3R:
			sl = "slic3r:%s" % self.app.slic3r.getProfile()
		else:
			sl = "skeinforge:%s" % self.app.skeinforge.getProfile()
		sliceText[SM_SLICE] = "Slice (%s)" % sl
		if self.bSliceMode == SM_SLICE:
			self.bLoad.config(state=NORMAL)
			self.app.allowLoadGCodeMenu(True)
			lt = len(sliceText[SM_SLICE])+2
开发者ID:jbernardis,项目名称:repraphost,代码行数:70,代码来源:toolbar.py

示例9: SettingWindow

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import get [as 别名]

#.........这里部分代码省略.........
        f13.grid(row=1, columnspan=2, pady=5, padx=5)
        Label(f13, text=u"     \N{GREEK SMALL LETTER SIGMA}").grid(row=1, column=0)
        self.dots_distance_scale = Scale(f13, from_=1, to=20, resolution=1, orient=HORIZONTAL, length=90)
        self.dots_distance_scale.set(6)
        self.dots_distance_scale.grid(row=0, column=1, rowspan=2)

        f14 = ttk.Labelframe(frame_other, text="Tracks")
        f14.grid(row=0, column=3, pady=5, padx=5)
        Label(f14, text="N").grid(row=1, column=0)
        self.num_frames_tracks_spinbox = Spinbox(f14, from_=2, to=num_frames, width=10)
        self.num_frames_tracks_spinbox.delete(0, END)
        self.num_frames_tracks_spinbox.insert(END, num_frames)
        self.num_frames_tracks_spinbox.grid(row=0, column=1, rowspan=2)

        Label(f14, text=u"\N{GREEK SMALL LETTER TAU}").grid(row=3, column=0)
        self.gaps_scale = Scale(f14, from_=1, to=10, resolution=1, orient=HORIZONTAL, length=90)
        self.gaps_scale.set(2)
        self.gaps_scale.grid(row=2, column=1, rowspan=2)

        self.notebook.pack(padx=1, pady=1)

        save_button = Button(self, text=" Save and Close window ", command=self.withdraw)
        save_button.pack(pady=2)

    def _select_all(self):
        for i, var in enumerate(self.features_vars):
            var.set(1)

    def _clear_selection(self):
        for i, var in enumerate(self.features_vars):
            var.set(0)

    def change_mser(self):
        rand_row = random.randint(1, 512-200)
        rand_col = random.randint(1, 512-110)
        self.mser_area = self.mser_image[rand_row:rand_row+180, rand_col:rand_col+100]

        self.update_mser_image(self.mser_area)

    def try_mser(self):
        delta = self.delta_scale.get()
        min_area = self.min_area_scale.get()
        max_area = self.max_area_scale.get()

        image = self.mser_area
        red_c = image[:,:,0]
        red_c = cv2.equalizeHist(red_c)

        det_img = image.copy()

        mser = cv2.MSER(delta, _min_area=min_area, _max_area=max_area)
        regions = mser.detect(red_c)
        cp = list()
        new_c = np.zeros(self.mser_area.shape, dtype=np.uint8)
        for r in regions:
            for point in r:
                cp.append(point)
                det_img[point[1], point[0], 0] = 0
                det_img[point[1], point[0], 1] = 0
                det_img[point[1], point[0], 2] = 204
                #new_c[point[1], point[0]] = 255

        self.update_mser_image(det_img)

    def update_mser_image(self, new_image):
        self.mser_img_array = Image.fromarray(new_image)
        self.mser_img.paste(self.mser_img_array)

    def get_patch_size(self):
        patch_size = self.patch_size_spinbox.get()
        return int(patch_size)

    def get_num_frames_tracks(self):
        num_frames_tracks = self.num_frames_tracks_spinbox.get()
        return int(num_frames_tracks)

    def get_mser_opts(self):
        return [self.delta_scale.get(), self.min_area_scale.get(), self.max_area_scale.get()]

    def get_forest_opts(self):
        return [self.num_trees_scale.get(), self.depth_tree_scale.get(), self.percentage_feats_scale.get()]

    def get_low_thresh(self):
        return self.low_thresh_scale.get()

    def get_high_thresh(self):
        return self.high_thresh_scale.get()

    def get_dots_distance(self):
        return int(self.dots_distance_scale.get())

    def get_selection_mask(self):
        if self.selection is not None:
            return self.selection

        selection_mask = np.zeros((self.max_num_feats, ), dtype='bool')
        for i, var in enumerate(self.features_vars):
            selection_mask[i] = var.get()
        self.selection = selection_mask
        return selection_mask
开发者ID:jhowarth15,项目名称:celldetector,代码行数:104,代码来源:SettingWindow.py

示例10: send_values

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import get [as 别名]
def send_values(_):
	vr, vg, vb = r.get(), g.get(), b.get()
	res = "{},{},{}".format(vr, vg*212.0/255.0, vb*164.0/255.0)
	print res
	ser.write(res+'\n')
	ard = ser.readline()
	print ard
	ard = ser.readline()
	print ard

master = Tk()
r = Scale(master, from_=0, to=255, length=250, 
		  orient=HORIZONTAL, label="red",
		  command=send_values)
r.pack()
g = Scale(master, from_=0, to=255, length=250, 
		  orient=HORIZONTAL, label="green",
		  command=send_values)
g.pack()
b = Scale(master, from_=0, to=255, length=250, 
		  orient=HORIZONTAL, label="blue",
		  command=send_values)
b.pack()
master.geometry('{}x{}'.format(300, 200))

print r.get()


mainloop()
开发者ID:ice3,项目名称:sunlight_alarm_clock,代码行数:31,代码来源:calibration.py

示例11: Scraper

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import get [as 别名]
class Scraper():

    def __init__(self, img_filename='snap.png'):
        self.canvas = Canvas()
        self.scales = []
        self.canvas.pack()
        self._current_image = None
        self._original_image = None
        
        self.root = self._load_gui()
        self.open_image(img_filename)
        self.repaint()
        self.root.mainloop()

    @property
    def image(self):
        return self._current_image

    @image.setter
    def image(self, value):
        self._current_image = value

    @property
    def original_image(self):
        return self._original_image

    @image.setter
    def image(self, value):
        self._original_image = value

    def open_image(self, filename):
        self.original_image = Image.open(filename).copy()
        self.image = self.original_image

    def repaint(self):
        rgb_min = (self.scale_red_min.get(), self.scale_green_min.get(), self.scale_blue_min.get())
        rgb_max = (self.scale_red_max.get(), self.scale_green_max.get(), self.scale_blue_max.get())
        print "repainting", rgb_min, rgb_max
        self.image = strip_colors(self.original_image, rgb_min, rgb_max)
        self._paint(self.image)

    def _paint(self, image):
        if image is not None:
            # check if we need to resize the canvas, based on the size of the image being painted
            image_width, image_height = image.size
            if self.canvas.winfo_width() != image_width or self.canvas.winfo_height() != image_height:
                self.canvas.config(width=image_width, height=image_height)

            # paint the image to the canvas
            self._img_tk = ImageTk.PhotoImage(image)
            self.canvas.create_image(0, 0, image=self._img_tk, anchor=NW)
        else:
            print 'there is no image to paint'
            return -1
 
    def _load_gui(self):
        root = Tk()
        root.title("Scraper")
        main_frame = Frame(root)
        main_frame.grid(column=0, row=0, sticky=(N, W, E, S))
        main_frame.columnconfigure(0, weight=1)
        main_frame.rowconfigure(0, weight=1)
        main_frame.pack()
        
        self.scale_red_min = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_red_min)
        self.scale_red_min.grid(column=1, row=1)
       
        self.scale_red_max = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_red_max)
        self.scale_red_max.grid(column=2, row=1)
        self.scale_red_max.set(255)
        
        self.scale_green_min = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_green_min)
        self.scale_green_min.grid(column=1, row=2)

        self.scale_green_max = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_green_max)
        self.scale_green_max.grid(column=2, row=2)
        self.scale_green_max.set(255)

        self.scale_blue_min = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_blue_min)
        self.scale_blue_min.grid(column=1, row=3)
        
        self.scale_blue_max = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_blue_max)
        self.scale_blue_max.grid(column=2, row=3)
        self.scale_blue_max.set(255)
        return root

    def _update_red_min(self, value):
        print 'updating red min to %s' % value
        if self.scale_red_min.get() > self.scale_red_max.get():
            self.scale_red_max.set(self.scale_red_min.get())
        self.repaint()

    def _update_red_max(self, value):
        print 'updating red max to %s' % value
        if self.scale_red_max.get() < self.scale_red_min.get():
            self.scale_red_min.set(self.scale_red_max.get())
        self.repaint()

    def _update_green_min(self, value):
        print 'updating green min to %s' % value
#.........这里部分代码省略.........
开发者ID:protobuf,项目名称:dsbot,代码行数:103,代码来源:scraper.py

示例12: EnviroDialog

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import get [as 别名]
class EnviroDialog(Dialog):
    """
    Dialog for editing the simulation environment details
    """
    def __init__(self, parent, populator=None, manager=None):
        """
        Construct the dialog
        :param parent:          The tk element that is the parent of the dialog
        :return:                An instance of EnviroDialog
        """
        self._entries = {
            "floor_texture": None,
            "wall_height": None,
            "edge_width": None,
            "sky_texture": None,
            "start_node": None
        }
        Dialog.__init__(self, parent=parent, title="EnvironmentConfiguration", populator=populator, manager=manager)

    def body(self, parent):
        """
        Overridden method defining the body of the dialog
        :param parent:
        :return:
        """
        self._floorSel = ImagePicker(parent, "Floor Texture:",
                                     default=self._entries["floor_texture"], auto_move=True, move_fold="Data")
        self._floorSel.grid(row=0, columnspan=4)
        self._skySel = ImagePicker(parent, "Sky Texture:", default=self._entries["sky_texture"], auto_move=True, move_fold="Data")
        self._skySel.grid(row=1, columnspan=4)

        Label(parent, text="Wall Height:", width=10, anchor=W).grid(row=2, column=0, sticky=W)
        Label(parent, text="Edge Width:", width=10, anchor=W).grid(row=3, column=0, sticky=W)

        self._wallScale = Scale(parent, from_=10, to=1000, orient=HORIZONTAL)
        if self._entries["wall_height"] is not None:
            self._wallScale.set(self._entries["wall_height"])
        self._wallScale.grid(row=2, column=1, columnspan=2, sticky=W)

        self._edgeScale = Scale(parent, from_=10, to=1000, orient=HORIZONTAL)
        if self._entries["edge_width"] is not None:
            self._edgeScale.set(self._entries["edge_width"])
        self._edgeScale.grid(row=3, column=1, columnspan=2, sticky=W)

        Label(parent, text="Starting Node:", anchor=W).grid(row=4, column=0, sticky=W)
        self._start_node = Label(parent, text=self._entries["start_node"], anchor=W)
        self._start_node.grid(row=4, column=1, sticky=W)

    def populate(self, manager):

        self._entries["floor_texture"]  = manager.floor_texture
        self._entries["edge_width"]     = manager.edge_width
        self._entries["sky_texture"]    = manager.sky_texture
        self._entries["start_node"]     = manager.start_node
        self._entries["edge_width"]     = manager.edge_width
        self._entries["wall_height"]    = manager.wall_height

    def validate(self):
        (result, message) = DataValidator.validate(DataStore.EVENT.ENVIRONMENT_EDIT, {
            "floor_texture" : self._floorSel.get(),
            "sky_texture"   : self._skySel.get()
        })
        if result is not True:
            tkMessageBox.showerror("Input Error", message)
        return result

    def apply(self):
        self._entries["floor_texture"] = self._floorSel.get()
        self._entries["edge_width"] = self._edgeScale.get()
        self._entries["sky_texture"] = self._skySel.get()
        self._entries["wall_height"] = self._wallScale.get()
        self._manager.inform(DataStore.EVENT.ENVIRONMENT_EDIT, self._entries)

    def auto_populate(self):
        self._floorSel.set(Defaults.Environment.FLOOR_TEXTURE)
        self._skySel.set(Defaults.Environment.SKY_TEXTURE)
        self._wallScale.set(Defaults.Environment.WALL_HEIGHT)
        self._edgeScale.set(Defaults.Environment.EDGE_WIDTH)
        self._start_node.config(text=Defaults.Environment.START_NODE)
开发者ID:twisty-n,项目名称:MazeBuilder,代码行数:81,代码来源:DiaDoges.py

示例13: SPIFrame

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import get [as 别名]
class SPIFrame(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)   
        self.parent = parent
        self.initialize()
        
    def initialize(self):
        self.grid()
        self.entryVariable = StringVar()
        self.entry = Entry(self, textvariable=self.entryVariable)
        self.entry.grid(column=0,row=0,sticky='EW')
        self.entry.bind("<Return>", self.OnPressEnter)

        button = Button(self,text="SPI send", command=self.OnButtonClick)
        button.grid(column=1,row=0)
        
        #ramp = Button(self,text="RAMP", command=self.setlabvar)
        #ramp.grid(column=1,row=1)        

        self.labelVariable = StringVar()
        label = Label(self,textvariable=self.labelVariable,
                              anchor="w",fg="white",bg="blue")
        label.grid(column=0,row=1,columnspan=1,sticky='EW')
        self.labelVariable.set("Start..")
        
        self.slider = Scale(self, from_=0, to=80, orient=HORIZONTAL, 
                            command=self.setlabvar)
        self.slider.grid(column=0, row=2, columnspan=3, sticky='EW')
        
        self.PID = PIDTune(self)
        self.PID.grid(column=0, row=3, columnspan=3, sticky='EW')
        
        self.grid_columnconfigure(0,weight=1)
        self.update()
        #self.geometry(self.geometry()) # caused busy wait?
        self.entry.focus_set()
        #self.entry.selection_range(0, Tkinter.END) # caused busy wait?
        

        
        
    def setlabvar(self, val):
        val = self.slider.get()
        speed.SetAcceleration(val)
        accel = val;
        self.labelVariable.set("Duty set: " + str(val) )       
        

    def OnButtonClick(self):
        accel = int(self.entryVariable.get())
        self.slider.set(accel)
        speed.SetAcceleration(accel)
        self.labelVariable.set("Duty set: " + str(accel) )
        self.entry.focus_set()
        self.entry.selection_range(0, END)
        
    def OnPressEnter(self,event):
        accel = int(self.entryVariable.get())
        self.slider.set(accel)
        speed.SetAcceleration(accel)
        self.labelVariable.set("Duty set: " + str(accel) )
        self.entry.focus_set()
        self.entry.selection_range(0, END)
开发者ID:NissankaW,项目名称:Mariokart3,代码行数:65,代码来源:GUI.py

示例14: VRConfigDialog

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import get [as 别名]
class VRConfigDialog(Dialog):
    """
    Defines a custom dialog for editing the Virtual Reality params
    """
    def __init__(self, parent, populator=None, manager=None):
        """
        Construct the dialog
        """
        self._entries = {
            "frame_angle"    : None,
            "distortion"     : False,
            "windowed"      : False,
            "eye_height"     : None,
            "minimum_dist_to_wall"  : None

        }
        self._win_var = IntVar(0)
        self._distortion_var = IntVar(0)
        Dialog.__init__(self, parent=parent, title="VRConfiguration", populator=populator, manager=manager)

    def body(self, parent):
        """
        Overridden method defining the body of the dialog
        :param parent:
        :return:
        """

        # Define all of the labels for our options
        Label(parent, text="Frame Angle:", padx=3, anchor=SW, height=2).grid(row=0, column=0, sticky=W)
        Label(parent, text="Eye Height:", padx=3, anchor=SW, height=2).grid(row=1, column=0, pady=2, sticky=W )
        Label(parent, text="MinDistToWall:", padx=3, anchor=SW, height=2).grid(row=2, column=0, pady=2,  sticky=W)
        Label(parent, text="Distortion:", padx=3).grid(row=3, column=0, pady=2, sticky=W)
        Label(parent, text="Windowed:", padx=3).grid(row=4, column=0, pady=2, sticky=W)

        # Define the sub-widgets that the labels are referring to
        self._frameAngle = Scale(parent, from_=-20, to=20, orient=HORIZONTAL)
        if self._entries["frame_angle"] is not None:
            self._frameAngle.set(self._entries["frame_angle"])
        else:
            self._frameAngle.set(-5)
        self._frameAngle.grid(row=0, column=1, padx=3)

        self._eyeHeight = Scale(parent, from_=0, to=500, orient=HORIZONTAL)
        if self._entries["eye_height"] is not None:
            self._eyeHeight.set( self._entries["eye_height"] )
        else:
            self._eyeHeight.set(50)
        self._eyeHeight.grid(row=1, column=1, padx=3)

        self._minDistToWall = Scale(parent, from_=1, to=300, orient=HORIZONTAL)
        if self._entries["minimum_dist_to_wall"] is not None:
            self._minDistToWall.set( self._entries["minimum_dist_to_wall"] )
        else:
            self._minDistToWall.set(20)
        self._minDistToWall.grid(row=2, column=1, padx=3)

        self._distortion = Checkbutton(parent, variable=self._distortion_var, offvalue=0, onvalue=1, text="Enable", command=self._toggle_distortion)
        self._distortion.grid(row=3, column=1, padx=3)

        self._windowed = Checkbutton(parent, variable=self._win_var, offvalue=0, onvalue=1, text="Enable", command=self._toggle_windowed)
        self._windowed.grid(row=4, column=1, padx=3)

    def _toggle_distortion(self):
        """
        Toggle the distortion flag
        :return:
        """
        self._distortion_var.set(0 if self._distortion_var.get() == 1 else 1)
        val = self._entries["distortion"]
        self._entries["distortion"] = not val
        Debug.printi("Distortion toggled to " + (str(not val)), Debug.Level.INFO)
        self._distortion.toggle()

    def _toggle_windowed(self):
        """
        Toggle the windowed flag
        :return:
        """
        self._win_var.set(0 if self._win_var.get() == 1 else 1)
        val = self._entries["windowed"]
        self._entries["windowed"] = not val
        Debug.printi("Windowing toggled to " + (str(not val)), Debug.Level.INFO)
        self._windowed.toggle()

    def populate(self, manager):
        self._entries["frame_angle"]            = manager.frame_angle
        self._entries["distortion"]             = manager.distortion
        self._entries["windowed"]               = manager.windowed
        self._entries["eye_height"]             = manager.eye_height
        self._entries["minimum_dist_to_wall"]   = manager.minimum_dist_to_wall
        self._win_var.set( 0 if manager.windowed is False else 1 )
        self._distortion_var.set( 0 if manager.distortion is False else 1 )

    def validate(self):
        (result, message) = DataValidator.validate(DataStore.EVENT.VR_EDIT, self._entries)
        if result is not True:
            tkMessageBox.showerror("Input Error", message)
        return result

    def apply(self):
#.........这里部分代码省略.........
开发者ID:twisty-n,项目名称:MazeBuilder,代码行数:103,代码来源:DiaDoges.py

示例15: Generator

# 需要导入模块: from Tkinter import Scale [as 别名]
# 或者: from Tkinter.Scale import get [as 别名]
class Generator(Frame):
    """calcul d'une vibration harmonique du type : e=a*sin(2*pi*f*t+p)

    scale_A : controleur d'amplitude
    """
    def __init__(self, parent, name="X",color="red"):
        """ initialisation

        parent : un oscilloscope
        name : nom du signal
        """
        Frame.__init__(self)
        self.configure(bd=1, relief="sunken", background = color)
        self.parent = parent
        self.name = name
        self.color = color
        self.scale_A = Scale(self, length=300, orient="horizontal",
                label=name + " Amplitude", showvalue=1, from_=0, to=10,
                tickinterval=1, command=self.update_signal)

        self.scale_P = Scale(self, length=300, orient="horizontal",
                label=name + " Phase", showvalue=1, from_=0, to=90,
                tickinterval=20, command=self.update_signal)

        self.scale_F = Scale(self, length=300, orient="horizontal",
                label=name + " Fréquence", showvalue=1, from_=0, to=100,
                tickinterval=10, command=self.update_signal)

        self.scale_A.pack(expand="yes", fill="both")
        self.scale_P.pack(expand="yes", fill="both")
        self.scale_F.pack(expand="yes", fill="both")

    def update_signal(self, event):
        """mise a jour de courbe si modifications (amplitude, frequence, phase)."""
        #print("Vibration.update_signal()")
        #print("Amplitude :", self.scale_A.get())
        scaling=0.05
        amp = scaling*self.scale_A.get()
        fre = scaling*self.scale_F.get()
        pha = scaling*self.scale_P.get()
        signal = self.generate_signal(a=amp, f=fre, p=pha)
        if not isinstance(self.parent, Tk):
            self.parent.set_signal(self.name, signal, self.color)
        return signal

    def generate_signal(self, a=1.0, f=2.0, p=0):
        """Calcul de l'elongation, amplitude, frequence et phase sur une periode."""
        signal = []
        samples = 100
        for t in range(0, samples):
            samples = float(samples)
            e = a * sin((2*pi*f*(t/samples)) - p)
            signal.append((t/samples,e))
        return signal

    def get_parameter(self):
        """
        Récupère les valeurs des paramètres de la courbe et les renvoie sous forme d'un tuple
        """
        return [str(self.scale_A.get()), str(self.scale_F.get()), str(self.scale_P.get())]

    def set_parameter(self, amp=1.0, freq=2.0, phase=0):
        """
        Modifie les valeurs des paramètres de la courbe
        """
        self.scale_A.set(amp)
        self.scale_F.set(freq)
        self.scale_P.set(phase)
开发者ID:Akanoa,项目名称:CAI2014,代码行数:70,代码来源:generator.py


注:本文中的Tkinter.Scale.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。