To display images, I had a Gtk.Pixmap.Gtk_Pixmap in a Gtk.Event_Box.Gtk_Event_Box.
Since Gtk.Pixmap is obsolescent, I try to replace it by
Gtk.Image.Gtk_Image.
When I replace Gtk.Pixmap.Gtk_Pixmap by Gtk.Image.Gtk_Image, it doesn't
work.
Why? What's specific to Gtk_Pixmap or Gtk_Image so it has not the same behavior in Gtk_Event_Box?
When I replace Gtk.Event_Box.Gtk_Event_Box by Gtk.Image.Gtk_Image, it
works fine, except the replacement by an other image.
(I try it using Gtk.Image.Get and Gtk.Image.Set, but it doesn't work.)
Is there an other container, that I should use instead of Gtk.Event_Box.Gtk_Event_Box that would work and that I should use
to replace the image inside?
On 2022-03-24 13:55, Thomas wrote:
To display images, I had a Gtk.Pixmap.Gtk_Pixmap in a Gtk.Event_Box.Gtk_Event_Box.
Since Gtk.Pixmap is obsolescent, I try to replace it by Gtk.Image.Gtk_Image.
When I replace Gtk.Pixmap.Gtk_Pixmap by Gtk.Image.Gtk_Image, it doesn't work.
Why? What's specific to Gtk_Pixmap or Gtk_Image so it has not the same behavior in Gtk_Event_Box?
When I replace Gtk.Event_Box.Gtk_Event_Box by Gtk.Image.Gtk_Image, it
works fine, except the replacement by an other image.
(I try it using Gtk.Image.Get and Gtk.Image.Set, but it doesn't work.)
Is there an other container, that I should use instead of Gtk.Event_Box.Gtk_Event_Box that would work and that I should use to replace the image inside?
I don't know what are you trying to achieve.
If you want to change a
child of a container, remove the old child and add a new one.
is it clear enough ?
On 2022-03-24 16:14, Thomas wrote:
[...]
is it clear enough ?
Not really. But anyway it does not work this way.
In order to change
image's pixbuff you must redraw it afterwards and possibly resize it
etc. It is possible, but you must understand the inner workings of GTK.
Much simpler is to replace the image widget as a whole.
If you need a button with image just put an image into it. Gtk_Button is already a container.
Put Gtk_Box into it. Put Gtk_Image into Gtk_Box.
That's would be all.
In article <t1i3qd$oud$1@gioia.aioe.org>,
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
If you need a button with image just put an image into it. Gtk_Button is
already a container.
yes, it works fine :-)
Put Gtk_Box into it. Put Gtk_Image into Gtk_Box.
That's would be all.
do you mean that (for a simple image, not a button) i should use a
Gtk_Box as intermediate container, instead of a Gtk_Event_Box?
On 2022-03-24 19:40, Thomas wrote:
In article <t1i3qd$oud$1@gioia.aioe.org>,
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
If you need a button with image just put an image into it. Gtk_Button is >> already a container.
yes, it works fine :-)
Put Gtk_Box into it. Put Gtk_Image into Gtk_Box.
That's would be all.
do you mean that (for a simple image, not a button) i should use a
Gtk_Box as intermediate container, instead of a Gtk_Event_Box?
Gtk_Box is handy as you can place many children into it, e.g. labels,
use alignment etc.
normal
containers already do the work. If you use Gtk_Event_Box you would have
to handle necessary signals to make everything work as it would with
Gtk_Box out of the box (no pun intended).
but first, since you seem to be sure that Gtk_Box is the right container
to use, i tested it ...
it doesn't work !
i don't understand why.
it is put in a Gtk_Fixed, can that have an influence?
the case where it works are :
- Gtk_Pixmap instead of Gtk_Image
- Gtk_Image without container
- Gtk_Button set with a Gtk_Image
any idea of what i should try, now?
On 2022-03-25 02:53, Thomas wrote:
but first, since you seem to be sure that Gtk_Box is the right container
to use, i tested it ...
it doesn't work !
I am using Gtk_Image in Gtk_Box, it works perfectly well, and worked in
GTK 2 (I am using GTK 3).
i don't understand why.
it is put in a Gtk_Fixed, can that have an influence?
Gtk_Fixed should never be used, but I doubt it can be the reason.
the case where it works are :
- Gtk_Pixmap instead of Gtk_Image
- Gtk_Image without container
- Gtk_Button set with a Gtk_Image
any idea of what i should try, now?
Do you call Show on the new child widget after replacing it?
In article <t1jr00$1ja4$1@gioia.aioe.org>,
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
I am using Gtk_Image in Gtk_Box, it works perfectly well, and worked in
GTK 2 (I am using GTK 3).
(Gtk_Pixmap were fully removed from GTK 3)
afaiu, the specific thing about Gtk_Pixmap is that i need not to call
Show on it, calling Show on its parent is enough.
but, I thought calling Show on a container was recursive on its childs, wrong?
is it ok, or do you think i should avoid it anyway?
if i should avoid it, is there an other Gtk_Bin that i could use, or do
you think Gtk_Box is the only one i should use for this purpose?
On 2022-03-25 20:37, Thomas wrote:
In article <t1jr00$1ja4$1@gioia.aioe.org>,
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
I am using Gtk_Image in Gtk_Box, it works perfectly well, and worked in
GTK 2 (I am using GTK 3).
(Gtk_Pixmap were fully removed from GTK 3)
It is Gdk_Pixbuf now.
afaiu, the specific thing about Gtk_Pixmap is that i need not to call
Show on it, calling Show on its parent is enough.
No, I think that pixmap handles the Draw signal, so you do not need Show because all rendering optimizations are turned off.
but, I thought calling Show on a container was recursive on its childs, wrong?
It is recursive, but it affects only actual children. New children are
hidden by default. I think this is going to change in GTK 4.
is it ok, or do you think i should avoid it anyway?
My understanding is that some widgets are optimized not to process
signals from input devices, e.g. Gtk_Label and Gtk_Image. Because
normally, you would not use keyboard or mouse buttons on them. But if
you need that, you add Gtk_Event_Box. If things work without it, then
leave it as is.
if i should avoid it, is there an other Gtk_Bin that i could use, or do
you think Gtk_Box is the only one i should use for this purpose?
I think any container is OK. I use Gtk_Box just because I want both
label and icon on the button.
Gtk_Fixed is bad because it breaks widget resizing protocol. If you
never resize (e.g. when changing the widget style, fonts, for example)
then Gtk_Fixed is just fine.
In article <t1l90i$1otm$1@gioia.aioe.org>,
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
It is recursive, but it affects only actual children. New children are
hidden by default. I think this is going to change in GTK 4.
i understand that about mcc.tki.Widget.Picture.Set_Image.
but in mcc.tki.Widget.Picture.Create,
when i call Gtk.Container.Add, and then Gtk.Widget.Show on the
container, it doesn't work.
i need to call Gtk.Widget.Show on the image too.
(no matter if i don't understand, at least that works :-) but if you
have enough patience, i like understand things :-) )
Gtk_Fixed is bad because it breaks widget resizing protocol. If you
never resize (e.g. when changing the widget style, fonts, for example)
then Gtk_Fixed is just fine.
i don't understand details, but i think since RAPID was designed with Gtk_Fixed I can keep it without inconvenience in the short term.
(i plan to make an other design in the medium term.)
On 2022-03-26 02:38, Thomas wrote:
In article <t1l90i$1otm$1@gioia.aioe.org>,
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
It is recursive, but it affects only actual children. New children are
hidden by default. I think this is going to change in GTK 4.
i understand that about mcc.tki.Widget.Picture.Set_Image.
but in mcc.tki.Widget.Picture.Create,
when i call Gtk.Container.Add, and then Gtk.Widget.Show on the
container, it doesn't work.
i need to call Gtk.Widget.Show on the image too.
(no matter if i don't understand, at least that works :-) but if you
have enough patience, i like understand things :-) )
Maybe the widgets involved must be "realized" for recursive Show to
work? The allocation size might be needed correctly set.
Maybe the image
is actually rendered but at a wrong place and size where it is not
visible.
There are many ways to mess it up.
Gtk_Fixed is bad because it breaks widget resizing protocol. If you
never resize (e.g. when changing the widget style, fonts, for example)
then Gtk_Fixed is just fine.
i don't understand details, but i think since RAPID was designed with Gtk_Fixed I can keep it without inconvenience in the short term.
(i plan to make an other design in the medium term.)
RAPID is a GUI generator thing, right?
So it tries to manage the layout
by itself instead of using the prescribed techniques. Then Gtk_Fixed is
a way to go.
In article <t1mkkt$1vs3$1@gioia.aioe.org>,
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
since it can be made before call to Gtk.Container.Add, that raises a new question:
should i prefer to call Gtk.Image.Show as soon as possible, when
creating mcc.tki.Image.External_Image?
or should i call Gtk.Image.Show only at the time it is really displayed,
when creating mcc.tki.Widget.Picture.Picture?
So it tries to manage the layout
by itself instead of using the prescribed techniques. Then Gtk_Fixed is
a way to go.
it asks the user to choose the position and size of each widget, instead
of ask him to make stacks with automatic layout management, like Gtk
does with Gtk_Box.
On 2022-03-26 18:32, Thomas wrote:
should i prefer to call Gtk.Image.Show as soon as possible, when
creating mcc.tki.Image.External_Image?
or should i call Gtk.Image.Show only at the time it is really displayed, when creating mcc.tki.Widget.Picture.Picture?
I usually create new widgets derived from a container, more or less
always. GtkAda allows this nicely. Then in my implementation of
Initialize for the custom I call Show at its end. I never had issues
with this approach.
it asks the user to choose the position and size of each widget, instead
of ask him to make stacks with automatic layout management, like Gtk
does with Gtk_Box.
Yes, using GTK in a totally non-GTK way.
I had this problem designing my
GTK/Cairo-based library for instruments like meters, gauges etc. I used relative positions and sizes instead of fixed ones to support resizing
the top-level dashboard widgets. Plus hacks for keeping or not keeping
aspect ratio of the resized thing. The base is Gtk_Drawing_Area_Record
rather than Gtk_Fixed_Record.
i don't think it's pertinent to apply full flexibility to all widgets,
but :
as is, i get 2 differents behaviors :
- with Tcl/Tk, the window can be fully resized, the overflowing widgets
are hidden, and still shown when the window is enlarged.
- with GTK, the window cannot be fully resized, it is forbidden to hide
any widget set in the Gtk_Fixed.
On 2022-03-27 18:41, Thomas wrote:
i don't think it's pertinent to apply full flexibility to all widgets,
but :
as is, i get 2 differents behaviors :
- with Tcl/Tk, the window can be fully resized, the overflowing widgets
are hidden, and still shown when the window is enlarged.
This is of course unacceptable behavior.
- with GTK, the window cannot be fully resized, it is forbidden to hide
any widget set in the Gtk_Fixed.
The proper approach in case you do not want to resize children is to use Gtk_Scrolled_Window as the top-level container.
You can always catch size allocation signals and hide widgets you wanted.
(afaiu, i need to put a Gtk_Viewport in a Gtk_Scrolled_Window ?
a Gtk_Window doesn't do the job ?)
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 399 |
Nodes: | 16 (2 / 14) |
Uptime: | 110:04:38 |
Calls: | 8,369 |
Calls today: | 8 |
Files: | 13,165 |
Messages: | 5,898,998 |