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 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Test.py
#
# Copyright 2020 Yoko_UM-01 <yoko_um-01@yoko-um-01>
#
#
from Tkinter import *
import RPi.GPIO as GPIO
Race = 00
#Configuration GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(2, GPIO.OUT)
GPIO.setup(3, GPIO.OUT)
GPIO.setup(4, GPIO.OUT)
GPIO.setup(14, GPIO.OUT)
GPIO.setup(15, GPIO.OUT)
GPIO.setup(18, GPIO.OUT)
GPIO.setup(17, GPIO.OUT)
GPIO.setup(22, GPIO.OUT)
GPIO.setup(27, GPIO.OUT)
# nom de la fenetre
Aff_Race = Tk()
Aff_Race.title("Numéro de Race")
Aff_Race.geometry("310x310")
#Fonctions
def Num0():
global Race
Race = Race * 10
Race = Race + 0
Race = Race % 100
l = Label(Aff_Race, text= Race, padx=20, pady=15)
l.grid(row = 0, column = 1)
Affichage()
def Num1():
global Race
Race = Race * 10
Race = Race + 1
Race = Race % 100
l = Label(Aff_Race, text= Race, padx=20, pady=15)
l.grid(row = 0, column = 1)
Affichage()
def Num2():
global Race
Race = Race * 10
Race = Race + 2
Race = Race % 100
l = Label(Aff_Race, text= Race, padx=20, pady=15)
l.grid(row = 0, column = 1)
Affichage()
def Num3():
global Race
Race = Race * 10
Race = Race + 3
Race = Race % 100
l = Label(Aff_Race, text= Race, padx=20, pady=15)
l.grid(row = 0, column = 1)
Affichage()
def Num4():
global Race
Race = Race * 10
Race = Race + 4
Race = Race % 100
l = Label(Aff_Race, text= Race, padx=20, pady=15)
l.grid(row = 0, column = 1)
Affichage()
def Num5():
global Race
Race = Race * 10
Race = Race + 5
Race = Race % 100
l = Label(Aff_Race, text= Race, padx=20, pady=15)
l.grid(row = 0, column = 1)
Affichage()
def Num6():
global Race
Race = Race * 10
Race = Race + 6
Race = Race % 100
l = Label(Aff_Race, text= Race, padx=20, pady=15)
l.grid(row = 0, column = 1)
Affichage()
def Num7():
global Race
Race = Race * 10
Race = Race + 7
Race = Race % 100
l = Label(Aff_Race, text= Race, padx=20, pady=15)
l.grid(row = 0, column = 1)
Affichage()
def Num8():
global Race
Race = Race * 10
Race = Race + 8
Race = Race % 100
l = Label(Aff_Race, text= Race, padx=20, pady=15)
l.grid(row = 0, column = 1)
Affichage()
def Num9():
global Race
Race = Race * 10
Race = Race + 9
Race = Race % 100
l = Label(Aff_Race, text= Race, padx=20, pady=15)
l.grid(row = 0, column = 1)
Affichage()
def NumP():
global Race
Race = Race + 1
Race = Race % 100
l = Label(Aff_Race, text = Race, padx=20, pady=15)
l.grid(row = 0, column = 1)
Affichage()
def NumM():
global Race
Race = Race - 1
l = Label(Aff_Race, text = Race, padx=20, pady=15)
l.grid(row = 0, column = 1)
Affichage()
def NumOk():
return ('OK');
def NumR():
global Race
Race = 00
l = Label(Aff_Race, text = Race, padx=20, pady=15)
l.grid(row = 0, column = 1)
Affichage()
# Numéro Afficheur
# Numéro 0
def Aff0():
GPIO.output(2, 1)
GPIO.output(3, 1)
GPIO.output(4, 1)
GPIO.output(14, 1)
GPIO.output(15, 1)
GPIO.output(18, 0)
GPIO.output(17, 1)
# Numéro 1
def Aff1():
GPIO.output(2, 0)
GPIO.output(3, 0)
GPIO.output(4, 0)
GPIO.output(14, 0)
GPIO.output(15, 1)
GPIO.output(18, 0)
GPIO.output(17, 1)
# Numéro 2
def Aff2():
GPIO.output(2, 1)
GPIO.output(3, 0)
GPIO.output(4, 1)
GPIO.output(14, 1)
GPIO.output(15, 0)
GPIO.output(18, 1)
GPIO.output(17, 1)
# Numéro 3
def Aff3():
GPIO.output(2, 1)
GPIO.output(3, 0)
GPIO.output(4, 0)
GPIO.output(14, 1)
GPIO.output(15, 1)
GPIO.output(18, 1)
GPIO.output(17, 1)
# Numéro 4
def Aff4():
GPIO.output(2, 0)
GPIO.output(3, 1)
GPIO.output(4, 0)
GPIO.output(14, 0)
GPIO.output(15, 1)
GPIO.output(18, 1)
GPIO.output(17, 1)
# Numéro 5
def Aff5():
GPIO.output(2, 1)
GPIO.output(3, 1)
GPIO.output(4, 0)
GPIO.output(14, 1)
GPIO.output(15, 1)
GPIO.output(18, 1)
GPIO.output(17, 0)
# Numéro 6
def Aff6():
GPIO.output(2, 1)
GPIO.output(3, 1)
GPIO.output(4, 1)
GPIO.output(14, 1)
GPIO.output(15, 1)
GPIO.output(18, 1)
GPIO.output(17, 0)
# Numéro 7
def Aff7():
GPIO.output(2, 1)
GPIO.output(3, 0)
GPIO.output(4, 0)
GPIO.output(14, 0)
GPIO.output(15, 1)
GPIO.output(18, 0)
GPIO.output(17, 1)
# Numéro 8
def Aff8():
GPIO.output(2, 1)
GPIO.output(3, 1)
GPIO.output(4, 1)
GPIO.output(14, 1)
GPIO.output(15, 1)
GPIO.output(18, 1)
GPIO.output(17, 1)
# Numéro 9
def Aff9():
GPIO.output(2, 1)
GPIO.output(3, 1)
GPIO.output(4, 0)
GPIO.output(14, 1)
GPIO.output(15, 1)
GPIO.output(18, 1)
GPIO.output(17, 1)
# Numéro -
def Aff_():
GPIO.output(2, 0)
GPIO.output(3, 0)
GPIO.output(4, 0)
GPIO.output(14, 0)
GPIO.output(15, 0)
GPIO.output(18, 1)
GPIO.output(17, 0)
#Affichage
def Affichage():
if Race <= 9:
GPIO.output(22, 0)
GPIO.output(27, 1)
if Race == 0:
Aff0()
if Race == 1:
Aff1()
if Race == 2:
Aff2()
if Race == 3:
Aff3()
if Race == 4:
Aff4()
if Race == 5:
Aff5()
if Race == 6:
Aff6()
if Race == 7:
Aff7()
if Race == 8:
Aff8()
if Race == 9:
Aff9()
# Clavier
Clav_0 = Button(Aff_Race, text='0', fg='White', bg='Black', command = Num0)
Clav_1 = Button(Aff_Race, text='1', fg='White', bg='Black', command = Num1)
Clav_2 = Button(Aff_Race, text='2', fg='White', bg='Black', command = Num2)
Clav_3 = Button(Aff_Race, text='3', fg='White', bg='Black', command = Num3)
Clav_4 = Button(Aff_Race, text='4', fg='White', bg='Black', command = Num4)
Clav_5 = Button(Aff_Race, text='5', fg='White', bg='Black', command = Num5)
Clav_6 = Button(Aff_Race, text='6', fg='White', bg='Black', command = Num6)
Clav_7 = Button(Aff_Race, text='7', fg='White', bg='Black', command = Num7)
Clav_8 = Button(Aff_Race, text='8', fg='White', bg='Black', command = Num8)
Clav_9 = Button(Aff_Race, text='9', fg='White', bg='Black', command = Num9)
Clav_P = Button(Aff_Race, text='+', fg='White', bg='Black', command = NumP)
Clav_M = Button(Aff_Race, text='-', fg='White', bg='Black', command = NumM)
Clav_Ok = Button(Aff_Race, text='Ok', fg='White', bg='Green', command = NumOk)
Clav_R = Button(Aff_Race, text='Sup', fg='White', bg='Red', command = NumR)
# placement clavier
Clav_0.grid(row = 5, column = 1, ipadx=20, ipady=15)
Clav_1.grid(row = 4, column = 0, ipadx=20, ipady=15)
Clav_2.grid(row = 4, column = 1, ipadx=20, ipady=15)
Clav_3.grid(row = 4, column = 2, ipadx=20, ipady=15)
Clav_4.grid(row = 3, column = 0, ipadx=20, ipady=15)
Clav_5.grid(row = 3, column = 1, ipadx=20, ipady=15)
Clav_6.grid(row = 3, column = 2, ipadx=20, ipady=15)
Clav_7.grid(row = 2, column = 0, ipadx=20, ipady=15)
Clav_8.grid(row = 2, column = 1, ipadx=20, ipady=15)
Clav_9.grid(row = 2, column = 2, ipadx=20, ipady=15)
Clav_P.grid(row = 2, column = 3, ipadx=20, ipady=15)
Clav_M.grid(row = 4, column = 3, ipadx=20, ipady=15)
Clav_Ok.grid(row = 5, column = 0, ipadx=14, ipady=15)
Clav_R.grid(row = 5, column = 2, ipadx=11, ipady=15)
Quitter = Button(Aff_Race, text='Exit', command = Aff_Race.destroy) # fermeture de la fenetre
Quitter.grid(row = 0, column = 0,ipadx=10, ipady=15)
Aff_Race.mainloop() |
Partager