Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 626feae

Browse files
committed
added adjustable padding between label and text box
1 parent 0d173e6 commit 626feae

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/matplotlib/widgets.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ class TextBox(AxesWidget):
650650
"""
651651

652652
def __init__(self, ax, label, initial='',
653-
color='.95', hovercolor='1'):
653+
color='.95', hovercolor='1', label_pad=.01):
654654
"""
655655
Parameters
656656
----------
@@ -669,6 +669,9 @@ def __init__(self, ax, label, initial='',
669669
670670
hovercolor : color
671671
The color of the box when the mouse is over it
672+
673+
label_pad : float
674+
the distance between the label and the right side of the textbox
672675
"""
673676
AxesWidget.__init__(self, ax)
674677

@@ -680,7 +683,7 @@ def __init__(self, ax, label, initial='',
680683
self.params_to_disable += [key]
681684

682685
self.text = initial
683-
self.label = ax.text(-0.01, 0.5, label,
686+
self.label = ax.text(-label_pad, 0.5, label,
684687
verticalalignment='center',
685688
horizontalalignment='right',
686689
transform=ax.transAxes)
@@ -810,7 +813,6 @@ def begin_typing(self, x):
810813
rcParams[key] = []
811814
#now, we have to figure out where the cursor goes.
812815
#approximate it based on assuming all characters the same length
813-
print(x)
814816
self.cursor_index = len(self.text)
815817
self._rendercursor()
816818

0 commit comments

Comments
 (0)