8000 formatting changes for Pep8 compliance · matplotlib/matplotlib@21fcbe6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 21fcbe6

Browse files
committed
formatting changes for Pep8 compliance
1 parent 62b876f commit 21fcbe6

File tree

1 file changed

+85
-74
lines changed

1 file changed

+85
-74
lines changed

lib/matplotlib/widgets.py

Lines changed: 85 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -622,14 +622,14 @@ def disconnect(self, cid):
622622
except KeyError:
623623
pass
624624

625+
625626
class TextBox(AxesWidget):
626627
"""
627628
A GUI neutral text input box.
628629
629-
For the text box to remain responsive
630-
you must keep a reference to it.
630+
For the text box to remain responsive you must keep a reference to it.
631631
632-
The following attributes are accessible
632+
The following attributes are accessible:
633633
634634
*ax*
635635
The :class:`matplotlib.axes.Axes` the button renders into.
@@ -643,11 +643,13 @@ class TextBox(AxesWidget):
643643
*hovercolor*
644644
The color of the text box when hovering.
645645
646-
Call :meth:`on_text_change` to be updated whenever the text changes
647-
Call :meth:`on_submit` to be updated whenever the user hits enter or leaves the text entry field
646+
Call :meth:`on_text_change` to be updated whenever the text changes.
647+
648+
Call :meth:`on_submit` to be updated whenever the user hits enter or
649+
leaves the text entry field.
648650
"""
649651

