Skip to content

pep8ify examples/ part 3 #3183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
found a few pep8 issued not fixed by autopep8 in examples/event_handling
Signed-off-by: Thomas Hisch <t.hisch@gmail.com>
  • Loading branch information
twmr committed Jul 4, 2014
commit 54d4b585f9314ac0dd9dfb7eda7ffcb91647c9fb
11 changes: 7 additions & 4 deletions examples/event_handling/pipong.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ def __init__(self, ax):
padAy = padBy = .30
padBx += 6.3
pA, = self.ax.barh(padAy, .2, height=.3, color='k', alpha=.5,
edgecolor='b', lw=2, label="Player B", animated=True)
edgecolor='b', lw=2, label="Player B",
animated=True)
pB, = self.ax.barh(padBy, .2, height=.3, left=padBx, color='k',
alpha=.5, edgecolor='r', lw=2, label="Player A", animated=True)
alpha=.5, edgecolor='r', lw=2, label="Player A",
animated=True)

# distractors
self.x = np.arange(0, 2.22 * np.pi, 0.01)
Expand All @@ -144,9 +146,10 @@ def __init__(self, ax):
self.line4, = self.ax.plot(
self.x, np.cos(self.x), "r", animated=True, lw=4)
self.centerline, = self.ax.plot(
[3.5, 3.5], [1, -1], 'k', alpha=.5, animated=True, lw=8)
[3.5, 3.5], [1, -1], 'k', alpha=.5, animated=True, lw=8)
self.puckdisp = self.ax.scatter(
[1], [1], label='_nolegend_', s=200, c='g', alpha=.9, animated=True)
[1], [1], label='_nolegend_', s=200, c='g', alpha=.9,
animated=True)

self.canvas = self.ax.figure.canvas
self.background = None
Expand Down
3 changes: 2 additions & 1 deletion examples/event_handling/poly_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class PolygonInteractor:
def __init__(self, ax, poly):
if poly.figure is None:
raise RuntimeError(
'You must first add the polygon to a figure or canvas before defining the interactor')
'You must first add the polygon to a figure or canvas before '
'defining the interactor')
self.ax = ax
canvas = poly.figure.canvas
self.poly = poly
Expand Down
12 changes: 6 additions & 6 deletions examples/event_handling/test_mouseclicks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
from __future__ import print_function

import matplotlib
# import matplotlib
# matplotlib.use("WxAgg")
# matplotlib.use("TkAgg")
# matplotlib.use("GTKAgg")
Expand All @@ -10,23 +10,23 @@
# matplotlib.use("MacOSX")
import matplotlib.pyplot as plt

#print("***** TESTING WITH BACKEND: %s"%matplotlib.get_backend() + " *****")
# print("***** TESTING WITH BACKEND: %s"%matplotlib.get_backend() + " *****")


def OnClick(event):
def on_click(event):
if event.dblclick:
print("DBLCLICK", event)
else:
print("DOWN ", event)


def OnRelease(event):
def on_release(event):
print("UP ", event)


fig = plt.gcf()
cid_up = fig.canvas.mpl_connect('button_press_event', OnClick)
cid_down = fig.canvas.mpl_connect('button_release_event', OnRelease)
cid_up = fig.canvas.mpl_connect('button_press_event', on_click)
cid_down = fig.canvas.mpl_connect('button_release_event', on_release)

plt.gca().text(0.5, 0.5, "Click on the canvas to test mouse events.",
ha="center", va="center")
Expand Down
6 changes: 3 additions & 3 deletions examples/event_handling/timers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def update_title(axes):
x = np.linspace(-3, 3)
ax.plot(x, x * x)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excessive whitespace.


# Create a new timer object. Set the interval 500 milliseconds (1000 is default)
# and tell the timer what function should be called.
# Create a new timer object. Set the interval 500 milliseconds (1000 is
# default) and tell the timer what function should be called.
timer = fig.canvas.new_timer(interval=100)
timer.add_callback(update_title, ax)
timer.start()
Expand All @@ -24,6 +24,6 @@ def update_title(axes):
# def start_timer(evt):
# timer.start()
# fig.canvas.mpl_disconnect(drawid)
#drawid = fig.canvas.mpl_connect('draw_event', start_timer)
# drawid = fig.canvas.mpl_connect('draw_event', start_timer)

plt.show()