What is this widget?

M

Muddy Coder

Hi Folks,

I am trying to write letters on a photo that is opened in a canvas. So
I think I must need a widget to contain the letters I will type in. I
tried to use a Label, it worked. But, a Label covered part of the
photo underneath, so I can't use it. I saw some software did such a
thing nicely: a box popped on a photo, with dotted lines as borders,
expandable. When such a box was re-sized with a mouse, the font size
in the box also got changed. The box has no background color, so it
does not cover a rectangle area on the photo. I need such a widget,
but I don't know what is this one. I tried Text, Label, but they all
come with Window-like stuff, so they cover some photo content. Can
somebody points me a direction? Thanks!


Cosmo
 
D

Dave Angel

Hi Folks,

I am trying to write letters on a photo that is opened in a canvas. So
I think I must need a widget to contain the letters I will type in. I
tried to use a Label, it worked. But, a Label covered part of the
photo underneath, so I can't use it. I saw some software did such a
thing nicely: a box popped on a photo, with dotted lines as borders,
expandable. When such a box was re-sized with a mouse, the font size
in the box also got changed. The box has no background color, so it
does not cover a rectangle area on the photo. I need such a widget,
but I don't know what is this one. I tried Text, Label, but they all
come with Window-like stuff, so they cover some photo content. Can
somebody points me a direction? Thanks!


Cosmo
I don't have an answer, but it'd be much easier for others if you
specified what gui toolkit you're using, and probably also the OS and
Python versions.
 
D

Dennis Lee Bieber

I am trying to write letters on a photo that is opened in a canvas. So
I think I must need a widget to contain the letters I will type in. I
tried to use a Label, it worked. But, a Label covered part of the
photo underneath, so I can't use it. I saw some software did such a
thing nicely: a box popped on a photo, with dotted lines as borders,
expandable. When such a box was re-sized with a mouse, the font size
in the box also got changed. The box has no background color, so it
does not cover a rectangle area on the photo. I need such a widget,
but I don't know what is this one. I tried Text, Label, but they all
come with Window-like stuff, so they cover some photo content. Can
somebody points me a direction? Thanks!

You haven't specified which toolkit you are using: Tk, wx, GTK,
win32 native... So I'm going to go down to the root basics.

The "widget" would be the entire image canvas, you have to intercept
each key stroke and mouse operation (to control the dotted box size),
and render the text via a combination of first blitting the photo to the
canvas and then drawing the dotted box and text over the rendered photo.

With advanced coding you could keep track of the dotted border and
only blit that part of the photo onto the visible canvas each time you
update the box contents.

Maybe some toolkit has a native way to do this, but it would have to
be a totally transparent widget except for the dot outline, dynamically
positioned over the photo canvas.
 
T

Terry Reedy

Hi Folks,

I am trying to write letters on a photo that is opened in a canvas. So
I think I must need a widget to contain the letters I will type in. I
tried to use a Label, it worked. But, a Label covered part of the
photo underneath, so I can't use it.

You could use a entry widget over or outside the canvas for the user to
enter the text, and then close that box and write the entered text to
the canvas. Whether you can make the background of the entry box
transparent probably depends on the gui toolkit.
 
R

Rick Johnson

Hi Folks,

I am trying to write letters on a photo that is opened in a canvas. So
I think I must need a widget to contain the letters I will type in. I
tried to use a Label, it worked. But, a Label covered part of the
photo underneath, so I can't use it. I saw some software did such a
thing nicely: a box popped on a photo, with dotted lines as borders,
expandable. When such a box was re-sized with a mouse, the font size
in the box also got changed. The box has no background color, so it
does not cover a rectangle area on the photo. I need such a widget,
but I don't know what is this one. I tried Text, Label, but they all
come with Window-like stuff, so they cover some photo content. Can
somebody points me a direction? Thanks!

Listen Muddy, this is not first time that you've come here seeking
advice with a cryptic and ambiguous post. People have been very
patient and even asked you to be more explicit with your questions. I
highly advise you to re-write your original post and include which GUI
library you are using and any other pertinent info.

My guess is that you are using Tkinter. If so, i believe the canvas
has a method called "create_text" which will do what you want. To make
the input easier to code, use a Tkinter Entry widget stuffed into a
dialog -- tkSimpleDialog makes this, well, simple.

PS: Clean up you act Muddy!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top