Plot sur Tkinter

Résolu
Programmeurnul Messages postés 22 Statut Membre -  
Programmeurnul Messages postés 22 Statut Membre -
Bonjour,

J'essaie de mettre des plots sur mon GUI mais n'y arrive pas. j'ai crée une fenêtre root =Tk()et souhaiterai depuis la afficher 20 boutons qui me lanceraient 20 plot différents. Malheureusement j'ai essayé de creer une fonction et de mettre root.insert(0.0, fonctionquifaitleplot) mais cela ne fonctionne pas. J'ai trouvé des vidéos sur internet qui me parlent de Canevas mais je ne comprends pas comment m'y prendre... pourriez vous m'aider s'il vous plait ?

voici à quoi ressemble un bouton et un plot :

from tkinter import *
import matplotlib.pyplot as plt
import pandas as pd 
import numpy as np 

def BTC_G()
    dr.insert(0.0, BTC())
    
def BTC():
    
    BTC = pd.read_csv('BTC.csv') 
    dates_BTC = BTC['Date']
    price = BTC['Open']
    clean_date = dates_BTC[::48]
    
    mean_BTC = round(np.mean(price),2)
    std_BTC = round(np.std(price),2)
    max_BTC = round(np.amax(price),2)
    min_BTC = round(np.amin(price),2)
    
    f = plt.figure()
    ax = f.add_subplot(111)
    plt.plot(dates_BTC,price, label = 'BTC price')
    plt.xticks(clean_date)
    mean_BTC = plt.axhline(y = mean_BTC, color = 'k', linestyle = '--', label = 'Mean Price')
    max_BTC = plt.axhline(y = max_BTC, color = 'g', linestyle = '-',label = 'Max Price')
    min_BTC = plt.axhline(y = min_BTC, color = 'r', linestyle = '-', label = 'Min Price')
    plt.title('BTC price over time in $')
    plt.legend()
    plt.grid()
    plt.show()


root = Tk()
root.title('Ewallet Services')
root.geometry('1400x800+250+100')

l1 = Label(root, text="Welcome to Ewallet Services Which action would you like to take?", fg = 'black')
l1.pack()

dr= Text(root, width = 100, height = 40)
dr.pack()

btn1 = Button(root, text="[https://www.commentcamarche.net/faq/36478-bitcoin-guide-du-debutant Bitcoin]", command=BTC_G())
btn1.place(x=290, y=650, width =75, height=45)



1 réponse

Programmeurnul Messages postés 22 Statut Membre
 
j'ai réussi
0