Is it possible to have a text widget over an image? In other words, I need to have a background image and be able to write text on that image (overlaid).
It is not possible to overlay an image with a text widget, and have the image be visible under the widget.
What you can do instead is use a Canvas widget, display the image in the canvas, and then create text items on the canvas. Text items on the canvas are editable, though you have to do a little work to set up some bindings.
There is a good explanation of how to create editable text items on a canvas here: http://effbot.org/zone/editing-canvas-text-items.htm
Related
I want to have an image as a background to a Listbox, but I am am only able to find out how to change background color of one.
No, it is not possible to add an image as a background for the listbox.
Is it possible to replace text in label with an image in kivy?
I have a label containing a text but i want to replace the text with an image.
Is this possible in kivy?
The answer is technically yes, but this isn't something exposed by the label api so you'd have to mess about doing stuff manually. It would probably be a better idea to put an Image on top of (or behind) the Label, and use this to display the imgae when necessary.
A Tkinter Checkbutton widget can have a text or an image/bitmap. When using text the width and height configurations of the widget refer to characters, rather than pixels, but when using an image/bitmap they refer to pixels. I'm using a Checkbutton widget with no image nor text - just a plain checkbox. Is there a simple way to have it sized in pixels?
Note: I am familiar with the hack of wrapping it in a Frame, but am hoping this is avoidable here, as the widget itself does support by-pixel sizing.
If there's no simple way of instructing the widget to use "image mode" in these circumstances, what's a simple way of feeding it an empty bitmap (if that would at all work)?
In case it matters: I'm using Python 3.4.3 on Ubuntu 15.04.
Give it a 1x1 image (one pixel wide, one pixel tall). That will cause the size attribute to be based on pixels, and the image you give it will be virtually invisible.
import tkinter as tk
...
img = tk.PhotoImage(width=1, height=1)
cb = tk.Checkbutton(root, width=40, height=40)
...
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.
I wanted to create an app which has an image as its background. But when I add a Label over the image, the label had a white background.
Is there a way to set the Label widget's background color to 'transparent'?
I'm not aware of a way to make Label backgrounds transparent. One alternative is to use a Canvas widget as the base for the whole thing, then use the create_image method to add the background image, and create_text to make the text labels. It will be a bit more work, but the text should render without a background on top of the image. (Admittedly I have very little experience with the Canvas widget, so I'm speaking more from theory than experience, but it's worth a try.)
If you don't have a good Tkinter reference, I highly recommend this one made by New Mexico Tech. It's available as a downloadable PDF as well.