It is a memorandum when moving the output code with tkinter as "A and pretending to be B" in python.
tkinter is a tool that allows you to build a GUI in Python. I will refer to the following
Event handling with Python Tkinter button Try using Tkinter in Python
sample.py
import tkinter as tk
import random
l = ["Apple",
"Mandarin orange",
"Strawberry",
"pineapple",
"Dragon fruit"]
def bot():
string1=random.choice(l)
string2=random.choice(l)
string=string1+"Pretending to be"+string2
label = tk.Label(text=string) #Define label
x = random.randrange(640)
y = random.randrange(480)
label.place(x=x, y=y) #Install label
window = tk.Tk() #Define window
window.title("Title") #Set window title
window.geometry("640x480") #Set window size
btn = tk.Button(window, text='Pretending to be', command = bot) #Creating a button
btn.place(x=10, y=10)
window.mainloop() #Put into standby state as main loop
Event handling with Python Tkinter button Try using Tkinter in Python
Recommended Posts