1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
| #!/usr/bin/env python3.8
import tkinter
from tkinter import messagebox
import webbrowser
import yfinance
import locale
import time
import requests
from bs4 import BeautifulSoup
# Variable
####################################################################
# Date du jour
#####################################################################
locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')
date_jour = time.strftime('%A %d %B %Y')
# Recherche CAC 40
####################################################################
url = "https://bourse.latribune.fr/webfg/index/CAC-40"
reponse =requests.get(url)
soup = BeautifulSoup(reponse.text,'lxml')
tds = soup.find('span', {'data-field': 'precio_ultima_cotizacion'})
CAC40 = tds.text
# Recherche Variation du CAC 40
####################################################################
soup1 = BeautifulSoup(reponse.text,'lxml')
tds1 = soup1.find('span', {'data-field': 'variacion_porcentual'})
CAC40_Variation = "("+tds1.text+")"
#fonction
####################################################################
def a_propos():
def click_quitter():
barremenu.entryconfigure("Fichier", state="normal")
barremenu.entryconfigure("Gestion", state="normal")
barremenu.entryconfigure("Aide", state="normal")
popup_propos.destroy()
def click_web():
barremenu.entryconfigure("Fichier", state="normal")
barremenu.entryconfigure("Gestion", state="normal")
barremenu.entryconfigure("Aide", state="normal")
webbrowser.open("http://www.leleu-nom.fr")
popup_propos.destroy()
barremenu.entryconfigure("Fichier",state="disabled")
barremenu.entryconfigure("Gestion", state="disabled")
barremenu.entryconfigure("Aide", state="disabled")
popup_propos = tkinter.Toplevel()
popup_propos.title("A propos de Tux bourse")
popup_propos.focus_force()
popup_propos.grab_set()
popup_propos.grab_release()
popup_propos.transient(app)
popup_propos.configure(borderwidth=3, relief="raised")
popup_propos.minsize(width=600, height=400)
popup_propos.maxsize(width=600, height=400)
texte = tkinter.Label(popup_propos, text="Tux Bourse")
texte.place(x=255, y=20 )
texte1 = tkinter.Label(popup_propos, text="Logiciel de suivie d'un portefeille boursiere")
texte1.place(x=170, y=50)
texte2 = tkinter.Label(popup_propos, text="Version: 1.0.0")
texte2.place(x=250, y=110)
texte3 = tkinter.Label(popup_propos, text="Développeur: Gilles LELEU")
texte3.place(x=200, y=170)
texte4 = tkinter.Label(popup_propos, text="Licence: G.N.U / G.P.L")
texte4.place(x=220, y=230)
btn = tkinter.Button(popup_propos, text="Site web", command=click_web )
btn.place(x= 150, y=310)
btn1 = tkinter.Button(popup_propos, text="Fermer", command=click_quitter)
btn1.place(x=380, y=310)
def quitter():
def click_non():
barremenu.entryconfigure("Fichier", state="normal")
barremenu.entryconfigure("Gestion", state="normal")
barremenu.entryconfigure("Aide", state="normal")
popup_quitter.destroy()
def click_oui():
barremenu.entryconfigure("Fichier", state="normal")
barremenu.entryconfigure("Gestion", state="normal")
barremenu.entryconfigure("Aide", state="normal")
app.destroy()
barremenu.entryconfigure("Fichier", state="disabled")
barremenu.entryconfigure("Gestion", state="disabled")
barremenu.entryconfigure("Aide", state="disabled")
popup_quitter = tkinter.Toplevel()
popup_quitter.title("Quitter")
popup_quitter.focus_force()
popup_quitter.grab_release()
popup_quitter.transient(app)
popup_quitter.configure(borderwidth=3, relief="raised")
popup_quitter.minsize(width=300, height=150)
popup_quitter.maxsize(width=300, height=150)
texte = tkinter.Label(popup_quitter, text="Voulez-vous quitter l'application")
texte.place(x=50, y=30)
btn = tkinter.Button(popup_quitter, text="Non", command=click_non)
btn.place(x=60, y=85)
btn1 = tkinter.Button(popup_quitter, text="Oui", command=click_oui)
btn1.place(x=200, y=85)
# Création de la fenêtre + parametrage
#####################################################################
app = tkinter.Tk()
app.title("Tux Bourse")
#app.iconbitmap("icone.ico")
screen_x = int(app.winfo_screenwidth())
screen_y = int(app.winfo_screenheight())
window_x = int(app.winfo_screenwidth())
window_y = int(app.winfo_screenheight())
position_X = (screen_x // 2) - (window_x // 2)
position_Y = (screen_y // 2) - (window_y // 2)
geo = "{}x{}+{}+{}".format(window_x, window_y, position_X, position_Y)
app.geometry(geo)
app.configure(bg="#49A")
#Barre de menu
barremenu =tkinter.Menu(app)
fichier_menu = tkinter.Menu(barremenu, tearoff=0)
fichier_menu.add_command(label="Quitter", command=quitter)
gestion_menu = tkinter.Menu(barremenu, tearoff=0)
gestion_menu.add_command(label="Acheter")
gestion_menu.add_command(label="Vendre")
gestion_menu.add_command(label="Modifier")
aide_menu = tkinter.Menu(barremenu, tearoff=0)
aide_menu.add_command(label="A propos", command = a_propos)
barremenu.add_cascade(label="Fichier", menu=fichier_menu)
barremenu.add_cascade(label="Gestion", menu=gestion_menu)
barremenu.add_cascade(label="Aide", menu=aide_menu)
texte_date = tkinter.Label(app, text="Nous sommes le: "+ date_jour + " et la bourse de Paris est:", bg="#49A", font=("times", 20))
texte_date.place(x=50, y=50)
texte_cac = tkinter.Label(app, text="C A C 40:", bg="#49A", font=("times", 20))
texte_cac.place(x=50, y=100)
resultat_cac = tkinter.Label(app, text=CAC40, bg="#49A",fg="red", font=("times", 20))
resultat_cac.place(x=170, y=100)
variation_cac = tkinter.Label(app, text=CAC40_Variation, bg="#49A", fg="red", font=("times", 20))
variation_cac.place(x=270, y=100)
#Boucle principale
app.config(menu=barremenu)
app.mainloop() |
Partager