Would someone please like to take a look at this video and explain
to me what is going on here? I swear I don't have a clue.
https://0x0.st/HcTs.mp4
I'm not posting the entire code because the video illustrates
the problem very well and I believe the relevant part of the
code is all there.
Thanks in advance.
--
Luc
Dear Luc,pointing to 404...
please post short code examples to show what your problem is. Nobody will click usually on dubious image or video links. Having the code in the group as well will help future readers of the message where the video or the image link is already
I'm not posting the entire code because the video illustrates
the problem very well and I believe the relevant part of the
code is all there.
Thanks in advance.
Dear Luc,
please post short code examples to show what your problem is. Nobody
will click usually on dubious image or video links. Having the code in
the group as well will help future readers of the message where the
video or the image link is already pointing to 404...
Best,
Detlef
I think your problem is in the other column labels expanding to fill the space from the name.
Not all of the labels in your script need to be "-fill x". As fas as I
can tell, only the first one, "name", needs to be that, and the rest
should have a fixed size. You may also want to make sure that you
configure "name" with "-expand 1" in addition to "-fill x".
On Fri, 9 Jun 2023 00:04:08 -0700 (PDT), D Groth wrote:
Dear Luc,
please post short code examples to show what your problem is. Nobody
will click usually on dubious image or video links. Having the code in
the group as well will help future readers of the message where the
video or the image link is already pointing to 404...
Best,
Detlef
Well, here is the code. But you don't have the SVG icon file.
package require Tk
load "/home/tcl/fm/libtksvg0.12.so"
set file "/home/tcl/fm/icons/svg/folder_open3.svg"
image create photo i1 -file $file -format {svg -scaletoheight 24}
bind . <Escape> {exit}
pack [frame .outerframe -bg #ffffff]
pack [frame .outerframe.line0 -padx 0 -pady 0 -relief raised -bd 0 -bg #ffffff]
set ::headings {
line0 Name heading_name
line0 Size heading_size
line0 Modified heading_date
line0 Permissions heading_perms
line0 Owner heading_owner
}
foreach {line name col} $::headings {
set w [button .outerframe.$line.$col -text $name -anchor w -relief raised -font {Arial 14} -width 10 -bd 1 -anchor center -padx 0 -pady 0]
if {$col == "heading_name"} {.outerframe.$line.$col configure -width 50 -text "$name [subst -nocommands \\u25be]"}
pack $w -side left -fill x
}
pack [frame .line1] [frame .line2] [frame .line3] [frame .line4]
set ::data {
line1 "File 1" name
line1 "32.1 Mb" size
line1 2023-05-05 date
line1 755 perms
line1 root:root owner
line2 "File 2" name
line2 "32.1 Mb" size
line2 2023-05-05 date
line2 755 perms
line2 root:root owner
line3 "File 3" name
line3 "32.1 Mb" size
line3 2023-05-05 date
line3 755 perms
line3 root:root owner
line4 "File 4" name
line4 "32.1 Mb" size
line4 2023-05-05 date
line4 755 perms
line4 root:root owner
}
foreach {line name val} $::data {
set w [label .$line.$val -text $name -anchor w -relief flat -font {Arial 14} -width 10 -fg #000000 -bg #ffffff -bd 2 -anchor center]
if {$line == "line1"} {.$line.$val configure -bg #4A6984 -fg #ffffff}
if {$val == "name"} {.$line.$val configure -width 50 -anchor w}
pack $w -side left -fill x
}
Thank you for all the suggestions. But they didn't work. Nothing seems
to have changed.
On 6/9/2023 5:07 PM, Luc wrote:
Thank you for all the suggestions. But they didn't work. Nothing seems
to have changed.
For buttons with text and images, you need to drastically increase the
width, not totally sure why.
For buttons with text and images, you need to drastically increase the
width, not totally sure why.
If I increase the with to 650 as follows, everything lines up nicely
again.
Check out the image: https://0x0.st/HcSR.png
By the way, there are several table type widgets available to you as packages. They might work better for you.
The /why/ is stated in the documentation:
man n button:
man n label:
Use grid if you really want to roll your own table -- or better yet, use
one of the "table" widgets.
On Sat, 10 Jun 2023 02:34:09 -0000 (UTC), Rich wrote:
The /why/ is stated in the documentation:
man n button:
man n label:
You are right again, of course.
Still confusing though because while the width measure/metric is automatically changed to pixels, height seems to be still measured
in text characters.
So looks like I am going to have to measure the icon's width which
will be variable because I'm using SVG
and the label's text width with [font metrics] and do some math.
The nice thing about [pack] is that I can [pack forget] a bunch of
widgets and not lose their configuration when I [pack] them again.
That is pretty valuable in an application with multiple tabs
(and an Undo Close Tab feature). Sadly, [grid] cannot do that.
grid also does have a subcommand "forget".
A few experiments seem to imply, that [pack forget] forgets
everything specific to the widget, same as [grid forget], so
I don't yet understand the preference for pack.
Could you expand on that a bit more?
So unless you are seeing something different (possible) the addition of
an image to a button or label causes both -width and -height to be
"pixel based" measurements instead of "size of underlying font based" >measurements.
So looks like I am going to have to measure the icon's width which
will be variable because I'm using SVG
How so? Are you dynamically changing the size of the icon?
On Sat, 10 Jun 2023 18:07:36 -0000 (UTC), Rich wrote:
So unless you are seeing something different (possible) the addition of
an image to a button or label causes both -width and -height to be
"pixel based" measurements instead of "size of underlying font based"
measurements.
Yes, I am seeing something different. When I insert the image and
change height from 1 to 2, it gets too tall, obviously twice as tall
as before the change. At 3, it begins to look ridiculous. It is
obviously not using pixels, but font height.
So looks like I am going to have to measure the icon's width which
will be variable because I'm using SVG
How so? Are you dynamically changing the size of the icon?
Not yet. But I will.
My initial plan was to provide multiple sets of icons. I have 16,
20, 24, 32, 48, 64 and 128px icon sets. I never liked that, but
what else could I do? Well, then I discovered SVG support for Tk.
That is a game changer. Now the user can press + and - keys at will
and choose arbitrary icon sizes. I am not looking back.
Or maybe I am. I've already seen it's rather difficult to make the
entire file list scale along with the icons. The text size would
have to follow suit somehow, or maybe I should leave it to the user
to realize that they can only go so far with the resizing.
As they say on TV, to be continued...
On Sat, 10 Jun 2023 18:07:36 -0000 (UTC), Rich wrote:
So unless you are seeing something different (possible) the addition of
an image to a button or label causes both -width and -height to be
"pixel based" measurements instead of "size of underlying font based" >>measurements.
Yes, I am seeing something different. When I insert the image and
change height from 1 to 2, it gets too tall, obviously twice as tall
as before the change. At 3, it begins to look ridiculous. It is
obviously not using pixels, but font height.
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (0 / 16) |
| Uptime: | 169:21:31 |
| Calls: | 12,097 |
| Calls today: | 5 |
| Files: | 15,003 |
| Messages: | 6,517,834 |