650-
def __init__(self, ax, label, initial = '',
652+
def __init__(self, ax, label, initial='',
651653
color='.95', hovercolor='1'):
652654
"""
653655
Parameters
@@ -658,43 +660,48 @@ def __init__(self, ax, label, initial = '',
658660
659661
label : str
660662
Label for this text box. Accepts string.
661-
663+
662664
initial : str
663665
Initial value in the text box
664-
666+
665667
color : color
666668
The color of the box
667669
668670
hovercolor : color
669671
The color of the box when the mouse is over it
670672
"""
671673
AxesWidget.__init__(self, ax)
672-
673-
self.DIST_FROM_LEFT = .05
674-
674+
675+
self.DIST_FROM_LEFT = .05
676+
675677
self.params_to_disable = []
676-
for key in rcParams.keys():
678+
for key in rcParams.keys():
677679
if u'keymap' in key:
678-
self.params_to_disable += [key]
679-
680+
self.params_to_disable += [key]
681+
680682
self.text = initial
681-
self.label = ax.text(0.0,0.5, label,
683+
self.label = ax.text(0.0, 0.5, label,
682684
verticalalignment='center',
683685
horizontalalignment='right',
684686
transform=ax.transAxes)
685687
self.text_disp = self._make_text_disp(self.text)
686-
688+
687689
self.cnt = 0
688690
self.change_observers = {}
689691
self.submit_observers = {}
690-
691-
self.ax.set_xlim(0, 1) #If these lines are removed, the cursor won't appear
692-
self.ax.set_ylim(0, 1) #the first time the box is clicked
693-
694-
self.cursor_index = 0;
695-
self.cursor = self.ax.vlines(0, 0, 0) #because this is initialized, _render_cursor
696-
self.cursor.set_visible(False) #can assume that cursor exists
697-
692+
693+
# If these lines are removed, the cursor won't appear the first
694+
# time the box is clicked:
695+
self.ax.set_xlim(0, 1)
696+
self.ax.set_ylim(0, 1)
697+
698+
self.cursor_index = 0
699+
700+
# Because this is initialized, _render_cursor
701+
# can assume that cursor exists.
702+
self.cursor = self.ax.vlines(0, 0, 0)
703+
self.cursor.set_visible(False)
704+
698705
self.connect_event('button_press_event', self._click)
699706
self.connect_event('button_release_event', self._release)
700707
self.connect_event('motion_notify_event', self._motion)
@@ -707,105 +714,107 @@ def __init__(self, ax, label, initial = '',
707714
self.hovercolor = hovercolor
708715

709716
self._lastcolor = color
710-
711-
self.capturekeystrokes = False
712-
717+
718+
self.capturekeystrokes = False
719+
713720
def _make_text_disp(self, string):
714721
return self.ax.text(self.DIST_FROM_LEFT, 0.5, string,
715-
verticalalignment='center',
716-
horizontalalignment='left',
717-
transform=self.ax.transAxes)
722+
verticalalignment='center',
723+
horizontalalignment='left',
724+
transform=self.ax.transAxes)
725+
718726
def _rendercursor(self):
719-
#this is a hack to figure out where the cursor should go.
720-
#we draw the text up to where the cursor should go, measure
721-
#save its dimensions, draw the real text, then put the cursor
722-
#at the saved dimensions
723-
727+
# this is a hack to figure out where the cursor should go.
728+
# we draw the text up to where the cursor should go, measure
729+
# save its dimensions, draw the real text, then put the cursor
730+
# at the saved dimensions
731+
724732
widthtext = self.text[:self.cursor_index]
725733
no_text = False
726734
if(widthtext == "" or widthtext == " " or widthtext == " "):
727735
no_text = widthtext == ""
728-
widthtext = ","
729-
736+
widthtext = ","
737+
730738
wt_disp = self._make_text_disp(widthtext)
731-
739+
732740
self.ax.figure.canvas.draw()
733741
bb = wt_disp.get_window_extent()
734742
inv = self.ax.transData.inverted()
735743
bb = inv.transform(bb)
736744
wt_disp.set_visible(False)
737745
if no_text:
738-
bb[1, 0] = bb[0, 0]
739-
#hack done
740-
self.cursor.set_visible(False)
741-
746+
bb[1, 0] = bb[0, 0]
747+
# hack done
748+
self.cursor.set_visible(False)
749+
742750
self.cursor = self.ax.vlines(bb[1, 0], bb[0, 1], bb[1, 1])
743751
self.ax.figure.canvas.draw()
744752

745753
def _notify_submit_observers(self):
746754
for cid, func in six.iteritems(self.submit_observers):
747755
func(self.text)
748-
756+
749757
def _release(self, event):
750758
if self.ignore(event):
751759
return
752760
if event.canvas.mouse_grabber != self.ax:
753761
return
754762
event.canvas.release_mouse(self.ax)
755-
763+
756764
def _keypress(self, event):
757765
if self.ignore(event):
758766
return
759767
if self.capturekeystrokes:
760768
key = event.key
761-
769+
762770
if(len(key) == 1):
763-
self.text = (self.text[:self.cursor_index] + key +
764-
self.text[self.cursor_index:])
765-
self.cursor_index += 1
771+
self.text = (self.text[:self.cursor_index] + key +
772+
self.text[self.cursor_index:])
773+
self.cursor_index += 1
766774
elif key == "right":
767-
if self.cursor_index != len(self.text):
768-
self.cursor_index += 1
775+
if self.cursor_index != len(self.text):
776+
self.cursor_index += 1
769777
elif key == "left":
770-
if self.cursor_index != 0:
771-
self.cursor_index -= 1
778+
if self.cursor_index != 0:
779+
self.cursor_index -= 1
772780
elif key == "home":
773-
self.cursor_index = 0
781+
self.cursor_index = 0
774782
elif key == "end":
775-
self.cursor_index = len(self.text)
783+
self.cursor_index = len(self.text)
776784
elif(key == "backspace"):
777785
if self.cursor_index != 0:
778-
self.text = (self.text[:self.cursor_index - 1] +
779-
self.text[self.cursor_index:])
786+
self.text = (self.text[:self.cursor_index - 1] +
787+
self.text[self.cursor_index:])
780788
self.cursor_index -= 1
781789
elif(key == "delete"):
782790
if self.cursor_index != len(self.text):
783-
self.text = (self.text[:self.cursor_index] +
784-
self.text[self.cursor_index + 1:])
791+
self.text = (self.text[:self.cursor_index] +
792+
self.text[self.cursor_index + 1:])
793+
785794
self.text_disp.remove()
786795
self.text_disp = self._make_text_disp(self.text)
787796
self._rendercursor()
788797
for cid, func in six.iteritems(self.change_observers):
789798
func(self.text)
790799
if key == "enter":
791-
self._notify_submit_observers()
792-
800+
self._notify_submit_observers()
801+
793802
def _click(self, event):
794803
if self.ignore(event):
795804
return
796805
if event.inaxes != self.ax:
797-
notifysubmit = False
798-
#because _notify_submit_users might throw an error in the
799-
#user's code, we only want to call it once we've already done
800-
#our cleanup.
806+
notifysubmit = False
807+
# because _notify_submit_users might throw an error in the
808+
# user's code, we only want to call it once we've already done
809+
# our cleanup.
801810
if self.capturekeystrokes:
802-
for key in self.params_to_disable:
811+
for key in self.params_to_disable:
803812
rcParams[key] = self.reset_params[key]
804-
notifysubmit = True
813+
notifysubmit = True
805814
self.capturekeystrokes = False
806815
self.cursor.set_visible(False)
807816
self.ax.figure.canvas.draw()
808-
817+
809818
if notifysubmit:
810819
self._notify_submit_observers()
811820
return
@@ -837,33 +846,35 @@ def _motion(self, event):
837846

838847
def on_text_change(self, func):
839848
"""
840-
When the text changes, call this *func* with event
849+
When the text changes, call this *func* with event.
841850
842-
A connection id is returned which can be used to disconnect
851+
A connection id is returned which can be used to disconnect.
843852
"""
844853
cid = self.cnt
845854
self.change_observers[cid] = func
846855
self.cnt += 1
847856
return cid
848-
857+
849858
def on_submit(self, func):
850859
"""
851-
When the user hits enter or leaves the submision box, call this *func* with event
860+
When the user hits enter or leaves the submision box, call this
861+
*func* with event.
852862
853-
A connection id is returned which can be used to disconnect
863+
A connection id is returned which can be used to disconnect.
854864
"""
855865
cid = self.cnt
856866
self.submit_observers[cid] = func
857867
self.cnt += 1
858868
return cid
859-
869+
860870
def disconnect(self, cid):
861871
"""remove the observer with connection id *cid*"""
862872
try:
863873
del self.observers[cid]
864874
except KeyError:
865875
pass
866876

877+
867878
class RadioButtons(AxesWidget):
868879
"""
869880
A GUI neutral radio button
@@ -2506,4 +2517,4 @@ def onmove(self, event):
25062517
self.ax.draw_artist(self.line)
25072518
self.canvas.blit(self.ax.bbox)
25082519
else:
2509-
self.canvas.draw_idle()
2520+
self.canvas.draw_idle()time the

0 commit comments

Comments
 (0)
0