我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用ttk.Scale()。
def _scale(self, from_, to, resolution, variable, position, command = None, kwargs = {}): if command is None: command = lambda s: variable.set(round(float(s), 3)) scale = ttk.Scale(self.frame1.sliders, from_ = from_, to = to, variable = variable, orient = "horizontal", length = 20, command = command, takefocus = False, **kwargs) if position == 1: scale.place(relwidth = 0.35, relx = 0, x = 0, y = 25, anchor = "nw") elif position == 2: scale.place(relwidth = 0.35, relx = 0, x = 0, y = 70, anchor = "nw") elif position == 3: scale.place(relwidth = 0.35, relx = 0.5, x = 0, y = 25, anchor = "nw") elif position == 4: scale.place(relwidth = 0.35, relx = 0.5, x = 0, y = 70, anchor = "nw") return scale
def checkParam(self, widget, name, value, expected=_sentinel, conv=False, eq=None): widget[name] = value if expected is _sentinel: expected = value if conv: expected = conv(expected) if self._stringify or not self.wantobjects: if isinstance(expected, tuple): expected = tkinter._join(expected) else: expected = str(expected) if eq is None: eq = tcl_obj_eq self.assertEqual2(widget[name], expected, eq=eq) self.assertEqual2(widget.cget(name), expected, eq=eq) # XXX if not isinstance(widget, Scale): t = widget.configure(name) self.assertEqual(len(t), 5) self.assertEqual2(t[4], expected, eq=eq)
def test_keys(self): widget = self.create() keys = widget.keys() # XXX if not isinstance(widget, Scale): self.assertEqual(sorted(keys), sorted(widget.configure())) for k in keys: widget[k] # Test if OPTIONS contains all keys if test.test_support.verbose: aliases = { 'bd': 'borderwidth', 'bg': 'background', 'fg': 'foreground', 'invcmd': 'invalidcommand', 'vcmd': 'validatecommand', } keys = set(keys) expected = set(self.OPTIONS) for k in sorted(keys - expected): if not (k in aliases and aliases[k] in keys and aliases[k] in expected): print('%s.OPTIONS doesn\'t contain "%s"' % (self.__class__.__name__, k))
def create(self, **kwargs): return ttk.Scale(self.root, **kwargs)
def setUp(self): support.root_deiconify() self.scale = ttk.Scale() self.scale.pack() self.scale.update()
def create_control_panel(self): frame=Tkinter.LabelFrame(self.root) frame.pack(expand='yes',fill='x',side='top') add_fileicon=Tkinter.PhotoImage(file="../Icons/add_file.gif") add_directoryicon=Tkinter.PhotoImage(file="../Icons/add_directory.gif") exiticon=Tkinter.PhotoImage(file="../Icons/exit.gif") playicon=Tkinter.PhotoImage(file="../Icons/play.gif") pauseicon=Tkinter.PhotoImage(file="../Icons/pause.gif") stopicon=Tkinter.PhotoImage(file="../Icons/stop.gif") rewindicon=Tkinter.PhotoImage(file="../Icons/rewind.gif") fast_forwardicon=Tkinter.PhotoImage(file="../Icons/fast_forward.gif") previous_trackicon=Tkinter.PhotoImage(file="../Icons/previous_track.gif") next_trackicon=Tkinter.PhotoImage(file="../Icons/next_track.gif") self.muteicon=Tkinter.PhotoImage(file="../Icons/mute.gif") self.unmuteicon=Tkinter.PhotoImage(file="../Icons/unmute.gif") delete_selectedicon=Tkinter.PhotoImage(file="../Icons/delete_selected.gif") list_file=[ (playicon,'self.play'), (pauseicon,'self.pause'), (stopicon,'self.stop'), (previous_trackicon,'self.previous'), (rewindicon,'self.rewind'), (fast_forwardicon,'self.fast'), (next_trackicon,'self.Next'),] for i,j in list_file: storeobj=ttk.Button(frame, image=i,command=eval(j)) storeobj.pack(side='left') storeobj.image=i self.volume_label=Tkinter.Button(frame,image=self.unmuteicon) self.volume_label.image=self.unmuteicon volume=ttk.Scale(frame,from_=Volume_lowest_value, to=Volume_highest_value ,variable=self.var, command=self.update_volume) volume.pack(side='right', padx=10, ) self.volume_label.pack(side='right') return