It's almost the new year. You won't have a girlfriend (boyfriend) yet. Ba, no, no, No. then it means that you deserve to have the code~

preface

Hi ~ Hello, everyone, this is the demon king!

I send articles ~ usually reptiles, but what

Reptiles look too much. It's bad for your health. Let's have some reality today!!

It's almost the new year, and my family is urging me. I can't escape this year. Why can't I? The status quo is ba next year

Learn the confession code, install the next forced grid and find a girlfriend. Isn't he fragrant, right~

We don't just talk about goose bumps on the ground. If you need to, please Baidu yourself~


The main reason is that bloggers can't hold back any love words


All right! If you don't say much, why don't you write the code

1, Cupid's arrow

Cupid's arrow has always been regarded as a symbol of love. It is said that Cupid is a naughty little god with wings. Once his arrow is inserted into the hearts of young men and women, it will make them deeply love each other, not afraid of the pain of sharp arrows through their hearts, and be brave together.

Complete code

Not a paragraph of points ~ it's torture for you and torture for me. I want a paragraph of points and you want a paragraph of copies

import turtle as t


def init():
    t.speed(2)
    t.pensize(2)
    t.screensize(480, 360)
    t.color('red', 'red')


def draw_heart_right():
    t.up()
    t.goto(50, 50)
    t.pendown()
    t.right(45)
    t.goto(100, 0)
    t.seth(45)
    t.fd(120)
    t.circle(50, 225)


def draw_heart_left():
    t.up()
    t.goto(0, 0)
    t.down()
    t.seth(45)
    t.fd(120)
    t.circle(50, 225)
    t.seth(90)
    t.circle(50, 225)
    t.fd(120)


def draw_arrow():
    t.up()
    t.seth(0)
    # Feather
    t.goto(-210, 40)
    t.pendown()
    t.goto(-215, 44)
    t.goto(-190, 49)
    t.goto(-175, 46)
    t.up()

    t.goto(-210, 40)
    t.pendown()
    t.goto(-213, 34)
    t.goto(-185, 39)
    t.goto(-175, 46)
    t.up()

    # shaft
    t.pendown()
    t.goto(0, 80)
    t.penup()
    t.goto(160, 110)
    t.pendown()
    t.goto(320, 140)

    # Arrow feather
    t.left(160)
    t.begin_fill()
    t.fd(10)
    t.left(120)
    t.fd(10)
    t.left(120)
    t.fd(10)
    t.end_fill()


if __name__ == '__main__':
    init()
    draw_heart_right()
    draw_heart_left()
    draw_arrow()
    t.hideturtle()
    t.done()

effect

Please be calm when you see the effect. I'm just a small writer. Although it's simple, it means good

Hey, don't go yet~

I'm not satisfied with this. I have another one, right

2, Infinite pop-up confession

Oh ~ this way of confession may not be acceptable to ordinary people. This is a dead pop-up gadget

If you want to crash, just change the value to thousands. Of course, normal people don't do that~

However, there are exceptions. For example, when people around you are in pairs and you are alone, it is definitely a good player to pit friends,

If you accidentally kill yourself and hurt yourself, please don't come to me. The blogger has no money~

import tkinter as tk
import random
import threading
import time
def dow():
    window = tk.Tk()
    width=window.winfo_screenwidth()
    height=window.winfo_screenheight()
    a=random.randrange(0,width)
    b=random.randrange(0,height)
    window.title('520 happy')#The name of the pop-up window can be modified
    window.geometry("200x50"+"+"+str(a)+"+"+str(b))#Pop up window size, not recommended
    tk.Label(window,
        text='520 Happy!',    # The text of the label can be changed at will
        bg='Red',     # background color 
        font=('Regular script', 17),     # Font and font size
        width=15, height=2  # Label length and width
        ).pack()    # Fixed window position
    window.mainloop()
 
threads = []
for i in range(100):#Don't need too many pop-up frames. If the computer is not good, I'm afraid you'll crash
    t = threading.Thread(target=dow)
    threads.append(t)
    time.sleep(0.1)
    threads[i].start()

