建立水平布局,新版不再支援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//獲取hbox控制項
hboxobj, err := builder.
getobject
("box2"
)if err !=
nil fmt.
println
("hboxobj"
, reflect.
typeof
(hboxobj)
) hbox := hboxobj.
(*gtk.box)
3)button,
_:= gtk.
buttonnewwithlabel
("新按鈕"
)//新建按鈕
hbox.
add(button)
//按鈕新增到布局中
// 顯示所有介面
window.
showall()
}
<?xml version="1.0" encoding="utf-8"?>
>
class
="gtkwindow"
id="window1"
>
name
="can_focus"
>
falseproperty
>
>
class
="gtkbox"
id="box2"
>
name
="visible"
>
trueproperty
>
name
="can_focus"
>
falseproperty
>
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開發之垂直布局控制項 14
建立垂直布局,新版不再支援gtkhbox gtkvbox。新版不再支援gtkhbox gtkvbox glade3 3.8 編輯器太老了,使用glade 3.14 func main if err nilrun os.args func createwindow 獲取window視窗 winobj,...
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...
android開發之路3
intent intent new intent intent.action call,uri.parse tel textstr startactivity intent android minline 控制textview的顯示行數 1.狀態列通知 2.對話方塊通知 3.吐絲 toast sms...