Python Tkinter.Scale() Examples
The following are 20
code examples of Tkinter.Scale().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
Tkinter
, or try the search function
.
Example #1
Source File: fisheye.py From DualFisheye with MIT License | 7 votes |
def _make_slider(self, parent, rowidx, label, inival, maxval, res=0.5): # Create shared variable and set initial value. tkvar = tk.DoubleVar() tkvar.set(inival) # Set a callback for whenever tkvar is changed. # (The 'command' callback on the SpinBox only applies to the buttons.) tkvar.trace('w', self._update_callback) # Create the Label, SpinBox, and Scale objects. label = tk.Label(parent, text=label) spbox = tk.Spinbox(parent, textvariable=tkvar, from_=0, to=maxval, increment=res) slide = tk.Scale(parent, orient=tk.HORIZONTAL, showvalue=0, variable=tkvar, from_=0, to=maxval, resolution=res) label.grid(row=rowidx, column=0) spbox.grid(row=rowidx, column=1) slide.grid(row=rowidx, column=2) return tkvar # Find the largest output size that fits within the given bounds and # matches the aspect ratio of the original source image.
Example #2
Source File: enhancer.py From mxnet-lambda with Apache License 2.0 | 6 votes |
def __init__(self, master, image, name, enhancer, lo, hi): tkinter.Frame.__init__(self, master) # set up the image self.tkim = ImageTk.PhotoImage(image.mode, image.size) self.enhancer = enhancer(image) self.update("1.0") # normalize # image window tkinter.Label(self, image=self.tkim).pack() # scale s = tkinter.Scale(self, label=name, orient=tkinter.HORIZONTAL, from_=lo, to=hi, resolution=0.01, command=self.update) s.set(self.value) s.pack()
Example #3
Source File: thresholder.py From mxnet-lambda with Apache License 2.0 | 6 votes |
def __init__(self, master, im, value=128): tkinter.Frame.__init__(self, master) self.image = im self.value = value self.canvas = tkinter.Canvas(self, width=im.size[0], height=im.size[1]) self.backdrop = ImageTk.PhotoImage(im) self.canvas.create_image(0, 0, image=self.backdrop, anchor=tkinter.NW) self.canvas.pack() scale = tkinter.Scale(self, orient=tkinter.HORIZONTAL, from_=0, to=255, resolution=1, command=self.update_scale, length=256) scale.set(value) scale.bind("<ButtonRelease-1>", self.redraw) scale.pack() # uncomment the following line for instant feedback (might # be too slow on some platforms) # self.redraw()
Example #4
Source File: agents.py From aima with MIT License | 6 votes |
def __init__(self, parent, env, canvas): super(EnvToolbar, self).__init__(parent, relief='raised', bd=2) # Initialize instance variables self.env = env self.canvas = canvas self.running = False self.speed = 1.0 # Create buttons and other controls for txt, cmd in [('Step >', self.env.step), ('Run >>', self.run), ('Stop [ ]', self.stop), ('List things', self.list_things), ('List agents', self.list_agents)]: tk.Button(self, text=txt, command=cmd).pack(side='left') tk.Label(self, text='Speed').pack(side='left') scale = tk.Scale(self, orient='h', from_=(1.0), to=10.0, resolution=1.0, command=self.set_speed) scale.set(self.speed) scale.pack(side='left')
Example #5
Source File: plot_wing.py From OpenAeroStruct with Apache License 2.0 | 5 votes |
def draw_slider(self): # scale to choose iteration to view self.w = Tk.Scale( self.options_frame, from_=0, to=self.num_iters - 1, orient=Tk.HORIZONTAL, resolution=1, font=tkFont.Font(family="Helvetica", size=10), command=self.update_graphs, length=200) if self.curr_pos == self.num_iters - 1 or self.curr_pos == 0 or self.var_ref.get(): self.curr_pos = self.num_iters - 1 self.w.set(self.curr_pos) self.w.grid(row=0, column=1, padx=5, sticky=Tk.W)
Example #6
Source File: test_geometry_managers.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def test_grid_size(self): with self.assertRaises(TypeError): self.root.grid_size(0) self.assertEqual(self.root.grid_size(), (0, 0)) f = tkinter.Scale(self.root) f.grid_configure(row=0, column=0) self.assertEqual(self.root.grid_size(), (1, 1)) f.grid_configure(row=4, column=5) self.assertEqual(self.root.grid_size(), (6, 5))
Example #7
Source File: test_widgets.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def create(self, **kwargs): return tkinter.Scale(self.root, **kwargs)
Example #8
Source File: ttk.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def __init__(self, master=None, variable=None, from_=0, to=10, **kw): """Construct an horizontal LabeledScale with parent master, a variable to be associated with the Ttk Scale widget and its range. If variable is not specified, a Tkinter.IntVar is created. WIDGET-SPECIFIC OPTIONS compound: 'top' or 'bottom' Specifies how to display the label relative to the scale. Defaults to 'top'. """ self._label_top = kw.pop('compound', 'top') == 'top' Frame.__init__(self, master, **kw) self._variable = variable or Tkinter.IntVar(master) self._variable.set(from_) self._last_valid = from_ self.label = Label(self) self.scale = Scale(self, variable=self._variable, from_=from_, to=to) self.scale.bind('<<RangeChanged>>', self._adjust) # position scale and label according to the compound option scale_side = 'bottom' if self._label_top else 'top' label_side = 'top' if scale_side == 'bottom' else 'bottom' self.scale.pack(side=scale_side, fill='x') tmp = Label(self).pack(side=label_side) # place holder self.label.place(anchor='n' if label_side == 'top' else 's') # update the label as scale or variable changes self.__tracecb = self._variable.trace_variable('w', self._adjust) self.bind('<Configure>', self._adjust) self.bind('<Map>', self._adjust)
Example #9
Source File: ttk.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def __init__(self, master=None, **kw): """Construct a Ttk Scale with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS command, from, length, orient, to, value, variable """ Widget.__init__(self, master, "ttk::scale", kw)
Example #10
Source File: gui_widgets.py From SVPV with MIT License | 5 votes |
def __init__(self, parent): tk.LabelFrame.__init__(self, parent) self.af_on = tk.IntVar(value=0) self.af_on_cb = tk.Checkbutton(self, text="AF Threshold", variable=self.af_on) self.af_on_cb.grid(row=0, column=0, padx=3, columnspan=2, sticky=tk.EW) self.af_var = tk.DoubleVar() self.af_gt_lt = tk.IntVar(value=1) self.af_lt_radio_button = tk.Radiobutton(self, text="<", variable=self.af_gt_lt, value=1) self.af_lt_radio_button.grid(row=1, column=0, sticky=tk.EW) self.af_gt_radio_button = tk.Radiobutton(self, text=">", variable=self.af_gt_lt, value=2) self.af_gt_radio_button.grid(row=1, column=1, sticky=tk.EW) self.af_scale = tk.Scale(self, variable=self.af_var, from_=float(0), to=float(1), resolution=float(0.01), orient=tk.HORIZONTAL) self.af_scale.grid(row=2, column=0, padx=3, sticky=tk.EW, columnspan=2)
Example #11
Source File: plot_wingbox.py From OpenAeroStruct with Apache License 2.0 | 5 votes |
def draw_slider(self): # scale to choose iteration to view self.w = Tk.Scale( self.options_frame, from_=0, to=self.num_iters - 1, orient=Tk.HORIZONTAL, resolution=1, font=tkFont.Font(family="Helvetica", size=10), command=self.update_graphs, length=200) if self.curr_pos == self.num_iters - 1 or self.curr_pos == 0 or self.var_ref.get(): self.curr_pos = self.num_iters - 1 self.w.set(self.curr_pos) self.w.grid(row=0, column=1, padx=5, sticky=Tk.W)
Example #12
Source File: test_geometry_managers.py From oss-ftp with MIT License | 5 votes |
def test_grid_size(self): with self.assertRaises(TypeError): self.root.grid_size(0) self.assertEqual(self.root.grid_size(), (0, 0)) f = tkinter.Scale(self.root) f.grid_configure(row=0, column=0) self.assertEqual(self.root.grid_size(), (1, 1)) f.grid_configure(row=4, column=5) self.assertEqual(self.root.grid_size(), (6, 5))
Example #13
Source File: test_widgets.py From oss-ftp with MIT License | 5 votes |
def create(self, **kwargs): return tkinter.Scale(self.root, **kwargs)
Example #14
Source File: ttk.py From oss-ftp with MIT License | 5 votes |
def __init__(self, master=None, variable=None, from_=0, to=10, **kw): """Construct an horizontal LabeledScale with parent master, a variable to be associated with the Ttk Scale widget and its range. If variable is not specified, a Tkinter.IntVar is created. WIDGET-SPECIFIC OPTIONS compound: 'top' or 'bottom' Specifies how to display the label relative to the scale. Defaults to 'top'. """ self._label_top = kw.pop('compound', 'top') == 'top' Frame.__init__(self, master, **kw) self._variable = variable or Tkinter.IntVar(master) self._variable.set(from_) self._last_valid = from_ self.label = Label(self) self.scale = Scale(self, variable=self._variable, from_=from_, to=to) self.scale.bind('<<RangeChanged>>', self._adjust) # position scale and label according to the compound option scale_side = 'bottom' if self._label_top else 'top' label_side = 'top' if scale_side == 'bottom' else 'bottom' self.scale.pack(side=scale_side, fill='x') tmp = Label(self).pack(side=label_side) # place holder self.label.place(anchor='n' if label_side == 'top' else 's') # update the label as scale or variable changes self.__tracecb = self._variable.trace_variable('w', self._adjust) self.bind('<Configure>', self._adjust) self.bind('<Map>', self._adjust)
Example #15
Source File: ttk.py From oss-ftp with MIT License | 5 votes |
def __init__(self, master=None, **kw): """Construct a Ttk Scale with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS command, from, length, orient, to, value, variable """ Widget.__init__(self, master, "ttk::scale", kw)
Example #16
Source File: ttk.py From BinderFilter with MIT License | 5 votes |
def __init__(self, master=None, variable=None, from_=0, to=10, **kw): """Construct an horizontal LabeledScale with parent master, a variable to be associated with the Ttk Scale widget and its range. If variable is not specified, a Tkinter.IntVar is created. WIDGET-SPECIFIC OPTIONS compound: 'top' or 'bottom' Specifies how to display the label relative to the scale. Defaults to 'top'. """ self._label_top = kw.pop('compound', 'top') == 'top' Frame.__init__(self, master, **kw) self._variable = variable or Tkinter.IntVar(master) self._variable.set(from_) self._last_valid = from_ self.label = Label(self) self.scale = Scale(self, variable=self._variable, from_=from_, to=to) self.scale.bind('<<RangeChanged>>', self._adjust) # position scale and label according to the compound option scale_side = 'bottom' if self._label_top else 'top' label_side = 'top' if scale_side == 'bottom' else 'bottom' self.scale.pack(side=scale_side, fill='x') tmp = Label(self).pack(side=label_side) # place holder self.label.place(anchor='n' if label_side == 'top' else 's') # update the label as scale or variable changes self.__tracecb = self._variable.trace_variable('w', self._adjust) self.bind('<Configure>', self._adjust) self.bind('<Map>', self._adjust)
Example #17
Source File: ttk.py From BinderFilter with MIT License | 5 votes |
def __init__(self, master=None, **kw): """Construct a Ttk Scale with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS command, from, length, orient, to, value, variable """ Widget.__init__(self, master, "ttk::scale", kw)
Example #18
Source File: PiScope.py From PiScope with MIT License | 5 votes |
def plot(self): if len(self.channels) < 1 or len(self.channels) > 2: print "The device can either operate as oscilloscope (1 channel) or x-y plotter (2 channels). Please operate accordingly." self._quit() else: print "Plotting will start in a new window..." try: # Setup Quit button button = Tkinter.Button(master=self.root, text='Quit', command=self._quit) button.pack(side=Tkinter.BOTTOM) # Setup speed and width self.scale1 = Tkinter.Scale(master=self.root,label="View Width:", from_=3, to=1000, sliderlength=30, length=self.ax.get_window_extent().width, orient=Tkinter.HORIZONTAL) self.scale2 = Tkinter.Scale(master=self.root,label="Generation Speed:", from_=1, to=200, sliderlength=30, length=self.ax.get_window_extent().width, orient=Tkinter.HORIZONTAL) self.scale2.pack(side=Tkinter.BOTTOM) self.scale1.pack(side=Tkinter.BOTTOM) self.scale1.set(4000) self.scale2.set(self.scale2['to']-10) self.root.protocol("WM_DELETE_WINDOW", self._quit) if len(self.channels) == 1: self.values = [] else: self.valuesx = [0 for x in range(4000)] self.valuesy = [0 for y in range(4000)] self.root.after(4000, self.draw) Tkinter.mainloop() except Exception, err: print "Error. Try again." print err self._quit()
Example #19
Source File: DeepBrainSegUI.py From DeepBrainSeg with MIT License | 4 votes |
def init_scales(self, vol): """ """ self.slice1 = vol.shape[0]//2 self.slice2 = vol.shape[1]//2 self.slice3 = vol.shape[2]//2 x_size, y_size, z_size = vol.shape self.Scale1 = tk.Scale(self.Frame10, from_=0.0, to=z_size) self.Scale1.place(relx=0.871, rely=0.025, relwidth=0.0, relheight=0.942 , width=46, bordermode='ignore') self.Scale1.configure(activebackground="#f9f9f9") self.Scale1.configure(command=self.AxialScroll) self.Scale1.configure(length="368") self.Scale1.configure(troughcolor="#d9d9d9") self.Scale2 = tk.Scale(self.Frame11, from_=0.0, to=y_size) self.Scale2.place(relx=0.871, rely=0.025, relwidth=0.0, relheight=0.942 , width=46, bordermode='ignore') self.Scale2.configure(activebackground="#f9f9f9") self.Scale2.configure(command=self.SagitalScroll) self.Scale2.configure(digits="50") self.Scale2.configure(length="368") self.Scale2.configure(troughcolor="#d9d9d9") self.Scale3 = tk.Scale(self.Frame12, from_=0.0, to=x_size) self.Scale3.place(relx=0.871, rely=0.025, relwidth=0.0, relheight=0.942 , width=46, bordermode='ignore') self.Scale3.configure(activebackground="#f9f9f9") self.Scale3.configure(command=self.CorronalScroll) self.Scale3.configure(length="368") self.Scale3.configure(troughcolor="#d9d9d9") self.TProgressbar1 = ttk.Progressbar(self.Frame2) self.TProgressbar1.place(relx=0.007, rely=0.948, relwidth=0.981 , relheight=0.0, height=19) self.TProgressbar1.configure(variable=self.progress_bar) self.overlay_flag = False # =================================================================
Example #20
Source File: fisheye.py From DualFisheye with MIT License | 4 votes |
def _make_slider(self, parent, rowidx, label, inival): # Set limits and resolution. lim = 1.0 res = 0.001 # Create shared variable. tkvar = tk.DoubleVar() tkvar.set(inival) # Set a callback for whenever tkvar is changed. # (The 'command' callback on the SpinBox only applies to the buttons.) tkvar.trace('w', self._update_callback) # Create the Label, SpinBox, and Scale objects. label = tk.Label(parent, text=label) spbox = tk.Spinbox(parent, textvariable=tkvar, from_=-lim, to=lim, increment=res) slide = tk.Scale(parent, orient=tk.HORIZONTAL, showvalue=0, variable=tkvar, from_=-lim, to=lim, resolution=res) label.grid(row=rowidx, column=0, sticky='W') spbox.grid(row=rowidx, column=1) slide.grid(row=rowidx, column=2) return tkvar # Thin wrapper for update_preview(), used to strip Tkinter arguments.