import tkinter as tk
import tkinter as tkinter
from tkinter import StringVar
from random import randint
questions = ['do you love me ?']
answers = ['Yes', 'No']
def button_yes_clicked():
print('Player clicked yes.')
def button_no_covered(a=0) -> None:
rand_pos_X = randint(5, 300)
rand_pos_Y = randint(5, 300)
buttonNo.place(x=rand_pos_X, y=rand_pos_Y)
def button_no_uncovered(a=0) -> None:
print('Button no not longer hovered.')
root = tk.Tk()
root.minsize(300, 300)
textVar = StringVar()
lab = tk.Label(root, textvariable=textVar)
textVar.set('do you love me ?')
lab.pack()
lab.grid(row=1, column=1)
buttonYes = tk.Button(root, text='yes', command=root.quit)
buttonYes.grid(row=2, column=1)
buttonNo = tk.Button(root, text='no', command=button_no_covered)
buttonNo.grid(row=2, column=2)
buttonNo.bind("<Enter>", button_no_covered)
buttonNo.bind("<Leave>", button_no_uncovered)
root.mainloop()
import requests
import tkinter as tk
from PIL import Image
root = tk.Tk()
file="1.gif"
info = Image.open(file)
frames = info.n_frames # gives total number of frames that gif contains
print(frames)
# _______ creating list of PhotoImage objects for each frames
im = [tk.PhotoImage(file=file,format=f"gif -index {i}") for i in range(frames)]
print(im)
count = 0
anim = None
def animation(count):
global anim
im2 = im[count]
gif_label.configure(image=im2)
count += 1
if count == frames:
count = 0
anim = root.after(100,lambda :animation(count))
gif_label = tk.Label(root,image="")
gif_label.pack()
start = tk.Button(root,text="yes",command=lambda:animation(count))
start.pack()
from tkinter import Tk, Label
from PIL import ImageTk, Image
child = tkinter.Toplevel(root)
child.title('child window')
label = Label(child, image = tk_image)
label.pack()
child.mainloop()```
#🔒 how to make it work by button yes from previos window
5 messages · Page 1 of 1 (latest)
@vapid echo
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
how to make gif open by button yes from preivos window
@vapid echo
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.