Advertisement
plarmi

Dice

Apr 4th, 2024
744
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. from tkinter import *
  2. from random import *
  3.  
  4. def roll():
  5.     dice1 = randint(1, 6)
  6.     dice2 = randint(1, 6)
  7.     dise_label.config(text=f"{dice1} {dice2}\nВсего: {dice1 + dice2}")
  8.  
  9. window = Tk()
  10. window.title("Симулятор броска игральных костей")
  11. window.geometry(f"400x400+{(window.winfo_screenwidth() // 2) - 200}+{(window.winfo_screenheight() // 2) - 200}")
  12.  
  13. dise_label = Label(window, text="", font=("Helvetica", 14))
  14. dise_label.grid(padx=20, pady=50, sticky="nsew")
  15.  
  16. roll_button = Button(window, text="Бросить", command=roll)
  17. roll_button.grid(padx=175, pady=175, sticky="nsew")
  18.  
  19. window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement