【问题标题】:Graphviz: align nodes on left side instead of centering (With answer)Graphviz:在左侧对齐节点而不是居中(有答案)
【发布时间】:2018-08-02 03:24:21
【问题描述】:

我制作了一个 python 脚本来使用 graphviz 绘制目录结构。 为了正确渲染图形,我使用 rankdir=LR。但是,具有相同等级的节点居中。

见下图。

如您所见,“.gitignore”、“.travis.yml”等节点因其标签而具有不同的宽度。 无论宽度如何,我都希望相同等级的节点在左侧对齐。

我看过其他相关的帖子,例如 this one,但我不想强制节点宽度。

还有其他方法吗?

提前感谢您的回答,祝您有美好的一天。

附: 这是我的图形代码示例:

strict digraph projetcStructure { 
    graph [overlap=false, splines=ortho, ranksep=0.05]
    edge[arrowhead=none, color=black]
    node[fontname="DejaVu Sans Mono", fontsize=14]
    "e0ec0f89f0745e25b725768b304be71e" [shape=folder, style=filled, colorscheme=ylgnbu3, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/file-directory.png" SCALE="TRUE"/></TD><TD>TechnicalReport</TD></TR></TABLE>>, color=2]
    "77a7da2a6f864418dd23f49f9c5e9804" [shape=note, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/git-merge.png" SCALE="TRUE"/></TD><TD>.gitignore</TD></TR></TABLE>>, color=1]
    "373d5e485b88f76e79d5bab15a88759e" [shape="point", width=0, height=0]
    "8e58ce33bdaaa1db79bab7080019c6fe" [shape=note, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/travis.png" SCALE="TRUE"/></TD><TD>.travis.yml</TD></TR></TABLE>>, color=1]
    "b56aa426f8ad0d8a7704c909f2473b70" [shape="point", width=0, height=0]
    "98a5f187b3527ca7f00643e7907b3453" [shape=note, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/book.png" SCALE="TRUE"/></TD><TD>LICENSE</TD></TR></TABLE>>, color=1]
    "07adcea039d69fb282b22eebd8daf537" [shape="point", width=0, height=0]
    "ede2c50901cc59eeb8987d630d055b22" [shape=note, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/terminal.png" SCALE="TRUE"/></TD><TD>makeScript.sh</TD></TR></TABLE>>, color=1]
    "8f182d8be99f90432a2bec25a864bf19" [shape="point", width=0, height=0]
    "53ccb88dccecc95c401d180aa34ac0ac" [shape=note, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/note.png" SCALE="TRUE"/></TD><TD>README.rst</TD></TR></TABLE>>, color=1]
    "f6ffc62db5cefc5b4a1eb2e6a3731802" [shape="point", width=0, height=0]
    "3f917d2353bb6c1c156b18a78f23cf71" [shape=note, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/file.png" SCALE="TRUE"/></TD><TD>requirements.txt</TD></TR></TABLE>>, color=1]
    "acc1004c581f3b603d2a33092ffcfe61" [shape="point", width=0, height=0]
    "2d05acf91c352a7ac491e18dcf65fc9c" [shape=note, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/settings.png" SCALE="TRUE"/></TD><TD>setup.cfg</TD></TR></TABLE>>, color=1]
    "8e1760a00144fca5272f341da0873674" [shape="point", width=0, height=0]
    "b78eb5bb77cb04f62506859fb1ab76f8" [shape=note, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/terminal.png" SCALE="TRUE"/></TD><TD>test.sh</TD></TR></TABLE>>, color=1]
    "cc60f62b1b3d0cf8c266074b7139b567" [shape="point", width=0, height=0]
    "3512568f6984d40e6353aa13b5029dc3" [shape=folder, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/mark-github.png" SCALE="TRUE"/></TD><TD>.github</TD></TR></TABLE>>, color=1]
    "88ae0eb0f89e79ddff8e2b1fe470a488" [shape="point", width=0, height=0]
    "9b43ae74e93bdb3dadace6084e333a27" [shape=folder, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/file-directory.png" SCALE="TRUE"/></TD><TD>foldertree</TD></TR></TABLE>>, color=1]
    "2f9f172522c65ab785d2c23db909b36a" [shape="point", width=0, height=0]
    "e7925cdfdefd09112b8b3c8b5ddde087" [shape=folder, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/file-directory.png" SCALE="TRUE"/></TD><TD>generated</TD></TR></TABLE>>, color=1]
    "0b54fbb48c26181df9c8a5fd3bab1049" [shape="point", width=0, height=0]
    "69d5f4cf4e091e008cb1f4de43692b4d" [shape=folder, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/file-directory.png" SCALE="TRUE"/></TD><TD>TechnicalReportGenerator</TD></TR></TABLE>>, color=1]
    "c4f859f4d369226348a4eb08adab0afc" [shape="point", width=0, height=0]
    "0ab55395ce4ef62f7a9f5f72201ce0ae" [shape=folder, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/file-directory.png" SCALE="TRUE"/></TD><TD>worklog</TD></TR></TABLE>>, color=1]
    "9b4f2a57b302961cd3509dd307121cfa" [shape="point", width=0, height=0]
    "77a7da2a6f864418dd23f49f9c5e9804" [shape=note, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/git-merge.png" SCALE="TRUE"/></TD><TD>.gitignore</TD></TR></TABLE>>, color=1]
    "8e58ce33bdaaa1db79bab7080019c6fe" [shape=note, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/travis.png" SCALE="TRUE"/></TD><TD>.travis.yml</TD></TR></TABLE>>, color=1]
    "98a5f187b3527ca7f00643e7907b3453" [shape=note, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/book.png" SCALE="TRUE"/></TD><TD>LICENSE</TD></TR></TABLE>>, color=1]
    "ede2c50901cc59eeb8987d630d055b22" [shape=note, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/terminal.png" SCALE="TRUE"/></TD><TD>makeScript.sh</TD></TR></TABLE>>, color=1]
    "53ccb88dccecc95c401d180aa34ac0ac" [shape=note, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/note.png" SCALE="TRUE"/></TD><TD>README.rst</TD></TR></TABLE>>, color=1]
    "3f917d2353bb6c1c156b18a78f23cf71" [shape=note, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/file.png" SCALE="TRUE"/></TD><TD>requirements.txt</TD></TR></TABLE>>, color=1]
    "2d05acf91c352a7ac491e18dcf65fc9c" [shape=note, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/settings.png" SCALE="TRUE"/></TD><TD>setup.cfg</TD></TR></TABLE>>, color=1]
    "b78eb5bb77cb04f62506859fb1ab76f8" [shape=note, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/terminal.png" SCALE="TRUE"/></TD><TD>test.sh</TD></TR></TABLE>>, color=1]
    "3512568f6984d40e6353aa13b5029dc3" [shape=folder, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/mark-github.png" SCALE="TRUE"/></TD><TD>.github</TD></TR></TABLE>>, color=1]
    "9b43ae74e93bdb3dadace6084e333a27" [shape=folder, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/file-directory.png" SCALE="TRUE"/></TD><TD>foldertree</TD></TR></TABLE>>, color=1]
    "e7925cdfdefd09112b8b3c8b5ddde087" [shape=folder, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/file-directory.png" SCALE="TRUE"/></TD><TD>generated</TD></TR></TABLE>>, color=1]
    "69d5f4cf4e091e008cb1f4de43692b4d" [shape=folder, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/file-directory.png" SCALE="TRUE"/></TD><TD>TechnicalReportGenerator</TD></TR></TABLE>>, color=1]
    "0ab55395ce4ef62f7a9f5f72201ce0ae" [shape=folder, style=filled, colorscheme=ylgnbu3, width=3.7555555555555555, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/foldertree/octicons/file-directory.png" SCALE="TRUE"/></TD><TD>worklog</TD></TR></TABLE>>, color=1]
    {rank=same;  "373d5e485b88f76e79d5bab15a88759e" "b56aa426f8ad0d8a7704c909f2473b70" "07adcea039d69fb282b22eebd8daf537" "8f182d8be99f90432a2bec25a864bf19" "f6ffc62db5cefc5b4a1eb2e6a3731802" "acc1004c581f3b603d2a33092ffcfe61" "8e1760a00144fca5272f341da0873674" "cc60f62b1b3d0cf8c266074b7139b567" "88ae0eb0f89e79ddff8e2b1fe470a488" "2f9f172522c65ab785d2c23db909b36a" "0b54fbb48c26181df9c8a5fd3bab1049" "c4f859f4d369226348a4eb08adab0afc" "9b4f2a57b302961cd3509dd307121cfa"}
"e0ec0f89f0745e25b725768b304be71e" -> "373d5e485b88f76e79d5bab15a88759e"
"373d5e485b88f76e79d5bab15a88759e" -> "b56aa426f8ad0d8a7704c909f2473b70"
"b56aa426f8ad0d8a7704c909f2473b70" -> "07adcea039d69fb282b22eebd8daf537"
"07adcea039d69fb282b22eebd8daf537" -> "8f182d8be99f90432a2bec25a864bf19"
"8f182d8be99f90432a2bec25a864bf19" -> "f6ffc62db5cefc5b4a1eb2e6a3731802"
"f6ffc62db5cefc5b4a1eb2e6a3731802" -> "acc1004c581f3b603d2a33092ffcfe61"
"acc1004c581f3b603d2a33092ffcfe61" -> "8e1760a00144fca5272f341da0873674"
"8e1760a00144fca5272f341da0873674" -> "cc60f62b1b3d0cf8c266074b7139b567"
"cc60f62b1b3d0cf8c266074b7139b567" -> "88ae0eb0f89e79ddff8e2b1fe470a488"
"88ae0eb0f89e79ddff8e2b1fe470a488" -> "2f9f172522c65ab785d2c23db909b36a"
"2f9f172522c65ab785d2c23db909b36a" -> "0b54fbb48c26181df9c8a5fd3bab1049"
"0b54fbb48c26181df9c8a5fd3bab1049" -> "c4f859f4d369226348a4eb08adab0afc"
"c4f859f4d369226348a4eb08adab0afc" -> "9b4f2a57b302961cd3509dd307121cfa"
    {rank=same;  "77a7da2a6f864418dd23f49f9c5e9804" "8e58ce33bdaaa1db79bab7080019c6fe" "98a5f187b3527ca7f00643e7907b3453" "ede2c50901cc59eeb8987d630d055b22" "53ccb88dccecc95c401d180aa34ac0ac" "3f917d2353bb6c1c156b18a78f23cf71" "2d05acf91c352a7ac491e18dcf65fc9c" "b78eb5bb77cb04f62506859fb1ab76f8" "3512568f6984d40e6353aa13b5029dc3" "9b43ae74e93bdb3dadace6084e333a27" "e7925cdfdefd09112b8b3c8b5ddde087" "69d5f4cf4e091e008cb1f4de43692b4d" "0ab55395ce4ef62f7a9f5f72201ce0ae"}
"373d5e485b88f76e79d5bab15a88759e" -> "77a7da2a6f864418dd23f49f9c5e9804"
"b56aa426f8ad0d8a7704c909f2473b70" -> "8e58ce33bdaaa1db79bab7080019c6fe"
"07adcea039d69fb282b22eebd8daf537" -> "98a5f187b3527ca7f00643e7907b3453"
"8f182d8be99f90432a2bec25a864bf19" -> "ede2c50901cc59eeb8987d630d055b22"
"f6ffc62db5cefc5b4a1eb2e6a3731802" -> "53ccb88dccecc95c401d180aa34ac0ac"
"acc1004c581f3b603d2a33092ffcfe61" -> "3f917d2353bb6c1c156b18a78f23cf71"
"8e1760a00144fca5272f341da0873674" -> "2d05acf91c352a7ac491e18dcf65fc9c"
"cc60f62b1b3d0cf8c266074b7139b567" -> "b78eb5bb77cb04f62506859fb1ab76f8"
"88ae0eb0f89e79ddff8e2b1fe470a488" -> "3512568f6984d40e6353aa13b5029dc3"
"2f9f172522c65ab785d2c23db909b36a" -> "9b43ae74e93bdb3dadace6084e333a27"
"0b54fbb48c26181df9c8a5fd3bab1049" -> "e7925cdfdefd09112b8b3c8b5ddde087"
"c4f859f4d369226348a4eb08adab0afc" -> "69d5f4cf4e091e008cb1f4de43692b4d"
"9b4f2a57b302961cd3509dd307121cfa" -> "0ab55395ce4ef62f7a9f5f72201ce0ae"

}

[编辑]

经过一些研究并感谢@TomServo,我已经能够“修复”节点宽度。

我使用以下代码。 ImageFont 文档可以找到here

font = ImageFont.truetype('DejaVuSansMono.ttf', FONT_SIZE)
width = font.getsize("YOUR STRING TO MEASURE HERE")[0]
# convert pixels to inches and add extra space for icons and margins
# icon size is defined as points which is a 72's of an inch
width = width / GRAPHVIZ_DPI + ((1 / 72) * 20 * 2)

那么结果:

【问题讨论】:

    标签: nodes graphviz rank


    【解决方案1】:

    对不起,但我认为没有固定等级中节点宽度的方法可以达到您想要的效果。您可能需要重新考虑,因为让您的节点具有相同的宽度确实会使图形更加整洁:

    strict digraph projetcStructure { 
        graph [overlap=false, splines=ortho, ranksep=0.05, rankdir=LR]
        edge[arrowhead=none, color=black]
        "2f173bfac231270e0418210e8a3552d2" [shape=folder, style=filled, colorscheme=ylgnbu3, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/FolderTree/octicons/file-directory.png" SCALE="TRUE"/></TD><TD>TechnicalReport</TD></TR></TABLE>>, color=3, width=2.0]
        "6b9ec0d7104a108a26ba34f9672f35a5" [shape=note, style=filled, colorscheme=ylgnbu3, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/FolderTree/octicons/git-merge.png" SCALE="TRUE"/></TD><TD>.gitignore</TD></TR></TABLE>>, color=2, width=2.0]
        "6a20aaea09ab2aac28e4b8f50f46d9e6" [shape="point", width=0, height=0]
        "ad9d05da3ebed612a90ab85a30d039d7" [shape=note, style=filled, colorscheme=ylgnbu3, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/FolderTree/octicons/travis.png" SCALE="TRUE"/></TD><TD>.travis.yml</TD></TR></TABLE>>, color=2, width=2.0]
        "2bef36c3d9fd70fec1b1d395ec891948" [shape="point", width=0, height=0]
        "023bdc0f2f34c3d14a028c1190295079" [shape=note, style=filled, colorscheme=ylgnbu3, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/FolderTree/octicons/book.png" SCALE="TRUE"/></TD><TD>LICENSE</TD></TR></TABLE>>, color=2, width=2.0]
        "1a7aeec41293922786ed460f863c197c" [shape="point", width=0, height=0]
        "418903823b3792736b96279643175a80" [shape=note, style=filled, colorscheme=ylgnbu3, label=<<TABLE><TR><TD WIDTH="20" HEIGHT="20" FIXEDSIZE="TRUE"><IMG SRC="/mnt/e/Documents/3eme/TechnicalReport/FolderTree/octicons/terminal.png" SCALE="TRUE"/></TD><TD>makeScript.sh</TD></TR></TABLE>>, color=2, width=2.0]
    

    注意前几个节点末尾的width=2.0。这使它们具有相同的宽度并稍微清理了参差不齐的外观。

    此外,请务必将rankdir=LR 放在顶部附近,如图所示,正如您在问题中提到的那样。

    要“预先计算”必要的宽度,在 Windows 系统上,我会使用 Graphics 命名空间来确定宽度,如下所示:

    private void MeasureStringWidth(PaintEventArgs e)
    {
    
        // Set up string.
        string measureString = "Measure String";
        Font stringFont = new Font("Arial", 16);
    
        // Set maximum width of string.
        int stringWidth = 200;
    
        // Measure string.
        SizeF stringSize = new SizeF();
        stringSize = e.Graphics.MeasureString(measureString, stringFont, stringWidth);
    
        // Draw rectangle representing size of string.
        e.Graphics.DrawRectangle(new Pen(Color.Red, 1), 0.0F, 0.0F, stringSize.Width, stringSize.Height);
    
        // Draw string to screen.
        e.Graphics.DrawString(measureString, stringFont, Brushes.Black, new PointF(0, 0));
    }
    

    然后例如将stringSize.Width 值转换为英寸。添加一点内边距,为包含的图标图形添加一点额外的内容,然后将其用于统一宽度。

    最后,如果你不是在 Windows 系统上,或者没有使用 .NET,可能还有其他方法可以measure the width of a string,如 python 和 tkinter 的示例。所以不要放弃,你可以做到的!

    【讨论】:

    • 感谢您的回答。我将修复节点宽度。你知道是否有一种方法可以“预先计算”较大节点的宽度以便将其应用于每个节点?
    • Graphviz 参考手册没有提供关于确定最大宽度的任何线索,所以我认为它不支持它。但是,请参阅我编辑后的答案,了解一个可以稍加努力的额外想法。
    • 我也没有在手册中看到任何内容,这就是我问的原因。我会试试你的方法,根据最长文件名中的字符数和字体大小来估计宽度。我正在使用 Python,所以我认为这不是问题。我已经想过这样做,但我想知道是否有更简单的方法。非常感谢您的回答。周末愉快。
    • 我已经找到了计算宽度的方法。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-26
    • 2015-02-22
    • 2022-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-16
    相关资源
    最近更新 更多