Python/Tkinter - Making The Background of a Textbox an Image? - python

Since Text(Tk(), image="somepicture.png") is not an option on text boxes, I was wondering how I could make bg= a .png image. Or any other method of allowing a text box to stay a text box, with an image in the background so it can blend into a its surroundings.

You cannot use an image as a background in a text widget.
The best you can do is to create a canvas, place an image on the canvas, and then create a text item on top of that. Text items are editable, but you would have to write a lot of bindings, and you wouldn't have nearly as many features as the text widget. In short, it would be a lot of work.

Related

How to make Entry box in Tkinter transparent?

I want to make my Entry box without any color and only shows the cursor so it will blend with the canvas image. Here is what I want to make objective design and here is what I am able to make current design.
I did try the root.wm_attributes("-transparentcolor", "yellow") but it will also make the frame invisible. How do I make the entry box transparent without affecting the background. My code is based on the link below.
https://github.com/ajinkyapadwad/Tkinter-HosoKeys

How to resize images in a canvas dynamically in tkinter?

In Tkinter, resizing a canvas and/or frame can be done using
canvas.pack(fill="both", expand=True)
This way I can drag the tkinter window with the mouse and the canvas and frames within will adapt to the new size.
However I have not found a solution for applying this to images within the canvas. Only solutions so far are to independently change the size of the images through event actions.
Is there any way to make images within a canvas to resize dynamically, just like the canvas does with the one-liner above?
Is there any way to make images within a canvas to resize dynamically, just like the canvas does with the one-liner above?
No, there is no way to do what you want. Images aren't like widgets which can automatically grow and shrink. You will need to set up a binding on the <Configure> event of the containing widget, and in the bound function you will have to convert the image to the desired size.

Draw line on text widget in Tkinter [duplicate]

I was wondering whether it is possible to use some of the tkinter canvas drawing methods on a text widget. Ideally I would have the text widget placed onto the canvas so that I can draw onto the canvas and make it look like it shows up on the text widget.
No, it is not possible to draw over or into a tkinter Text widget. You can, however, add text to a canvas with the create_text method and draw over that.

Python Tkinter - How to move a textbox by pixels

What the title says.
I'm having a problem moving the textbox from a side to side.
The code's long and it's about 200+ lines so I wont post it here.
Anybody has an idea?
You have various options for this, depending on what you mean by "text box," and whether you want to move it "by pixels" or "from a side to [another] side."
If you just want to display text, you can use a Label widget. If you want a text box where the user can enter text, try an Entry widget. If you want to move your widget from one area of the screen to another, you can use the grid geometry manager and simply use grid_forget to "unplace" your widget then grid (with different options than you originally used, of course) to put it somewhere else.
If you just have text and you'd like to move it pixel by pixel, you could create a Canvas and then use that widget's create_text method to create some text in a specific place on the Canvas. You can the use the Canvas widget's itemconfig method to move the text to a new location.
If you need something more complex than text, like an Entry widget, and you want to move it pixel by pixel, do the same as above but use the create_window method instead.
See Canvas, grid, Label, Entry, and these SO questions about create_window.

movable and resizable text edit control like in mspaint using wxpython

Hi I am trying to add some text to an image, and want adjust font, size, etc.
Is there any way to implement a mspaint style text input control in wxpython?
It have a rectangle area you can input text in it, and with 8 handler in 4 corner and 4 border to adjust size. I see many control like it in photoshop and other image process software.
Check out Whyteboard. I think it has one of those widgets and it's written in wxPython:
http://whyteboard.org/

Categories