I am currently working on a project to play videos in Tkinter. I have set the code to run through a loop and play each frame (so it would be a bit like a gif) but the code doesn't seem to play the loop, it just displays the first image. What am I doing wrong? Here is the code:
from tkinter import*
root=Tk()
root.geometry=('400x400')
loop=1
while loop>0:
if loop<240:
filepath="Frames\Frame_Layer_"+str(loop)+".png"
imageback=PhotoImage(file=filepath)
button1=Button(root, image=imageback).pack()
loop=loop+1
else:
loop=1
root.mainloop()
When I run the code it comes up with a message saying too early to create image???
Any help would be much appreciated. Thanks in advance,
Mitra0000
Related
I want to create a visualised card game. I want to make a system where tkinter would show me a picture but the picture name is made of to other variables. tkinter will let me add only one value but I want to add two walues.
raam=Tk()
raam.title("joonistus")
tahvel=Canvas(raam, width=1900, height=1000, background="black")
tahvel.grid()
kaart=[["poti","ruutu","risti","ärtu"],["kaks","kolm","neli","viis","kuus","seitse","kaheksa","üheksa","kümme","poiss","emand","kuningas","äss"]]
#in the finished game I would have more of these pictures imported
poti kaks= PhotoImage(file="doesn't_matter.gif")
tahvel.create_image(20,950, anchor=SW, image=kaart[0][0], kaart[1][0])
I know that I can also use other libraries but I want to try make this game using only tkinter.
Thank you for your support!
I've looked around on SO for ages and can't find what i'm looking for.
What I'm trying to do is get a program to run and look like this:
Combined With the power of editing
With the video file embedded in tkinter window in column 0 under the title. However all I have been able to achieve so far is the video in a separate window to the rest of the GUI.
GUI
Video File window
How do I embed this video into the GUI window on column 0?
This is the portion of the code I have been running to generate both windows so far
os.environ['SDL_WINDOWID'] = str(embed.winfo_id())
os.environ['SDL_VIDEODRIVER'] = 'root'
clip = VideoFileClip("Produce_3.avi")
clip.preview()
Your help is very much appreciated and thank you in advance!
-Anthony
In tkinter, python, I'm currently trying to make a program so when a button is clicked a canvas created shape/line/text is hidden/removed. Here's what I've tried:
line = canvas.create_line(...)
line.configure(state=HIDDEN)
this just simply comes up with an error message, so I'd like some help with this. Thanks you for your time :)
- Jake
I apologise for my poor english skills
canvas.delete(line) is the function you're looking for.
I advise you to consult online documentation on Tkinter before asking basic questions on SO. You can take a look at this website or this one for instance.
I want to make a GUI program with Tkinter which would take in the text and then display all the sentences of the text one by one, moving on, when i click button 'Next'. Problem is that I have no experience with Tkinter, would anyone help me with this by posting some code?
Thanks
I'm developing a media player. Right now it's a simple window with a button to load .wav files. The problem is I would like to implement a pause button now. But, when playing a audio file the GUI isn't accessible again (no buttons can be pushed) till the file is done playing. How can I make the GUI dynamic while an audio file is playing?
I'm using PyAudio, and their implementation doesn't allow this.
Probably you have to use threads for that. You have to play your audio file in a different thread than the gui mainloop so that the GUI keeps responding user input.
IMHO, wxpython is not so complicated and has some utility functions that would help to do what you want. Check the wxpython demo, you have several examples there.
You can alternatively use pygame mixer for the purpose , I made the same in pyqt and I did'nt require to implement threading . You can get the documentation of pygame mixer at https://www.pygame.org/docs/ref/mixer.html
Happy Coding .
Try this out:
Check the code https://drive.google.com/file/d/0B7ccI33Aew5fNVhwZ2puYTBuUFU/view?usp=sharing
I have used pygame also.Hope this helps.