Facebook
From Władysław , 1 Year ago, written in Python.
Embed
Download Paste or View Raw
Hits: 79
  1. from tkinter import *
  2. import random
  3.  
  4. main = Tk()
  5. main.geometry('1100x700')
  6. main.title('Шибениця')
  7.  
  8. c = Canvas(main, width = 530, height = 600, bg = 'white')
  9. c.place(relx = 0.5, rely = 0.05)
  10.  
  11. slova = ["амперметр", "байрактар","атмосфера", "багатство", "батальйон", "біжутерія", "вдячність", "відеоблог",
  12.          "гомофобія", "гіпербола", "диктатура", "евакуація", "екзорцизм", "забаганка", "заголовок", "іконостас",
  13.          "кавалерія", "коломийка", "континент", "лоботомія", "люстрація", "маршрутка", "математик", "махінатор", ]
  14.  
  15. shib = Label(main, text = 'Шибениця', font=('Courier', 25, 'bold'))
  16. shib.place(relx = 0.16, rely = 0.05)
  17. prav = Label(main, text = "Ваша задача: вгадати слово з 9 літер. \n Вгадаєте - виграєте. \n Не вгадаєте - програєте і людина повіситься.", font=('Courier', 12))
  18. prav.place(relx = 0.005, rely = 0.15)
  19.  
  20. def slovo():
  21.     sl = random.choice(slova)
  22.     chst_sl = sl[1:-1]
  23.     lit_sl = []
  24.     for i in chst_sl:
  25.         lit_sl.append(i)
  26.     b1 = Label(text = sl[0], font=('Courier', 25, 'bold'))
  27.     b2 = Label(text = '_', font=('Courier', 25, 'bold'))
  28.     b3 = Label(text = '_', font=('Courier', 25, 'bold'))
  29.     b4 = Label(text = '_', font=('Courier', 25, 'bold'))
  30.     b5 = Label(text = '_', font=('Courier', 25, 'bold'))
  31.     b6 = Label(text = '_', font=('Courier', 25, 'bold'))
  32.     b7 = Label(text = '_', font=('Courier', 25, 'bold'))
  33.     b8 = Label(text = '_', font=('Courier', 25, 'bold'))
  34.     b9 = Label(text = sl[-1], font=('Courier', 25, 'bold'))
  35.  
  36.     alf = 'абвгґдеєжзиіїйклмнопрстуфхцчшщьюя'
  37.     nb = [1,2,3,4,5,6,7]
  38.     loss = []
  39.     win = []
  40.  
  41.     def litery(h):
  42.         ind = alf.index(h)
  43.         nazh = alf[ind]
  44.         if h in lit_sl:
  45.             inde = lit_sl(h)
  46.             nb1 = nb[inde]
  47.             lit_sl[inde] = '1'
  48.            
  49.             def koord():
  50.                 if nb1 == 1:
  51.                     x1 = 0.03
  52.                     y1 = 0.4
  53.                 if nb1 == 2:
  54.                     x1 = 0.08
  55.                     y1 = 0.4
  56.                 if nb1 == 3:
  57.                     x1 = 0.13
  58.                     y1 = 0.4
  59.                 if nb1 == 4:
  60.                     x1 = 0.18
  61.                     y1 = 0.4
  62.                 if nb1 == 5:
  63.                     x1 = 0.23
  64.                     y1 = 0.4
  65.                 if nb1 == 6:
  66.                     x1 = 0.28
  67.                     y1 = 0.4
  68.                 if nb1 == 7:
  69.                     x1 = 0.33
  70.                     y1 = 0.4
  71.                 return x1, y1
  72.            
  73.             x1, y1 = kord()
  74.             win.append(h)
  75.            
  76.             if not h in lit_sl:
  77.                 butt[nazh]['state'] = 'disabled'
  78.             if h in lit_sl:
  79.                 win.append(h)
  80.                 inde2 = lit_sl.index(h)
  81.                 nb1 = nb[inde2]
  82.                  
  83.  
  84.     butt = {}
  85.  
  86.     def rozm(a, x, y):
  87.         butt[a] = Button(main, text = a, width = 3, height = 1, command = litery(a))
  88.         butt[a].place(relx = str(x), rely = str(y))
  89.    
  90.     x = 0.05
  91.     y = 0.5
  92.     for i in alf[0:13]:
  93.         rozm(i, x, y)
  94.         x += 0.03
  95.     x = 0.05
  96.     y = 0.55
  97.     for i in alf[13:26]:
  98.         rozm(i, x, y)
  99.         x += 0.03
  100.     x = 0.05
  101.     y = 0.6
  102.     for i in alf[26:33]:
  103.         rozm(i, x, y)
  104.         x += 0.03
  105.  
  106. main.mainloop()