コード例 #1
0
ファイル: texteditor.py プロジェクト: calebh/maestroflow
import maestroflow as mf
from tkinter import *
import sys

if len(sys.argv) >= 2:
    identifier = sys.argv[1]
else:
    identifier = ""
app_name = "texteditor" + identifier

# Create a new application and use the text editor icon
app = mf.Application(app_name, mf.image('../texteditor-icon.png'))
# Create a source which will broadcast the entered text
text_source = mf.Source(app, "textsource", "text")
# Create a sink which will change the text to whatever was received
text_sink = mf.Sink(app, "textsink", "text")
# Create a sink which accepts events of type color
color_sink = mf.Sink(app, "textcolor", "color")

root = Tk()
root.title(app_name)
text = Text(root)
text.grid()


def on_receive_color(color):
    text.config(fg=color)


# Register the callback handler with the sink
color_sink.on_notify(on_receive_color)
コード例 #2
0
ファイル: histogram.py プロジェクト: calebh/maestroflow
canvas = FigureCanvasTkAgg(f, master=root)
canvas.draw()
canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)


# This function will draw our histogram
def draw_histogram(numbers):
    plt.clf()
    plt.hist(numbers)
    plt.draw()
    canvas.draw()


app = mf.Application("histogram", mf.image('../histogram-icon.png'))
input_sink = mf.Sink(app, "input", "text")


def on_receive_input(text):
    try:
        numbers = list(map(int, text.split(",")))
        draw_histogram(numbers)
    except ValueError:
        # Ignore invalid entries
        pass


# Set up the sink callback
input_sink.on_notify(on_receive_input)
コード例 #3
0
import maestroflow as mf
import signal
import time
import sys

# Create a new application called app2, and use the unicorn icon
app = mf.Application("app2", mf.image('../unicorn-icon.png'))
# Create a sink called app2.sink which accepts events of type text
s = mf.Sink(app, "app2.sink", "text")
# Register the callback handler with the sink. In this case we directly print the data
s.on_notify(print)


# A signal to kill the program should also kill the MaestroFlow application
def signal_handler(sig, frame):
    app.stop()
    sys.exit(0)


signal.signal(signal.SIGINT, signal_handler)

while True:
    # For the MaestroFlow sinks to function, we have to occasionally call poll
    app.poll()
    time.sleep(0.01)
コード例 #4
0
import maestroflow as mf
import signal
import sys

# Create a new application called app1, and use the twirl icon
app = mf.Application("app1", mf.image('../twirl-icon.png'))
# Create a source called input which broadcasts data of type text
input_source = mf.Source(app, "input", "text")


# A signal to kill the program should also kill the MaestroFlow application
def signal_handler(sig, frame):
    app.stop()
    sys.exit(0)


signal.signal(signal.SIGINT, signal_handler)

while True:
    txt = input("Enter some text to send: ")
    # Notify MaestroFlow that we got an input
    input_source.notify(txt)
    # For the MaestroFlow sinks to function, we have to occasionally call poll
    app.poll()
コード例 #5
0
ファイル: colorpicker.py プロジェクト: calebh/maestroflow
import tkinter as tk
import tkinter.ttk as ttk
from tkcolorpicker import askcolor
import maestroflow as mf

# Create a new application called colorpicker, and use the twirl icon
app = mf.Application("colorpicker", mf.image('../colorpicker-icon.png'))
# Create a source called color which broadcasts data of type color
color_source = mf.Source(app, "color", "color")

root = tk.Tk()

while True:
    (rgb, hexcolor) = askcolor((255, 255, 0), root)
    color_source.notify(hexcolor)
    # For the MaestroFlow sinks to function, we have to occasionally call poll
    app.poll()