本文整理汇总了Python中Tkinter.Scale类的典型用法代码示例。如果您正苦于以下问题:Python Scale类的具体用法?Python Scale怎么用?Python Scale使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Scale类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
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")
示例2: __init__
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")
示例3: TimeBase
class TimeBase(Frame):
def __init__(self, parent=None):
"""
Description :
Creation d'un controleur pour la base de temps
Proprietes :
- un parent (classe Oscilloscope)
- controleur de la base de temps (classe Scale)
Methodes :
- update_time_base(self, event) : callback de demande de mise a jour sur l'oscilloscope
- get_time(self) : observateur sur la valeur de la base de temps
"""
Frame.__init__(self)
self.configure(bd=1, relief="sunken")
self.parent = parent
self.scale_T = Scale(self, length=300, orient="horizontal",
label="Temps", showvalue=1, from_=1, to=10,
tickinterval=1, command=self.update_time_base)
self.scale_T.pack(expand="yes", fill="both")
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_T.get())
if not isinstance(self.parent, Tk):
self.parent.update_time(self.scale_T.get())
def get_time(self):
"""
Retour : valeur courante de la base de temps
"""
return self.scale_T.get()
示例4: __init__
def __init__(self, parent, name="X"):
"""
Initialisation
parent : un oscilloscope
name : nom du signal
"""
Frame.__init__(self)
self.configure(bd=1, relief="sunken")
self.parent = parent
self.name = name
self.drawVar = IntVar()
self.signal = None
self.draw = Checkbutton(self,text="Afficher "+self.name, selectcolor=eval('self.parent.view.color_'+name), variable=self.drawVar, onvalue = 1, offvalue = 0, command=self.parent.plot_all)
self.draw.pack()
self.draw.select()
self.scale_A = Scale(self, length=100, orient="horizontal",
label=name + " Amplitude", showvalue=1, from_=0, to=10,
tickinterval=1, command=self.update_signal)
self.scale_A.pack(expand="yes", fill="both")
self.scale_F = Scale(self, length=100, orient="horizontal",
label=name + " Fréquence", showvalue=1, from_=1, to=10,
tickinterval=1, command=self.update_signal)
self.scale_F.pack(expand="yes", fill="both")
self.scale_P = Scale(self, length=100, orient="horizontal",
label=name + " Phase", showvalue=1, from_=0, to=10,
tickinterval=1, command=self.update_signal)
self.scale_P.pack(expand="yes", fill="both")
self.bind("<Configure>",self.update_signal)
示例5: setup_gui
def setup_gui(self):
Visualiser.setup_gui(self)
self.tk_quit.grid(row=0, column=0, sticky=W+E)
self.tk_movie_toggle = Button(self.tk_controlFrame, text="Movie off", command=self.movie_toggle)
self.tk_movie_toggle.grid(row=0, column=6, sticky=W+E)
self.tk_restart = Button(self.tk_controlFrame, text="<<<", command=self.restart, width=5)
self.tk_restart.grid(row=1, column=0, sticky=W+E)
self.tk_back10 = Button(self.tk_controlFrame, text="<<", command=self.back10, width=5)
self.tk_back10.grid(row=1, column=1, sticky=W+E)
self.tk_back = Button(self.tk_controlFrame, text="<", command=self.back, width=5)
self.tk_back.grid(row=1, column=2, sticky=W+E)
self.tk_pauseResume = Button(self.tk_controlFrame, text="Pause", command=self.pauseResume, width=15)
self.tk_pauseResume.grid(row=1, column=3, sticky=W+E)
self.tk_forward = Button(self.tk_controlFrame, text=">", command=self.forward, width=5)
self.tk_forward.grid(row=1, column=4, sticky=W+E)
self.tk_forward10 = Button(self.tk_controlFrame, text=">>", command=self.forward10, width=5)
self.tk_forward10.grid(row=1, column=5, sticky=W+E)
self.tk_forwardEnd = Button(self.tk_controlFrame, text=">>>", command=self.forwardEnd, width=5)
self.tk_forwardEnd.grid(row=1, column=6, sticky=W+E)
self.tk_frameNumber = Label(self.tk_controlFrame, text='Frame')
self.tk_frameNumber.grid(row=2, column=0, sticky=W+E)
self.tk_gotoFrame = Scale(self.tk_controlFrame, from_=0, to=self.maxFrameNumber, orient=HORIZONTAL)
self.tk_gotoFrame.grid(row=2, column=1, columnspan=2, sticky=W+E)
self.tk_stepLabel = Label(self.tk_controlFrame, text='Step')
self.tk_stepLabel.grid(row=2, column=4, sticky=W+E)
self.tk_frameStep = Scale(self.tk_controlFrame, from_=0, to=self.maxFrameNumber, orient=HORIZONTAL)
self.tk_frameStep.grid(row=2, column=5, columnspan=2, sticky=W+E)
# Make the buttons stretch to fill all available space
for i in range(7):
self.tk_controlFrame.grid_columnconfigure(i, weight=1)
示例6: body
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)
示例7: create_ranges
def create_ranges(self):
counter = 0
for ran in RANGES:
setattr(self, 'min_' + ran, RANGES[ran]['min'])
setattr(self, 'max_' + ran, RANGES[ran]['max'])
self.this_min_scale = Scale(self, label='min ' + ran, orient=HORIZONTAL,
from_=getattr(self, 'min_' + ran),
to=getattr(self, 'max_' + ran),
resolution=RANGES[ran]['res'])
self.this_max_scale = Scale(self, label='max ' + ran, orient=HORIZONTAL,
from_=getattr(self, 'min_' + ran),
to=getattr(self, 'max_' + ran),
resolution=RANGES[ran]['res'])
self.this_min_scale.set(RANGES[ran]['min_start'])
self.this_max_scale.set(RANGES[ran]['max_start'])
self.this_min_scale.enable = ('enable' in RANGES[ran].keys() and
RANGES[ran]['enable'] or None)
self.this_min_scale.disable = ('disable' in RANGES[ran].keys() and
RANGES[ran]['disable'] or None)
self.this_max_scale.enable = ('enable' in RANGES[ran].keys() and
RANGES[ran]['enable'] or None)
self.this_max_scale.disable = ('disable' in RANGES[ran].keys() and
RANGES[ran]['disable'] or None)
self.this_min_scale.grid(column=2, row=counter, sticky=E + W)
self.this_max_scale.grid(column=2, row=counter + 1, sticky=E + W)
self.this_min_scale.ref = 'min_' + ran
self.this_max_scale.ref = 'max_' + ran
self.this_min_scale.bind("<ButtonRelease>", self.scale_handler)
self.this_max_scale.bind("<ButtonRelease>", self.scale_handler)
counter += 2
示例8: create_monitor
def create_monitor(self):
self.monitor_frame = LabelFrame(self, text="Monitor and Transport")
this_cycle = Scale(self.monitor_frame, label='cycle_pos', orient=HORIZONTAL,
from_=1, to=16, resolution=1)
this_cycle.disable, this_cycle.enable = (None, None)
this_cycle.ref = 'cycle_pos'
this_cycle.grid(column=0, row=0, sticky=E + W)
self.updateButton = Button(self.monitor_frame,
text='Reload all Settings',
command=self.request_update)
self.updateButton.grid(row=1, sticky=E + W)
self.ForceCaesuraButton = Button(self.monitor_frame,
text='Force Caesura',
command=self.force_caesura)
self.ForceCaesuraButton.grid(row=2, sticky=E + W)
self.saveBehaviourButton = Button(self.monitor_frame,
text='Save current behaviour',
command=self.request_saving_behaviour)
self.saveBehaviourButton.grid(row=3, sticky=E + W)
self.saveBehaviourNameEntry = Entry(self.monitor_frame)
self.saveBehaviourNameEntry.grid(row=4, sticky=E + W)
self.saveBehaviourNameEntry.bind('<KeyRelease>', self.request_saving_behaviour)
self.selected_behaviour = StringVar()
self.selected_behaviour.trace('w', self.new_behaviour_chosen)
self.savedBehavioursMenu = OptionMenu(self.monitor_frame,
self.selected_behaviour, None,)
self.savedBehavioursMenu.grid(row=5, sticky=E + W)
self.monitor_frame.grid(column=0, row=10, sticky=E + W)
示例9: __init__
def __init__(self,parent,view,lissajou,subjectSig,subjects):
self.cursorFrame = Frame(parent)
self.selectionFrame = Frame(self.cursorFrame)
self.view = view
self.lissajou = lissajou
self.subjects = subjects
self.subjectSig=subjectSig
self.amp=IntVar()
self.scale_amp=Scale(self.cursorFrame,variable=self.amp,
label="Amplitude",
orient="horizontal",length=250,from_=0,to=10,
sliderlength=50,tickinterval=1,showvalue=0,
command=self.update)
self.freq=IntVar()
self.scale_freq=Scale(self.cursorFrame,variable=self.freq,
label="Frequence",
orient="horizontal",length=250,from_=0,to=10,
sliderlength=50,tickinterval=0,showvalue=0,
command=self.update)
self.offset=DoubleVar()
self.scale_offset=Scale(self.cursorFrame,variable=self.offset,
label="Offset",
orient="horizontal",length=250,from_=-10.0,to=10.0,
sliderlength=50,tickinterval=5,showvalue=0,
command=self.update)
self.phase=IntVar()
self.scale_phase=Scale(self.cursorFrame,variable=self.phase,
label="Phase",
orient="horizontal",length=250,from_=-90,to=90,
sliderlength=10,tickinterval=45,showvalue=0,
command=self.update)
self.voltVar = DoubleVar()
self.voltVar.set(1)
self.button1 = Radiobutton(self.selectionFrame, text="1V", variable=self.voltVar,
value=1.0*5.0,command =lambda:self.update(None))
self.button1.select()
self.button2 = Radiobutton(self.selectionFrame, text="2V", variable=self.voltVar,
value=2.0*5.0, command =lambda:self.update(None))
self.button5 = Radiobutton(self.selectionFrame, text="5V", variable=self.voltVar,
value=5.0*5.0, command =lambda:self.update(None))
self.isOffsetVar= IntVar()
self.isOffset = Checkbutton(self.selectionFrame,text = "Offset",variable = self.isOffsetVar,
command =lambda:self.update(None))
示例10: JoystickFrame
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))
示例11: create_scales
def create_scales(self):
counter = 0
for sca in SCALES:
label = SCALES[sca]['label'] if 'label' in SCALES[sca].keys() else sca
setattr(self, 'min_' + sca, SCALES[sca]['min'])
setattr(self, 'max_' + sca, SCALES[sca]['max'])
self.this_scale = Scale(self, label=label, orient=HORIZONTAL,
from_=getattr(self, 'min_' + sca),
to=getattr(self, 'max_' + sca),
resolution=SCALES[sca]['res'])
self.this_scale.set(SCALES[sca]['start'])
self.this_scale.enable = ('enable' in SCALES[sca].keys() and
SCALES[sca]['enable'] or None)
self.this_scale.disable = ('disable' in SCALES[sca].keys() and
SCALES[sca]['disable'] or None)
if 'pos' in SCALES[sca].keys():
pos = SCALES[sca]['pos']
col = pos['c']
row = pos['r']
else:
row = counter
col = 1
counter += 1
self.this_scale.grid(column=col, row=row, sticky=E + W)
self.this_scale.ref = sca
self.this_scale.bind("<ButtonRelease>", self.scale_handler)
示例12: __init__
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()
示例13: 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()
示例14: __init__
def __init__(self, parent=None):
Frame.__init__(self, parent)
self.pack(side=BOTTOM, anchor=S, fill=X)
self.scale = Scale(self, from_=0, to=1, sliderlength = 10,
showvalue=YES, tickinterval=10,
orient='horizontal')
self.scale.pack(fill=X)
示例15: Playbar
class Playbar(Frame):
def __init__(self, parent=None):
Frame.__init__(self, parent)
self.pack(side=BOTTOM, anchor=S, fill=X)
self.scale = Scale(self, from_=0, to=1, sliderlength = 10,
showvalue=YES, tickinterval=10,
orient='horizontal')
self.scale.pack(fill=X)
# We don't set the initial value of the scale here because
# that's done by tying it to the global variable "slidert"
# Resetscale: takes a frame count and resets scale parms appropriately
def resetscale(self, frames):
temp = floor(log10(frames))
tickinterval = int(pow(10,temp))
if(tickinterval<1): tickinterval = 1
self.scale.config(to=frames, tickinterval=tickinterval)