• Can I shimmer measuring units? (Image in labels mess them all up)

    From Luc@21:1/5 to All on Sat Jun 10 20:27:10 2023
    I seem to have found a way to make everything align correctly.
    Let's see if a bug won't come to bite me in the ass later.

    My solution probably fits in the "ugly hack is ugly" category though:
    I made a very skinny (1px wide) and transparent SVG icon that is now
    included in all other buttons and labels.

    Why would I do that? Well, let's see the documentation:

    Command-Line Name: -width
    Specifies a desired width for the label. If an image or bitmap is
    being displayed in the label then the value is in screen units (i.e.
    any of the forms acceptable to Tk_GetPixels); for text it is in
    characters. If this option is not specified, the label's desired width
    is computed from the size of the image or bitmap or text being
    displayed in it.

    Tk_GetPixels:
    <none>
    The number specifies a distance in pixels.
    c
    The number specifies a distance in centimeters on the screen.
    i
    The number specifies a distance in inches on the screen.
    m
    The number specifies a distance in millimeters on the screen.
    p
    The number specifies a distance in printer's points (1/72 inch)
    on the screen.


    So if my understanding is correct, there is no way to tell Tk that I
    want to use pixels as the measuring reference. And if I don't specify
    anything, Tk won't really interpret <none> as none and interpret the
    distance in pixels. Tk will rather assume whatever it wants to, which
    will not be pixels if no image is present.

    So if my understanding is correct, the only way to force measuring in
    pixels is to insert an image, even if it's not really wanted there.

    Or am I wrong? I would love to be wrong.

    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mark Case@21:1/5 to All on Sun Jun 11 20:29:44 2023
    I do the same thing.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Schelte@21:1/5 to Luc on Mon Jun 12 10:32:03 2023
    On 11/06/2023 01:27, Luc wrote:
    So if my understanding is correct, there is no way to tell Tk that I
    want to use pixels as the measuring reference. And if I don't specify anything, Tk won't really interpret <none> as none and interpret the
    distance in pixels. Tk will rather assume whatever it wants to, which
    will not be pixels if no image is present.

    Normally you want Tk to adjust widgets based on their contents and the
    size of the window. Aligning things should usually be achieved via the
    geometry manager. From past posts I understand that you mostly use pack.
    With pack it is difficult to align things. Even something as simple as a
    text window with both a horizontal and a vertical scrollbar requires
    hacks to get right. For such things, grid generally works much better.

    If you really want the odd widget to have a specific size, you can put
    it inside a frame and set the size of the frame. Frame width and height
    is always in screen units. For this purpose, I would put the widget
    inside the frame using the place geometry manager:
    place $w -in $f -relwidth 1 -relheight 1
    If using grid or pack, you have to switch off propagation to prevent the
    frame from resizing to fit its contents:
    pack propagate $f 0
    pack $w -in $f -fill both -expand 1


    Schelte.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)