The effect is not shown. Bloggers still cherish their computers

Not satisfied with this? It's okay. We have another one

3, 520 confession wall

1. First of all, let's make preparations

We create a folder named lyf, put the prepared photos of the goddess in it, and change the photos to jpg format, sequence number sorting.

Create a 520 style template file, create a new txt file, and put the following into it.

# 520
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,1,1,1,1,1,0,0,1,1,1,1,1,0,0,1,1,1,1,1,0
0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0
0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0
0,1,1,1,1,1,0,0,1,1,1,1,1,0,0,1,0,0,0,1,0
0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0
0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0
0,1,1,1,1,1,0,0,1,1,1,1,1,0,0,1,1,1,1,1,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
# name
0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,1,1,1,1,0,0
0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0
0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,0,0
0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0
0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0
0,0,1,1,1,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

Then renamed 1 TMP, create a new folder named templates, and put the saved templates in it.

2. Then we ctrl+c ctrl+v copy and paste our code

Main program code

'''

'''
import os
import argparse
from PIL import Image


'''Some super parameters'''
CELLSIZE = 64


'''Picture reading'''
def readImage(img_path, target_size=(64, 64)):
	img = Image.open(img_path)
	img = img.resize(target_size)
	return img


'''Picture generator'''
def yieldImage(target_dir, idx, target_size):
	img_paths = sorted([os.path.join(target_dir, imgname) for imgname in os.listdir(target_dir)])
	idx = (idx + 1) % len(img_paths)
	return readImage(img_paths[idx], target_size), idx


'''Parsing template'''
def parseTemplate(template_path):
	template = []
	with open(template_path, 'r') as f:
		for line in f.readlines():
			if line.startswith('#'):
				continue
			template.append(line.strip('\n').split(','))
	return template


'''Main function'''
def main(pictures_dir, template_path):
	template = parseTemplate(template_path)
	w = len(template[0])
	h = len(template)
	image_new = Image.new('RGBA', (CELLSIZE*w, CELLSIZE*h))
	img_idx = -1
	for y in range(h):
		for x in range(w):
			if template[y][x] == '1':
				img, img_idx = yieldImage(pictures_dir, img_idx, (CELLSIZE, CELLSIZE))
				image_new.paste(img, (x*CELLSIZE, y*CELLSIZE))
	image_new.show()
	image_new.save('picturewall.png')


'''run'''
if __name__ == '__main__':
	parser = argparse.ArgumentParser(description="Picture Wall Generator.")
	parser.add_argument('-t', dest='template_path', help='Template path.', default='templates/1.tmp')
	parser.add_argument('-p', dest='pictures_dir', help='Pictures dir.', default='lyf')
	args = parser.parse_args()
	template_path = args.template_path
	pictures_dir = args.pictures_dir
	main(pictures_dir, template_path)

Then create a py file and change its name to rename py

This step is to read the photos we have prepared

import os

target_path = 'lyf'
for idx, each in enumerate(os.listdir(target_path)):
	os.rename(os.path.join(target_path, each), os.path.join(target_path, '%s.jpg' % idx))

