建立垂直布局,新版不再支援gtkhbox/gtkvbox。
// 新版不再支援gtkhbox/gtkvbox
// glade3 3.8 編輯器太老了, 使用glade-3.14
func
main()
)if err !=
nilrun
(os.args)
}func
createwindow
// 獲取window視窗
winobj,
_:= builder.
getobject
("window1"
) window := winobj.
(*gtk.window)
addwindow
(window)
// window 視窗設定
window.
setsizerequest
(300
,240
)//設定視窗大小
window.
settitle
("hello go"
)//設定標題
window.
setresizable
(false
)//設定不可伸縮
window.
setposition
(gtk.win_pos_center)
//設定居中顯示
err = window.
seticonfromfile()
//設定icon
if err !=
nil//獲取vbox控制項
vboxobj, err := builder.
getobject
("box1"
)if err !=
nil fmt.
println
("vboxobj"
, reflect.
typeof
(vboxobj)
) vbox := vboxobj.
(*gtk.box)
3)button,
_:= gtk.
buttonnewwithlabel
("新按鈕"
)//新建按鈕
vbox.
add(button)
//按鈕新增到布局中
// 顯示所有介面
window.
showall()
}/*訊號標識 觸發條件
「clicked」 按下按鈕時觸發
「pressed」 按下按鈕時觸發
「released」 釋放按鈕時觸發
*/
<?xml version="1.0" encoding="utf-8"?>
>
class
="gtkwindow"
id="window1"
>
name
="can_focus"
>
falseproperty
>
>
class
="gtkbox"
id="box1"
>
name
="visible"
>
trueproperty
>
name
="can_focus"
>
falseproperty
>
name
="orientation"
>
verticalproperty
>
name
="homogeneous"
>
trueproperty
>
>
class
="gtkbutton"
id="button1"
>
name
="label"
translatable
="yes"
>
buttonproperty
>
name
="visible"
>
trueproperty
>
name
="can_focus"
>
trueproperty
>
name
="receives_default"
>
trueproperty
>
object
>
>
name
="expand"
>
falseproperty
>
name
="fill"
>
trueproperty
>
name
="position"
>
0property
>
packing
>
child
>
>
class
="gtkbutton"
id="button2"
>
name
="label"
translatable
="yes"
>
buttonproperty
>
name
="visible"
>
trueproperty
>
name
="can_focus"
>
trueproperty
>
name
="receives_default"
>
trueproperty
>
object
>
>
name
="expand"
>
falseproperty
>
name
="fill"
>
trueproperty
>
name
="position"
>
1property
>
packing
>
child
>
>
/>
child
>
object
>
child
>
object
>
inte***ce
>
go gtk3開發之Grid布局控制項 15
建立grid布局控制項。table布局已經取消 func main if err nilrun os.args func createwindow 獲取window視窗 winobj,builder.getobject window1 window winobj.gtk.window addwind...
go gtk3開發之水平布局控制項 13
建立水平布局,新版不再支援gtkhbox gtkvbox布局。新版不再支援gtkhbox gtkvbox glade3 3.8 編輯器太老了,使用glade 3.14 func main if err nilrun os.args func createwindow 獲取window視窗 winob...
WPF控制項開發之自定義控制項 3
建立 usercontrol 如前所述,在 wpf 中建立控制項的最簡單方法是從 usercontrol 派生。下面的示例演示用於定義 numericupdownusercontrol 的 使用者介面 ui 的 xaml 下面的示例演示此 usercontrol 的邏輯。如此示例所示,自定義 use...