#TkinterКаменьНожницыБумага
Код из видео:
from tkinter import *
from random import *
root = Tk()
root.title('Камень ножницы бумага')
root.geometry('600x400')
root.resizable(width=False, height=False)
root['bg'] = 'black'
def Whyknb():
knb = ['Камень', 'Ножницы', 'Бумага']
value = choice(knb)
labelText.configure(text=value)
labelText = Label(root, text='', fg='white', font=('Comic Sans MS', 20), bg ='black')
labelText.place(y = 200, x = 240)
stone = Button(root,
text='Камень',
font=('Comic Sans MS', 20),
bg = 'white',
command=Whyknb
)
stone.place(x=50, y=300)
scissors = Button(root,
text='Ножницы',
font=('Comic Sans MS', 20),
bg = 'white',
command=Whyknb
)
scissors.place(x=220, y=300)
paper = Button(root,
text='Бумага',
font=('Comic Sans MS', 20),
bg = 'white',
command=Whyknb
)
paper.place(x=420, y=300)
root.mainloop()
Код из видео:
from tkinter import *
from random import *
root = Tk()
root.title('Камень ножницы бумага')
root.geometry('600x400')
root.resizable(width=False, height=False)
root['bg'] = 'black'
def Whyknb():
knb = ['Камень', 'Ножницы', 'Бумага']
value = choice(knb)
labelText.configure(text=value)
labelText = Label(root, text='', fg='white', font=('Comic Sans MS', 20), bg ='black')
labelText.place(y = 200, x = 240)
stone = Button(root,
text='Камень',
font=('Comic Sans MS', 20),
bg = 'white',
command=Whyknb
)
stone.place(x=50, y=300)
scissors = Button(root,
text='Ножницы',
font=('Comic Sans MS', 20),
bg = 'white',
command=Whyknb
)
scissors.place(x=220, y=300)
paper = Button(root,
text='Бумага',
font=('Comic Sans MS', 20),
bg = 'white',
command=Whyknb
)
paper.place(x=420, y=300)
root.mainloop()
👍3
#TkinterКликер
Код из видео:
from tkinter import *
root = Tk()
root.title('Счётчик кликов')
root.geometry('200x200')
root.resizable(width=False, height=False)
count = 0
def clicked():
global count
count += 1
Click.configure(text=count)
Click = Label(root, text='0', font='Arial 35')
Click.pack()
btn = Button(root, text='Кликни на меня', padx='20', pady='20', command=clicked)
btn.pack()
root.mainloop()
Код из видео:
from tkinter import *
root = Tk()
root.title('Счётчик кликов')
root.geometry('200x200')
root.resizable(width=False, height=False)
count = 0
def clicked():
global count
count += 1
Click.configure(text=count)
Click = Label(root, text='0', font='Arial 35')
Click.pack()
btn = Button(root, text='Кликни на меня', padx='20', pady='20', command=clicked)
btn.pack()
root.mainloop()
👍1
#TkinterEntry
Код из видео:
from tkinter import *
root = Tk()
root.title('Тестовое приложение')
root.geometry('1280x720')
root.resizable(width=False, height=False)
# root.config(bg = 'black')
root['bg'] = 'black'
def add():
e.insert(END, 'Hello')
def dele():
e.delete(0, END)
def get():
label1['text'] = e.get()
e = Entry(root, show="*")
e.pack()
btn1 = Button(root, font='Arial 15', text='insert', command=add)
btn1.pack()
btn2 = Button(root, font='Arial 15', text='delete', command=dele)
btn2.pack()
btn3 = Button(root, font='Arial 15', text='get', command=get)
btn3.pack()
label1 = Label(root, bg='black', fg='white')
label1.pack()
root.mainloop()
Код из видео:
from tkinter import *
root = Tk()
root.title('Тестовое приложение')
root.geometry('1280x720')
root.resizable(width=False, height=False)
# root.config(bg = 'black')
root['bg'] = 'black'
def add():
e.insert(END, 'Hello')
def dele():
e.delete(0, END)
def get():
label1['text'] = e.get()
e = Entry(root, show="*")
e.pack()
btn1 = Button(root, font='Arial 15', text='insert', command=add)
btn1.pack()
btn2 = Button(root, font='Arial 15', text='delete', command=dele)
btn2.pack()
btn3 = Button(root, font='Arial 15', text='get', command=get)
btn3.pack()
label1 = Label(root, bg='black', fg='white')
label1.pack()
root.mainloop()