MCPcopy Index your code
hub / github.com/python/cpython / __init__

Method __init__

Lib/tkinter/ttk.py:1495–1530  ·  view source on GitHub ↗

Construct a 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

(self, master=None, variable=None, from_=0, to=10, **kw)

Source from the content-addressed store, hash-verified

1493 can be accessed through instance.label"""
1494
1495 def __init__(self, master=None, variable=None, from_=0, to=10, **kw):
1496 """Construct a horizontal LabeledScale with parent master, a
1497 variable to be associated with the Ttk Scale widget and its range.
1498 If variable is not specified, a tkinter.IntVar is created.
1499
1500 WIDGET-SPECIFIC OPTIONS
1501
1502 compound: 'top' or 'bottom'
1503 Specifies how to display the label relative to the scale.
1504 Defaults to 'top'.
1505 """
1506 self._label_top = kw.pop('compound', 'top') == 'top'
1507
1508 Frame.__init__(self, master, **kw)
1509 self._variable = variable or tkinter.IntVar(master)
1510 self._variable.set(from_)
1511 self._last_valid = from_
1512
1513 self.label = Label(self)
1514 self.scale = Scale(self, variable=self._variable, from_=from_, to=to)
1515 self.scale.bind('<<RangeChanged>>', self._adjust)
1516
1517 # position scale and label according to the compound option
1518 scale_side = 'bottom' if self._label_top else 'top'
1519 label_side = 'top' if scale_side == 'bottom' else 'bottom'
1520 self.scale.pack(side=scale_side, fill='x')
1521 # Dummy required to make frame correct height
1522 dummy = Label(self)
1523 dummy.pack(side=label_side)
1524 dummy.lower()
1525 self.label.place(anchor='n' if label_side == 'top' else 's')
1526
1527 # update the label as scale or variable changes
1528 self.__tracecb = self._variable.trace_add('write', self._adjust)
1529 self.bind('<Configure>', self._adjust)
1530 self.bind('<Map>', self._adjust)
1531
1532
1533 def destroy(self):

Callers

nothing calls this directly

Calls 10

placeMethod · 0.80
trace_addMethod · 0.80
LabelClass · 0.70
ScaleClass · 0.70
popMethod · 0.45
__init__Method · 0.45
setMethod · 0.45
bindMethod · 0.45
packMethod · 0.45
lowerMethod · 0.45

Tested by

no test coverage detected