Skip to content

Commit

Permalink
fix(examples) fixes timeflies_tkinter
Browse files Browse the repository at this point in the history
- User `from_` not `of`
  • Loading branch information
dbrattli committed Mar 15, 2022
1 parent a227802 commit 7af5c2d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions examples/timeflies/timeflies_tkinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from reactivex.subject import Subject


def main():
def main() -> None:
root = Tk()
root.title("Rx for Python rocks")
scheduler = TkinterScheduler(root)
Expand All @@ -21,29 +21,26 @@ def main():

text = "TIME FLIES LIKE AN ARROW"

def on_next(info: Tuple[tkinter.Label, "Event[Frame]", int]):
def on_next(info: Tuple[tkinter.Label, "Event[Frame]", int]) -> None:
label, ev, i = info
label.place(x=ev.x + i * 12 + 15, y=ev.y)

def label2stream(
label: tkinter.Label, index: int
) -> Observable[Tuple[tkinter.Label, "Event[Frame]", int]]:
label.config(dict(borderwidth=0, padx=0, pady=0))

return mousemoves.pipe(
ops.map(lambda ev: (label, ev, index)),
ops.delay(index * 0.1),
)

def char2label(char: str) -> Label:
return Label(frame, text=char)
return Label(frame, text=char, borderwidth=0, padx=0, pady=0)

xs = reactivex.of(text).pipe(
reactivex.from_(text).pipe(
ops.map(char2label),
ops.flat_map_indexed(label2stream),
)

xs.subscribe(on_next, on_error=print, scheduler=scheduler)
).subscribe(on_next, on_error=print, scheduler=scheduler)

frame.pack()
root.mainloop()
Expand Down

0 comments on commit 7af5c2d

Please sign in to comment.