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
| from tkinter import *
import math as m
import numpy as np
pourcenteau=0
pourcentforest=0
def askforest():
global pourcentforest
curseurforest = Scale(orient='horizontal', from_=0, to=100,
resolution=10, tickinterval=10, length=500,
label='Quel pourcentage de surface terrestre désirez-vous recouvert de forêt?',
relief='groove', variable=pourcentforest)
curseurforest.pack()
validerforest=Button(text="Valider")
validerforest.pack()
return()
def askwater():
global pourcenteau
a=DoubleVar()
curseureau = Scale(orient='horizontal', from_=0, to=100,
resolution=10, tickinterval=10, length=500,
label='Quel pourcentage d\'eau désirez-vous?', relief='groove', variable=a)
curseureau.pack()
pourcenteau=a
validereau=Button(text="Valider", command=askforest)
validereau.pack()
return()
def buildregion(n,p):
global pourcenteau
interface= Tk()
interface.geometry("1920x1080+0+0")
commencer=Button(interface, text="Commencer", command=askwater)
commencer.pack()
coeff=[0,0,0,[0,0]]
ligne=[p*[coeff]]
region = n*ligne
quantiteau=round((pourcenteau/100)*(n*p))
interface.mainloop()
alea=m.ceil((0.1*quantiteau))
print('alea=',alea)
k=0
while k<alea :
i=np.random.randint(0,p)
j=np.random.randint(0,n)
region[j][i][0]=1
print([i,j])
k+=1
print(region) |
Partager