【问题标题】:Center of canvas in tcl/tktcl/tk 中的画布中心
【发布时间】:2016-03-05 03:00:40
【问题描述】:

如果我需要输入坐标,如何在画布中心创建一个对象?

如果可能的话,如何获取画布中心的坐标?

【问题讨论】:

    标签: tcl tk


    【解决方案1】:

    来自Bag of TK algorithms 并在此google mailing list thread 中讨论过:

      toplevel .child
      set parent .
      set child .child
    
      # This should display $child centered in $parent
      set w [winfo width $parent]
      set h [winfo height $parent]
      set x [winfo rootx $parent]
      set y [winfo rooty $parent]
      set xpos "+[ expr {$x+($w-[winfo width $child])/2}]"
      set ypos "+[ expr {$y+($h-[winfo height $child])/2}]"
    
      wm geometry $child "$xpos$ypos"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-13
      • 2021-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多