Should bloggers have no boyfriend (it's impossible to show you if they have a boyfriend), so how does this effect

Of course, it's the handsome little brother and beautiful lady found on the Internet. Ha ha ha ha

As for your pictures, I don't care where they come from, but if you're not afraid of being beaten, you can take a few photos face to face~

Maybe if you are handsome (beautiful), you can put your own photo and change a word. It may be OK~

I'm only responsible for the method of delivery, but not for my girlfriend (boyfriend). Oh, I want to have magical powers

I'll call a bunch of beautiful girls or handsome small pots to play with me for a few days without heavy samples every day

It's okay, this can't do. What else

Tiktok's popular little software for confession

Tiktok is a lot of stuff. I think you've all seen it, but never mind. I'll share it with you. After all, it's also a confession that the code is not.

1. Preparation

First of all, why do you have to prepare these documents first

You can complete any content you want. Just name it the same as me, so you don't have to change the code yourself~

Pictures, music and fonts can express your feelings. Of course, they are good-looking. Girls still like good-looking things~

Tiktok: don't love ugly or unpleasant music. Otherwise, the matchmaker will not save you, just like a stalk.

Yuelao wrapped you with steel wire and red thread, but you can't make it. By the way, remember to change the name of the music file to BGM Mp3 oh

2. Code

configuration file
Create a new py file named CFG py

import os

# Window size (width, height)
SCREENSIZE = (500, 260)
# Define some colors
RED = (255, 0, 0)
BLACK = (0, 0, 0)
AZURE = (240, 255, 255)
WHITE = (255, 255, 255)
MISTYROSE = (255, 228, 225)
PALETURQUOISE = (175, 238, 238)
PAPAYAWHIP = (255, 239, 213)
LIGHTGRAY = (211, 211, 211)
GAINSBORO = (230, 230, 230)
WHITESMOKE = (245, 245, 245)
DARKGRAY = (169, 169, 169)
BLUE = (0, 0, 255)
DEEPSKYBLUE = (0, 191, 255)
SKYBLUE = (135, 206, 235)
LIGHTSKYBLUE = (135, 206, 250)
# Background music path
BGM_PATH = os.path.join(os.getcwd(), 'resources/music/bgm.mp3')
# Font path
FONT_PATH = os.path.join(os.getcwd(), 'resources/font/STXINGKA.TTF')
# Background picture path
BG_IMAGE_PATH = os.path.join(os.getcwd(), 'resources/images/bg.png')
# ICON path
ICON_IMAGE_PATH = os.path.join(os.getcwd(), 'resources/images/icon.png')

I can say I'm tired and don't want to type!

Main program code

import sys
import cfg
import random
import pygame
from tkinter import Tk, messagebox


'''
Function:
	Button class
Initial Args:
	--x, y: Coordinates of the upper left corner of the button
	--width, height: Button width and height
	--text: The text displayed by the button
	--fontpath: Font path
	--fontsize: font size
	--fontcolor: Font color
	--bgcolors: Button background color
	--is_want_to_be_selected: Does the button want to be selected by the player
	--screensize: Software screen size
'''
class Button(pygame.sprite.Sprite):
	def __init__(self, x, y, width, height, text, fontpath, fontsize, fontcolor, bgcolors, edgecolor, edgesize=1, is_want_to_be_selected=True, screensize=None, **kwargs):
		pygame.sprite.Sprite.__init__(self)
		self.rect = pygame.Rect(x, y, width, height)
		self.text = text
		self.font = pygame.font.Font(fontpath, fontsize)
		self.fontcolor = fontcolor
		self.bgcolors = bgcolors
		self.edgecolor = edgecolor
		self.edgesize = edgesize
		self.is_want_tobe_selected = is_want_to_be_selected
		self.screensize = screensize
	'''Automatically bind the button to the screen according to various conditions'''
	def draw(self, screen, mouse_pos):
		# The mouse is within the range of the button
		if self.rect.collidepoint(mouse_pos):
			# --Don't want to be selected
			if not self.is_want_tobe_selected:
				while self.rect.collidepoint(mouse_pos):
					self.rect.left, self.rect.top = random.randint(0, self.screensize[0]-self.rect.width), random.randint(0, self.screensize[1]-self.rect.height)
			pygame.draw.rect(screen, self.bgcolors[0], self.rect, 0)
			pygame.draw.rect(screen, self.edgecolor, self.rect, self.edgesize)
		# The mouse is not within the range of the button
		else:
			pygame.draw.rect(screen, self.bgcolors[1], self.rect, 0)
			pygame.draw.rect(screen, self.edgecolor, self.rect, self.edgesize)
		text_render = self.font.render(self.text, True, self.fontcolor)
		fontsize = self.font.size(self.text)
		screen.blit(text_render, (self.rect.x+(self.rect.width-fontsize[0])/2, self.rect.y+(self.rect.height-fontsize[1])/2))


'''Displays text in the specified location'''
def showText(screen, text, position, fontpath, fontsize, fontcolor, is_bold=False):
	font = pygame.font.Font(fontpath, fontsize)
	font.set_bold(is_bold)
	text_render = font.render(text, True, fontcolor)
	screen.blit(text_render, position)
'''Main function'''
def main():
	# initialization
	pygame.init()
	screen = pygame.display.set_mode(cfg.SCREENSIZE, 0, 32)
	pygame.display.set_icon(pygame.image.load(cfg.ICON_IMAGE_PATH))
	pygame.display.set_caption('From a little brother who likes you')
	# background music
	pygame.mixer.music.load(cfg.BGM_PATH)
	pygame.mixer.music.play(-1, 30.0)
	# The background picture of biu love
	bg_image = pygame.image.load(cfg.BG_IMAGE_PATH)
	bg_image = pygame.transform.smoothscale(bg_image, (150, 150))
	# Instantiate two buttons
	button_yes = Button(x=20, y=cfg.SCREENSIZE[1]-70, width=120, height=35, 
						text='okay', fontpath=cfg.FONT_PATH, fontsize=15, fontcolor=cfg.BLACK, edgecolor=cfg.SKYBLUE, 
						edgesize=2, bgcolors=[cfg.DARKGRAY, cfg.GAINSBORO], is_want_to_be_selected=True, screensize=cfg.SCREENSIZE)
	button_no = Button(x=cfg.SCREENSIZE[0]-140, y=cfg.SCREENSIZE[1]-70, width=120, height=35, 
					   text='forget it', fontpath=cfg.FONT_PATH, fontsize=15, fontcolor=cfg.BLACK, edgecolor=cfg.DARKGRAY, 
					   edgesize=1, bgcolors=[cfg.DARKGRAY, cfg.GAINSBORO], is_want_to_be_selected=False, screensize=cfg.SCREENSIZE)
	# Did you click the OK button
	is_agree = False
	# Main cycle
	clock = pygame.time.Clock()
	while True:
		# --Background picture
		screen.fill(cfg.WHITE)
		screen.blit(bg_image, (cfg.SCREENSIZE[0]-bg_image.get_height(), 0))
		# --Mouse event capture
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				# ----Do not exit the program until you click the OK button
				if is_agree:
					pygame.quit()
					sys.exit()
			elif event.type == pygame.MOUSEBUTTONDOWN and event.button:
				if button_yes.rect.collidepoint(pygame.mouse.get_pos()):
					button_yes.is_selected = True
					root = Tk()
					root.withdraw()
					messagebox.showinfo('', '❤❤❤kiss you❤❤❤')
					root.destroy()
					is_agree = True
		# --Display text
		showText(screen=screen, text='cute girl, I've been watching you for a long time', position=(40, 50), 
				 fontpath=cfg.FONT_PATH, fontsize=25, fontcolor=cfg.BLACK, is_bold=False)
		showText(screen=screen, text='Will you be my girlfriend?', position=(40, 100), 
				 fontpath=cfg.FONT_PATH, fontsize=25, fontcolor=cfg.BLACK, is_bold=True)
		# --Display button
		button_yes.draw(screen, pygame.mouse.get_pos())
		button_no.draw(screen, pygame.mouse.get_pos())
		# --Refresh
		pygame.display.update()
		clock.tick(60)


'''run'''
if __name__ == '__main__':
	main()

You say the effect, oh, the effect runs by itself. I'm tired

5, No routine confession

Background map

code

import pygame
import random
import sys

# Set the game screen size according to the size of the background image
WIDTH, HEIGHT = 1024, 576
# Incomplete screen
screen = pygame.display.set_mode((WIDTH, HEIGHT), 0, 32)
# Full screen
# screen = pygame.display.set_mode((WIDTH, HEIGHT), pygame.FULLSCREEN, 32)
pygame.display.set_caption('Little sister, your express has arrived.')


# Add text information
def title(text, screen, scale, color=(0, 0, 0)):
    font = pygame.font.SysFont('SimHei', 27)
    textRender = font.render(text, True, color)
    # Coordinates of initialization text
    screen.blit(textRender, (WIDTH / scale[0], HEIGHT / scale[1]))


# Button
def button(text, x, y, w, h, color, screen):
        pygame.draw.rect(screen, color, (x, y, w, h))
        font = pygame.font.SysFont('SimHei', 20)
        textRender = font.render(text, True, (255, 255, 255))
        textRect = textRender.get_rect()
        textRect.center = ((x+w/2), (y+h/2))
        screen.blit(textRender, textRect)


# Generate random position coordinates
def get_random_pos():
        x, y = random.randint(10, 600), random.randint(20, 500)
        return x, y


# Page displayed after clicking the allow button
def show_like_interface(screen):
    screen.fill((255, 255, 255))
    background1 = pygame.image.load('2.png').convert()
    screen.blit(background1, (0, 0))
    pygame.display.update()
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()


def main():
    pygame.init()
    clock = pygame.time.Clock()
    # Add background music
    pygame.mixer.music.load('Handwritten past-Jay Chou.mp3')#Change this music name to your own music name
    pygame.mixer.music.play(-1, 20)
    pygame.mixer.music.set_volume(0.5)
    # Set disagree button properties
    unlike_pos_x = 130
    unlike_pos_y = 375
    unlike_pos_width = 450
    unlike_pos_height = 55
    unlike_color = (115, 76, 243)
    # Set Agree button properties
    like_pos_x = 130
    like_pos_y = 280
    like_pos_width = 450
    like_pos_height = 55
    like_color = (115, 76, 243)

    running = True
    while running:
        # Fill window
        screen.fill((255, 255, 255))
        # Add background image
        background = pygame.image.load('1.png').convert()
        screen.blit(background, (0, 0))

        # Get mouse coordinates
        pos = pygame.mouse.get_pos()
        # Judge the mouse position. When you disagree, the button changes constantly
        if pos[0] < unlike_pos_x + unlike_pos_width + 5 and pos[0] > unlike_pos_x - 5 and pos[1] < unlike_pos_y + unlike_pos_height + 5 and pos[1] > unlike_pos_y - 5:
            while True:
                unlike_pos_x, unlike_pos_y = get_random_pos()
                if pos[0] < unlike_pos_x + unlike_pos_width + 5 and pos[0] > unlike_pos_x - 5 and pos[1] < unlike_pos_y + unlike_pos_height + 5 and pos[1] > unlike_pos_y - 5:
                    continue
                break

        # Set title and button text information
        title('1.If one day I confess to you, what will you do?', screen, scale=[8, 3])
        button('A.Your boy is finally enlightened. If you dare to confess, I dare to promise!', like_pos_x, like_pos_y, like_pos_width, like_pos_height, like_color, screen)
        button('B.I take you as my best friend, and you want to sleep with me! Refuse decisively!', unlike_pos_x, unlike_pos_y, unlike_pos_width, unlike_pos_height, unlike_color, screen)
        # Set off option properties
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()
        # When the mouse clicks the Agree button, jump to the end page
        if pos[0] < like_pos_x + like_pos_width + 5 and pos[0] > like_pos_x - 5 and pos[1] < like_pos_y + like_pos_height + 5 and pos[1] > like_pos_y - 5:
            if event.type == pygame.MOUSEBUTTONDOWN:
                show_like_interface(screen)

        pygame.display.flip()
        pygame.display.update()
        clock.tick(60)


main()

The effect is impossible. I can't strain my little hands for this. My little hands are very delicate. Ha ha ha ha ha

Finally, wechat hides the confession code

I found it by chance. Now I'll share it with you. Hey, hey

This is much simpler. You just need to copy the link below, open wechat and click the chat box of the person you want to express,

Then paste the code and send it. It's easy ˊ ᵕ ˋ) ੭*ଘ

Link: love wazf. top/S94

effect

Starting point opening effect:

Click Yes to the effect:


Effect after clicking No:

Well, my article will end here!

There are more suggestions or questions to comment on or send me a private letter! Come on, let's work together

Like to pay attention to the blogger, or like to collect and comment on my article, Ba!!!

Keywords: Python Programming computer networks

Added by chrys on Fri, 21 Jan 2022 08:18:44 +0200