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
Related
I am creating a program that needs to accept a string (such as a paragraph) from the user, then display certain words from that string in a larger font. Would I use PyGame for this? I know text can be put on the screen with PyGame, but I am having difficulty storing the input from the user. I am using Sublime 3 with SublimeREPL, and when I take user input, REPL says it can not run with Python. Can user input be acquired without SublimeREPL, such as directly with PyGame? If not, how would I go about making the program as described above?
I am new to programming, so I apologize for any misunderstandings. Any and all help will be appreciated. Thank you!
First: run it without Sublime and SublimeREPL. Run python your_script.py. Users will do the same.
If you need only one input then you can
run script with parameters python your_script.py "some text",
use input() in Python to get text before it will run PyGame.
But these methods need terminal (text window) and don't look nice when you create graphics program.
PyGame doesn't have widgets to get text from user. There are modules which can add some widgets but you have to learn how to build PyGame application with widgets because they may need to respect some rules.
See GUI on page PyGame.org
(ie. OcempGUI)
You can try to build own widget to get text. You can use key event to get text, update text in list (add or remove char) and use text from list to update text in window. Text Input
Some people use Tkinter to display window which ask for text. Or they embed PyGame in Tkinter's window with other widgets.
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
I`m using pyPdf to crop pdf pages.
And the only thing i miss, is GUI for this script.
I picked up tkinter module to do the GUI, but i cannot find whether it is possible to display pdf pages with GUI created with tkinter.
Any thoughts ?
Thank you.
Tkinter has no support for displaying pdf.
I once tried doing the same thing, and I managed to do it in wxPython with a widget that does just that. On Qt however, I didn't manage to do such a thing, and I doubt you could with Tkinter too.
The closest I got was converting to images and displaying the images: see this question.
Note: I'm talking about wxPython and Qt, but I guess the same principle applies for Tkinter.
In my python GTK project, I have a popup menu which pop-ups while typing in a particular text area. But, when type a letter popup menu get the focus and I can't type anymore in the text area until I click on the text area and grab the focus manually. I want to keep the focus to the text area as I type regularly while popup menu comes. Can anyone give tell me a way to do this. I tried widget.grab_focus() method. But it didn't solve my problem.
Also I want to know how to set the position of the popup menu. It always appears near by mouse pointer. I want it to appear near by my application.
Thanks all.
I ran into the same problem using the C API, the solution was to invoke the following functions, I presume they're approximately similar to the python equivalents:
gdk_pointer_ungrab(GDK_CURRENT_TIME);
gdk_keyboard_ungrab(GDK_CURRENT_TIME);
gtk_grab_remove(menu);
I am trying to extend a unity appindicator for project hamster. What I want to do is have a text entry directly in the indicator menu. I have seen this for example in the ubuntu memenu, but I cannot figure out how to get it to work with pygtk. I have searched for a while and found nothing. Does anyone know how to do this?
I'm pretty sure there is no way to add that in a menu in PyGTK, but you might try a borderless window popup.