I am using Latex and matplotlib library to get the output in canvas image
But i need the output in the form of string.
here is my tkinter code
import matplotlib
import matplotlib.pyplot as plt
# import numpy as np
# import base64
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
matplotlib.use('TkAgg')
from tkinter import *
def graph(text):
tmptext = entry.get()
tmptext = "$"+tmptext+"$"
ax.clear()
ax.text(0, 0.9, tmptext, fontsize = 16)
canvas.draw()
# s,(width,height) = canvas.print_to_buffer()
# x = np.fromstring(s, np.uint8).reshape((height,width,4))
# y = np.array_str(x)
# print(y)
# imagedata = base64.b64encode()
# print(imagedata)
# canvast = Canvas(root, width=400, height=500)
# canvast.pack()
# canvast.create_text(100,10, text=""")
root = Tk()
mainframe = Frame(root)
mainframe.pack()
text = StringVar()
entry = Entry(mainframe, width=70, textvariable=text)
entry.pack()
label = Label(mainframe)
label.pack()
fig = matplotlib.figure.Figure(figsize=(10, 4), dpi=100)
ax = fig.add_subplot(111)
canvas = FigureCanvasTkAgg(fig, master=label)
canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
canvas._tkcanvas.pack(side=TOP, fill=BOTH, expand=1)
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)
root.bind('<Return>', graph)
root.mainloop()
Above output is in canvas image i want to convert it into string format
is there any way to convert canvas image into string format
please help me out with this issue