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
| # coding: utf-8
from tkinter import *
import tkinter as tk
from tkinter.messagebox import *
def toplevel():
taille_x = int(E1.get()) #on reprend les valeurs précedentes
taille_y = int(E2.get())
main = Toplevel(begin)
main.title('CasioMaker by Tituya')
main['bg'] = '#abc'
nomfichier = 'DESSIN.txt'
main.resizable(width=False,height=False)
#A propos de l'affichage
disp_x = 15
disp_y = 15
#reset du fichier
fichier = open(nomfichier, 'w')
fichier.write('\'Made by TituyaÙ\n')
fichier.write('ClsÙ\n')
fichier.write('ViewWindow 1,127,1,1,63,1Ù\n')
fichier.write('AxesOffÙ\n')
fichier.close()
def a():
#Ecriture dans le fichier
fichier = open(nomfichier, 'w')
fichier.write('\'Made by TituyaÙ\n')
fichier.write('ClsÙ\n')
fichier.write('ViewWindow 1,127,1,1,63,1Ù\n')
fichier.write('AxesOffÙ\n')
fichier.close()
def c(): #Reset de la grille
canvas.delete("all")
for ligne1 in range(taille_y):
for colonne1 in range(taille_x):
button = tk.Button(frame_b, borderwidth=1, background='white', width=2, height=1)
button['command'] = lambda button=button: button.configure(background = 'black')
button.grid(row=ligne1, column=colonne1)
fichier = open(nomfichier, 'w')
fichier.write('\'Made by TituyaÙ\n')
fichier.write('ClsÙ\n')
fichier.write('ViewWindow 1,127,1,1,63,1Ù\n')
fichier.write('AxesOffÙ\n')
fichier.close()
def b(): #Lors du quit
if askyesno('Titre 1', 'Etes vous sur ? Toutes progression sera effacée'):
main.destroy()
begin.destroy()
else:
pass
def mouse(event):
grid_info = event.widget.grid_info()
if isinstance(event.widget, tk.Button):
print("Ligne:", grid_info["row"] - 62, "Colonne:", grid_info["column"] + 1)
point = canvas.create_line(grid_info["column"] + 2, grid_info["row"] + 2, grid_info["column"] + 2, grid_info["row"] + 3)
fichier = open(nomfichier, 'a')
value = (grid_info["column"] + 1)
value2 = (grid_info["row"] - 63)
valeur_colonne = str(value)
valeur_ligne = str(-value2)
fichier.write('PlotOn ' + valeur_colonne + ',' + valeur_ligne + 'Ù\n')
def tuto():
root = Tk()
root.title('Tutoriel')
root['bg'] = '#abc'
root.resizable(width=False,height=False)
Label(root, text='Après avoir éffectué votre oeuvre,\n un fichier texte est crée où vous avez ouvert ce logiciel.\n Dans ce fichier, ce trouve les instructions pour la calculatrice.\n Ouvrez FA124 (logiciel de calculatrice).\n Connectez votre calculatrice puis, dans un nouveau programme,\n Copier puis Coller l\'ensemble du fichier texte dans un nouveau programme.\n Après ceci, tranférez le.\n Bravo, vous avez fini !', bg = '#abc').pack()
root.mainloop()
#Image CasioMaker
photo = PhotoImage(file="casio_maker.png")
frametxt = Frame(main, relief=FLAT)
frametxt.pack(side=TOP)
cantxt = Canvas(frametxt, width=300, height=25, bg=main['bg'], relief=FLAT)
cantxt.create_image(150, 12, anchor=CENTER, image=photo)
cantxt.pack(side=TOP)
frame = Frame(main)
frame.pack(padx=10, pady=100)
can = Canvas(frame, background='yellow')
can.grid(row=0, column=0)
#Barre vertical
vsbar = Scrollbar(frame, orient=VERTICAL, command=can.yview)
vsbar.grid(row=0, column=1, sticky=NS)
can.configure(yscrollcommand=vsbar.set)
#Barre horizontal
hsbar = Scrollbar(frame, orient=HORIZONTAL, command=can.xview)
hsbar.grid(row=1, column=0, sticky=EW)
can.configure(xscrollcommand=hsbar.set)
frame_b = Frame(can)
#Generation des boutons
for ligne in range(taille_y):
for colonne in range(taille_x):
button = tk.Button(frame_b, borderwidth=1, background='white', width=2, height=1)
button['command'] = lambda button=button: button.configure(background = 'black')
button.grid(row=ligne, column=colonne)
can.create_window((0,0), window=frame_b, anchor=NW)
frame_b.update_idletasks()
bbox = can.bbox(ALL)
w, h = bbox[2]-bbox[1], bbox[3]-bbox[1]
dw, dh = int((w/taille_x) * disp_x), int((h/taille_y) * disp_y)
can.configure(scrollregion=bbox, width=dw, height=dh)
#Menu du haut
menu = Menu(main)
sousmenu = Menu(menu, tearoff=0)
menu.add_cascade(label="Menu", menu=sousmenu)
sousmenu.add_command(label="Creer le fichier texte", command=a)
sousmenu.add_command(label="Quitter", command=b)
menu.add_command(label="Effacer", command=c)
menu.add_command(label='Tutoriel', command=tuto)
main.config(menu = menu)
#Faux ecran de calc
bottom_frame = Frame(main)
bottom_frame.pack( side = BOTTOM )
canvas = Canvas(bottom_frame, width=127, height=63, background='#7E9658')
canvas.pack( side = BOTTOM)
main.bind("<Button-1>", mouse)
begin = Tk()
x = StringVar(begin)
y = StringVar(begin)
x.set("10") #Valeur de base
y.set("10") #Valeur de base
E1=Entry(textvariable=x, width=7,justify=CENTER) #Entry 1 gérant x
E2=Entry(textvariable=y, width=7,justify=CENTER) #Entry 2 gérant y
E1.pack(side = RIGHT)
E2.pack(side = RIGHT)
go=Button(begin, text="lancer", command=toplevel) #bouton permettant le lancement de l'app
go.pack()
begin.mainloop() |
Partager