<div dir="ltr">Stefan,<div><br></div><div>On a quick skim that does not look wrong.</div><div><br></div><div>I would not use globals and have the callbacks be methods on your BOStrab_Fahrzeugeinschraenkung class.</div><div><br></div><div>Tom</div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Aug 5, 2017 at 12:35 PM stefanxfg via Matplotlib-users <<a href="mailto:matplotlib-users@python.org">matplotlib-users@python.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello to everyone.<br>
<br>
I develop a GUI and i want to embedd Matplotlib in a Tkinter Canvas. Theres<br>
is no problem until here. But i want to draw the lines and have a curser<br>
line in the diagram. In the code below i embedd the canvas in the<br>
INIT-Function.<br>
<br>
<br>
<br>
class BOStrab_Fahrzeugeinschraenkung:<br>
        def __init__(self, top=None):<br>
            ......<br>
                self.ya = np.array(ddd)<br>
                self.yb = np.array(ddd)<br>
                self.z = np.array(ddd)<br>
<br>
                self.canvasframe11 = Frame(self.TPanedwindow4_f2)<br>
                self.canvasframe11.place(x=0, y=0, relwidth=1.0, relheight=0.95,<br>
bordermode=INSIDE)<br>
                self.canvasframe12 = Frame(self.TPanedwindow4_f2)<br>
                self.canvasframe12.place(x=0, rely=0.95, relwidth=1.0, bordermode=INSIDE)<br>
<br>
                global ax1<br>
                self.fig1 = Figure (figsize=(5,4), dpi=100)<br>
<br>
                self.ax1 = self.fig1.add_subplot(111) #für 2d-Plot<br>
                self.ax1.set_title('Definition der LRUGL')<br>
                self.ax1.set_xlabel('Breite y [mm]')<br>
                self.ax1.set_ylabel('Hoehe z [mm]')<br>
<br>
                self.ax1.axis([-2000,2000,0, 5000])<br>
                self.ax1.grid(True)<br>
                self.ax1.plot(self.ya,self.z, color='red', linestyle='--', marker='')<br>
                self.ax1.plot(self.yb,self.z, color='red', linestyle='--', marker='')<br>
<br>
                self.canvas1 = FigureCanvasTkAgg(self.fig1,self.canvasframe11)<br>
                toolbar1 = NavigationToolbar2TkAgg(self.canvas1, self.canvasframe12)<br>
<br>
                self.canvas1.get_tk_widget().pack(fill=BOTH, expand=TRUE, pady=2, padx=2,<br>
anchor="n")<br>
<br>
<br>
<br>
In several examples i saw the drawing in def's and the input for the drawing<br>
from root. So the following code is function then.<br>
<br>
<br>
def onMouseMove(event):<br>
        ax1.lines = [ax1.lines[0]]<br>
        ax1.axhline(y=event.ydata, color="k")<br>
        ax1.axvline(x=event.xdata, color="k")<br>
<br>
def updateData():<br>
        global level1, val1<br>
        clamp = lambda n, minn, maxn: max(min(maxn, n), minn)<br>
        yield 1     # FuncAnimation expects an iterator<br>
<br>
def visualize(i):<br>
        lineVal1.set_ydata(val1)<br>
        return lineVal1<br>
<br>
<br>
My question is. Is my way to embedd the code in Tkinter right? Or its better<br>
to declare the diagram functionalities outside the class and only draw into<br>
the class?<br>
<br>
Best regards from Stefan<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://matplotlib.1069221.n5.nabble.com/Embedding-Drawing-Curser-in-Tkinter-tp48038.html" rel="noreferrer" target="_blank">http://matplotlib.1069221.n5.nabble.com/Embedding-Drawing-Curser-in-Tkinter-tp48038.html</a><br>
Sent from the matplotlib - users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Matplotlib-users mailing list<br>
<a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br>
</blockquote></div>