Справочник Программиста
6.28K subscribers
1.35K photos
387 videos
64 files
1.7K links
По рекламе - @it_start_programmer
Мои курсы - @courses_from_it_start_bot
Сайт - https://it-start.online/
YouTube - https://www.youtube.com/@it_start
Реклама на бирже - https://telega.in/c/programmersGuide_1

Предложить идею: @it_start_suggestion_bot
Download Telegram
#ЗаписьВидеоСЭкрана
Код из видео:

import cv2
import numpy as np
import pyautogui

SCREEN_SIZE = (1920, 1080)

fourcc = cv2.VideoWriter_fourcc(*"XVID")

out = cv2.VideoWriter("output.avi", fourcc, 20.0, (SCREEN_SIZE))

while True:
img = pyautogui.screenshot()
frame = np.array(img)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
out.write(frame)
cv2.imshow("screenshot", frame)

if cv2.waitKey(1) == ord("q"):
break

cv2.destroyAllWindows()
out.release()
👍2
#МонтажВидео
Код из видео:

from moviepy.editor import *

clip_1 = VideoFileClip('One.mp4')
clip_2 = VideoFileClip('Two.mp4')
# Склейка видео в одно
final_clip = concatenate_videoclips([clip_1, clip_2])
# Обрезать видео с 3 по 7 сек.
final_clip = final_clip.subclip(3, 7)
# Уменьшаем громкость видео
final_clip = final_clip.volumex(0.5)
# Узнаём длительность видео
duration = clip.duration
# Выводим длительность видео
print("Duration : " + str(duration))
# Сохраняем видео
final_clip.write_videofile('Three.mp4')
#УбегающаяКнопка
Код из видео:

from tkinter import *
from tkinter import messagebox
import random


def no():
messagebox.showinfo(' ', 'Спасибо! Ваш голос учтён!')
quit()


def motionMouse(event):
btnYes.place(x=random.randint(0, 500), y=random.randint(0, 500))


root = Tk()
root.geometry('600x600')
root.title('Опрос')
root.resizable(width=False, height=False)
root['bg'] = 'white'

label = Label(root, text='Вы хотите увеличить ЗП?', font='Arial 20 bold', bg='white').pack()
btnYes = Button(root, text='Да', font='Arial 20 bold')
btnYes.place(x=170, y=100)
btnYes.bind('<Enter>', motionMouse)
btnNo = Button(root, text='Нет', font='Arial 20 bold', command=no).place(x=350, y=100)


root.mainloop()
👍5
#СлайдШоуНаПитоне
Код из видео:

from moviepy.editor import *
import os
directory = 'Путь к папке с изображениями'
files = os.listdir(directory)
imges = list(filter(lambda x: x.endswith('.jpg'), files))
clips = [ImageClip(m).set_duration(2) for m in imges]

final_clip = concatenate_videoclips(clips, method='compose')
final_clip.write_videofile('test.mp4', fps=24)
#СокращательСсылок
Код из видео:

import pyshorteners
from tkinter import *
from tkinter import ttk, messagebox


def short():
s = pyshorteners.Shortener()
sohr = beforeLink.get()
afterLink.delete(0, END)
afterLink.insert(0, s.tinyurl.short(sohr))


root = Tk()
root.title('Сокращатель ссылок')
root.geometry('400x150')
root.resizable(width=False, height=False)

beforeLinkLabel = Label(root, text="Вставьте ссылку")
beforeLinkLabel.place(x=10, y=10)

beforeLink = ttk.Entry(root, width=40, font="Arial 13")
beforeLink.place(x=10, y=30)

btn = ttk.Button(root, text="Сократить", command=short)
btn.place(relx=0.5, y=80, anchor=CENTER)

afterLinkLabel = Label(root, text="Результат:")
afterLinkLabel.place(x=10, y=85)

afterLink = ttk.Entry(root, width=40, font="Arial 13", text="")
afterLink.place(x=10, y=105)

root.mainloop()
#ВиселицаНаPython
Код из видео:

from random import choice

HANGMAN = (
"""
------
| |
|
|
|
|
|
----------
""",
"""
------
| |
| O
|
|
|
|
----------
""",
"""
------
| |
| O
| |
|
|
|
----------
""",
"""
------
| |
| O
| /|
|
|
|
----------
""",
"""
------
| |
| O
| /|\\
|
|
|
----------
""",
"""
------
| |
| O
| /|\\
| /
|
|
----------
""",
"""
------
| |
| O
| /|\\
| / \\
|
|
----------
"""
)

max_wrong = len(HANGMAN)
WORDS = ('питон', 'игра', 'программирование')

word = choice(WORDS)
so_far = '_' * len(word)
wrong = 0
used = []

while wrong < max_wrong and so_far != word:
print(HANGMAN[wrong])
print('\nВы использовали следующие буквы:\n', used)
print('\nНа данный момент слово выглядит вот так:\n', so_far)

guess = input('\nВведите своё предположение: ')

while guess in used:
print('Вы уже угадали букву', guess)
guess = input('Введите своё предположение: ')

used.append(guess)

if guess in word:
print('\nДа! \'' + guess + '\' есть в слове!')

new = ''
for i in range(len(word)):
if guess == word[i]:
new += guess
else:
new += so_far[i]
so_far = new
else:
print('\nИзвините, буквы \'' + guess + '\' нет в слове.')
wrong += 1

if wrong == max_wrong:
print(HANGMAN[wrong])
print('\nТебя повесили!')
else:
print('\nВы угадали слово!')

print('\nЗагаданное слово было \'' + word + '\'')
👍1
#ПриложениеДляСкриншотов
Код из видео:

from pyautogui import *
from tkinter import *
from tkinter import messagebox


def screen():
img = screenshot()
img.save(r"screen.png")
messagebox.showinfo('Оповещение', 'Скриншот сделан!')


root = Tk()
root.title('Скриншотер')
root.geometry('300x70')
root.resizable(width=False, height=False)

btn = Button(root, text='Сделать скриншот', font=('Comic Sans MS', 15, 'bold'), command=screen)
btn.place(relx=0.5, rely=0.5, anchor=CENTER)

root.mainloop()
👍2
#ГенераторТекстаСимволами
Код из видео:


import pyfiglet

result = pyfiglet.figlet_format("Hello World", font="slant")
print(result)


Шрифты:
3-d
3x5
5lineoblique
alphabet
banner3-D
doh
isometric1
letters
alligator
dotmatrix
bubble
bulbhead
digital
#МатрицаCMDНаPython
Код из видео:

import os

with open('matrix.bat', 'w') as f:
f.write('@echo off\n')
f.write('color a\n')
f.write(':a\n')
f.write(f"echo {'%random%' * 20}\n")
f.write('goto a')

os.system('matrix.bat')