本文整理匯總了Golang中github.com/mattn/go-gtk/gtk.NewHBox函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewHBox函數的具體用法?Golang NewHBox怎麽用?Golang NewHBox使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewHBox函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: accountWindow
func accountWindow() {
// window settings
window_account := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window_account.SetPosition(gtk.WIN_POS_CENTER)
window_account.SetTitle("Add Account")
// main container
container_main := gtk.NewVBox(false, 10)
container_user := gtk.NewHBox(false, 0)
container_pass := gtk.NewHBox(false, 0)
container_buttons := gtk.NewHBox(false, 5)
container_main.SetBorderWidth(10)
// username
user_label := gtk.NewLabel("Username")
user_entry := gtk.NewEntry()
// password
pass_label := gtk.NewLabel("Password")
pass_entry := gtk.NewEntry()
pass_entry.SetVisibility(false)
// login and cancel buttons
button_login := gtk.NewButtonWithLabel("Add")
button_cancel := gtk.NewButtonWithLabel("Cancel")
// login
button_login.Clicked(func() {
username := user_entry.GetText()
password := pass_entry.GetText()
profile, err := CreateProfile(username, password)
if err == nil && profile != nil {
println("[*] Login successful")
window_account.Destroy()
}
})
// cancel
button_cancel.Clicked(func() {
window_account.Destroy()
})
// add elements to containers
container_buttons.Add(button_login)
container_buttons.Add(button_cancel)
container_user.PackStart(user_label, false, false, 20)
container_user.PackEnd(user_entry, true, true, 1)
container_pass.PackStart(pass_label, false, false, 20)
container_pass.PackEnd(pass_entry, true, true, 1)
container_main.PackStart(container_user, false, false, 1)
container_main.PackStart(container_pass, false, false, 1)
container_main.PackStart(container_buttons, false, false, 1)
window_account.Add(container_main)
window_account.SetSizeRequest(350, 150)
window_account.SetResizable(false)
window_account.ShowAll()
}
示例2: init_Calc
// Frame - Calculation
// This frame contains radix(16,10,8) and result labels
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
func (this *UI) init_Calc() {
// In this function, the designated frame is Calc_Frame
_Frame := this.Calc_Frame
if _Frame == nil {
panic("UI::init_Calc() : nil Frame received")
}
// (inner) Box of Calculation
fm_calc_box := gtk.NewHBox(false, 1)
if fm_calc_box == nil {
panic("UI::init_Calc() : HBox allocation Failed")
}
_Frame.Add(fm_calc_box)
// Box for Radix Buttons.
box_rdx := gtk.NewVBox(false, 1)
if box_rdx == nil {
panic("UI::init_Calc() : VBox allocation Failed")
}
btn_hex := button("Hex") // [Hex] : Hexadecimal
btn_dec := button("Dec") // [Dec] : Decimal
btn_oct := button("Oct") // [Oct] : Octal
box_rdx.Add(btn_hex)
box_rdx.Add(btn_dec)
box_rdx.Add(btn_oct)
// Insert radix buttons into the map
this.Btn_map["Hex"] = btn_hex
this.Btn_map["Dec"] = btn_dec
this.Btn_map["Oct"] = btn_oct
// Box for Result Labels
box_labels := gtk.NewVBox(false, 1)
if box_labels == nil {
panic("UI::init_Calc() : VBox allocation Failed")
}
// Place previous result
box_labels.Add(this.Lbl_prev)
// Place left and right operand
box_LnR := gtk.NewHBox(false, 3)
if box_LnR == nil {
panic("UI::init_Calc() : HBox allocation Failed")
}
box_LnR.Add(this.Lbl_lhs)
box_LnR.Add(this.Lbl_rhs)
box_labels.Add(box_LnR)
// Add both Boxes (Radix & Result) to frame box
fm_calc_box.Add(box_rdx)
fm_calc_box.Add(box_labels)
fmt.Println("UI::init_Calc() done.")
}
示例3: mkSidebar
func (g *GUI) mkSidebar() *gtk.ScrolledWindow {
sbVBox := gtk.NewVBox(false, 0)
sbVBox.PackStart(labelCustomFont("Tools", "Sans Bold 14"), false, false, 3)
g.showbiomes = gtk.NewCheckButtonWithLabel("Show Biomes")
g.showbiomes.SetActive(true)
g.showbiomes.Connect("toggled", g.showbiomesToggled)
sbVBox.PackStart(g.showbiomes, false, false, 3)
g.fixSnowIce = gtk.NewCheckButtonWithLabel("Fix Snow/Ice")
g.fixSnowIce.SetTooltipText("Add Snow/Ice for Taiga/Ice Plains. Remove Snow/Ice for other biomes.")
g.fixSnowIce.Connect("toggled", g.fixSnowIceToggled)
sbVBox.PackStart(g.fixSnowIce, false, false, 3)
fill := gtk.NewRadioButtonWithLabel(nil, "Fill")
fill.SetActive(true)
fill.Connect("toggled", g.mkUpdateToolFx(fill, NewFillTool()))
draw := gtk.NewRadioButtonWithLabel(fill.GetGroup(), "Draw")
drawRadius := gtk.NewSpinButtonWithRange(1, 20, 1)
drawHBox := gtk.NewHBox(false, 0)
drawHBox.PackStart(draw, true, true, 0)
drawHBox.PackStart(gtk.NewLabel("Radius:"), false, false, 3)
drawHBox.PackEnd(drawRadius, false, false, 3)
draw.Connect("toggled", g.mkUpdateToolFx(draw, NewDrawTool(func() int { return drawRadius.GetValueAsInt() })))
sbVBox.PackStart(fill, false, false, 3)
sbVBox.PackStart(drawHBox, false, false, 3)
sbVBox.PackStart(gtk.NewHSeparator(), false, false, 3)
bioHeaderHBox := gtk.NewHBox(false, 0)
bioHeaderHBox.PackStart(labelCustomFont("Biomes", "Sans Bold 14"), true, false, 0)
editBiomesBtn := gtk.NewButton()
editBiomesBtn.Add(gtk.NewImageFromStock(gtk.STOCK_EDIT, gtk.ICON_SIZE_SMALL_TOOLBAR))
editBiomesBtn.Connect("clicked", g.biomeEditor)
editBiomesBtn.SetTooltipText("Configure Biomes")
bioHeaderHBox.PackStart(editBiomesBtn, false, false, 0)
sbVBox.PackStart(bioHeaderHBox, false, false, 3)
g.bioVBoxWrap = gtk.NewVBox(false, 0)
g.bioVBox = gtk.NewVBox(false, 0)
g.bioVBoxWrap.PackStart(g.bioVBox, false, false, 0)
sbVBox.PackStart(g.bioVBoxWrap, false, false, 3)
g.updateBiomeInfo()
scrolled := gtk.NewScrolledWindow(nil, nil)
scrolled.SetPolicy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
scrolled.AddWithViewPort(sbVBox)
return scrolled
}
示例4: main
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("GTK Notebook")
window.Connect("destroy", gtk.MainQuit)
notebook := gtk.NewNotebook()
for n := 1; n <= 10; n++ {
page := gtk.NewFrame("demo" + strconv.Itoa(n))
notebook.AppendPage(page, gtk.NewLabel("demo"+strconv.Itoa(n)))
vbox := gtk.NewHBox(false, 1)
prev := gtk.NewButtonWithLabel("go prev")
prev.Clicked(func() {
notebook.PrevPage()
})
vbox.Add(prev)
next := gtk.NewButtonWithLabel("go next")
next.Clicked(func() {
notebook.NextPage()
})
vbox.Add(next)
page.Add(vbox)
}
window.Add(notebook)
window.SetSizeRequest(400, 200)
window.ShowAll()
gtk.Main()
}
示例5: Init
func (g *GUI) Init() {
g.biomes = ReadDefaultBiomes()
g.window = gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
g.window.SetTitle("biomed")
g.accel = gtk.NewAccelGroup()
g.window.AddAccelGroup(g.accel)
menubar := g.mkMenuBar()
vbox := gtk.NewVBox(false, 0)
vbox.PackStart(menubar, false, false, 0)
hbox := gtk.NewHBox(false, 0)
g.mapw = NewMapWidget(GUICallbacks{g.reportError, g.updateInfo, g.setBusy}, MkBiomeLookup(g.biomes))
hbox.PackStart(g.mapw.DArea(), true, true, 3)
sidebar := g.mkSidebar()
hbox.PackEnd(sidebar, false, false, 3)
vbox.PackStart(hbox, true, true, 0)
g.statusbar = gtk.NewStatusbar()
g.statusContext = g.statusbar.GetContextId("mapinfo")
vbox.PackEnd(g.statusbar, false, false, 0)
g.window.Add(vbox)
g.window.SetDefaultSize(800, 600)
g.window.Connect("destroy", g.exitApp)
g.setTool(NewFillTool())
}
示例6: CreateGuiController
func CreateGuiController() *GuiController {
guiController := &GuiController{}
guiController.buttons = make([]*gtk.Button, 0)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetTitle("GTK Go!")
window.SetIconName("gtk-dialog-info")
window.Connect("destroy", func(ctx *glib.CallbackContext) {
fmt.Println("got destroy!", ctx.Data().(string))
gtk.MainQuit()
}, "foo")
buttonsBox := gtk.NewHBox(false, 1)
black := gdk.NewColorRGB(0, 0, 0)
for i := 0; i < 8; i++ {
button := gtk.NewButtonWithLabel(fmt.Sprint(i))
button.ModifyBG(gtk.STATE_NORMAL, black)
guiController.buttons = append(guiController.buttons, button)
buttonsBox.Add(button)
}
window.Add(buttonsBox)
window.SetSizeRequest(600, 600)
window.ShowAll()
return guiController
}
示例7: main
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("Arrow Buttons")
window.Connect("destroy", gtk.MainQuit)
box := gtk.NewHBox(false, 0)
box.Show()
window.Add(box)
up := createArrowButton(gtk.ARROW_UP, gtk.SHADOW_IN)
down := createArrowButton(gtk.ARROW_DOWN, gtk.SHADOW_OUT)
left := createArrowButton(gtk.ARROW_LEFT, gtk.SHADOW_ETCHED_IN)
right := createArrowButton(gtk.ARROW_RIGHT, gtk.SHADOW_ETCHED_OUT)
box.PackStart(up, false, false, 3)
box.PackStart(down, false, false, 3)
box.PackStart(left, false, false, 3)
box.PackStart(right, false, false, 3)
up.Clicked(func() { println("↑") })
down.Clicked(func() { println("↓") })
left.Clicked(func() { println("←") })
right.Clicked(func() { println("→") })
window.Show()
gtk.Main()
}
示例8: CreateActivatableDemo
func CreateActivatableDemo(vbox *gtk.VBox) {
action_entry := gtk.NewAction("ActionEntry",
"Button attached to Action", "", gtk.STOCK_INFO)
action_entry.Connect("activate", func() {
fmt.Println("Action clicked")
})
frame1 := gtk.NewFrame("GtkActivatable interface demonstration")
frame1.SetBorderWidth(5)
hbox2 := gtk.NewHBox(false, 5)
hbox2.SetSizeRequest(400, 50)
hbox2.SetBorderWidth(5)
button1 := gtk.NewButton()
button1.SetSizeRequest(250, 0)
button1.SetRelatedAction(action_entry)
hbox2.PackStart(button1, false, false, 0)
hbox2.PackStart(gtk.NewVSeparator(), false, false, 0)
button2 := gtk.NewButtonWithLabel("Hide Action")
button2.SetSizeRequest(150, 0)
button2.Connect("clicked", func() {
action_entry.SetVisible(false)
fmt.Println("Hide Action")
})
hbox2.PackStart(button2, false, false, 0)
button3 := gtk.NewButtonWithLabel("Unhide Action")
button3.SetSizeRequest(150, 0)
button3.Connect("clicked", func() {
action_entry.SetVisible(true)
fmt.Println("Show Action")
})
hbox2.PackStart(button3, false, false, 0)
frame1.Add(hbox2)
vbox.PackStart(frame1, false, true, 0)
}
示例9: newBiomeList
func newBiomeList() *biomeList {
bl := &biomeList{
HBox: gtk.NewHBox(false, 0),
treeview: gtk.NewTreeView(),
lStore: gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING),
addBtn: gtk.NewButton(),
delBtn: gtk.NewButton(),
upBtn: gtk.NewButton(),
downBtn: gtk.NewButton(),
}
scroll := gtk.NewScrolledWindow(nil, nil)
scroll.SetPolicy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
scroll.Add(bl.treeview)
bl.PackStart(scroll, true, true, 3)
bl.treeview.SetModel(bl.lStore)
bl.treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Color", gtk.NewCellRendererText(), "background", 0))
bl.treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("ID", gtk.NewCellRendererText(), "text", 1))
bl.treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Snowline", gtk.NewCellRendererText(), "text", 2))
bl.treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Name", gtk.NewCellRendererText(), "text", 3))
bl.treeview.GetSelection().SetMode(gtk.SELECTION_SINGLE)
bl.treeview.Connect("cursor-changed", bl.onCursorChanged)
vbox := gtk.NewVBox(false, 0)
bl.addBtn.Add(gtk.NewImageFromStock(gtk.STOCK_ADD, gtk.ICON_SIZE_SMALL_TOOLBAR))
bl.delBtn.Add(gtk.NewImageFromStock(gtk.STOCK_DELETE, gtk.ICON_SIZE_SMALL_TOOLBAR))
bl.upBtn.Add(gtk.NewImageFromStock(gtk.STOCK_GO_UP, gtk.ICON_SIZE_SMALL_TOOLBAR))
bl.downBtn.Add(gtk.NewImageFromStock(gtk.STOCK_GO_DOWN, gtk.ICON_SIZE_SMALL_TOOLBAR))
bl.addBtn.Connect("clicked", bl.onAdd)
bl.delBtn.Connect("clicked", bl.onDel)
bl.upBtn.Connect("clicked", bl.onUp)
bl.downBtn.Connect("clicked", bl.onDown)
bl.delBtn.SetSensitive(false)
bl.upBtn.SetSensitive(false)
bl.downBtn.SetSensitive(false)
vbox.PackStart(bl.addBtn, false, false, 3)
vbox.PackStart(bl.delBtn, false, false, 3)
vbox.PackStart(bl.upBtn, false, false, 3)
vbox.PackStart(bl.downBtn, false, false, 3)
bl.PackStart(vbox, false, false, 0)
return bl
}
示例10: buildList
func (g *Gui) buildList(vbox *gtk.VBox) {
frame := gtk.NewFrame("Device List")
framebox := gtk.NewVBox(false, 1)
frame.Add(framebox)
vbox.Add(frame)
g.Status = gtk.NewStatusbar()
vbox.PackStart(g.Status, false, false, 0)
g.Store = gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_STRING)
treeview := gtk.NewTreeView()
framebox.Add(treeview)
treeview.SetModel(g.Store)
treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Device", gtk.NewCellRendererText(), "text", 0))
treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Name", gtk.NewCellRendererText(), "text", 1))
treeview.GetSelection().SetMode(gtk.SELECTION_SINGLE)
controls := gtk.NewHBox(true, 0)
g.Start = gtk.NewButtonWithLabel("Start Sync")
g.Start.Clicked(func() {
var iter gtk.TreeIter
var device glib.GValue
selection := treeview.GetSelection()
if selection.CountSelectedRows() > 0 {
selection.GetSelected(&iter)
g.Store.GetValue(&iter, 0, &device)
MainGui.notify("Start Writing On: " + device.GetString())
doWrite(device.GetString())
} else {
MainGui.notify("No Active Selection")
}
})
controls.Add(g.Start)
g.Recheck = gtk.NewButtonWithLabel("Rescan")
g.Recheck.Clicked(func() {
devices := SearchValid()
MainGui.Store.Clear()
for _, x := range devices {
MainGui.appendItem("/dev/hidraw"+strconv.FormatUint(x.SeqNum(), 10), x.SysAttrValue("product"))
}
MainGui.notify("Scanning Done")
})
controls.Add(g.Recheck)
framebox.PackStart(controls, false, false, 0)
}
示例11: newBiomeEditFrame
func newBiomeEditFrame() *biomeEditFrame {
frm := &biomeEditFrame{
Frame: gtk.NewFrame("Edit Biome"),
applyBtn: gtk.NewButtonWithLabel("Apply"),
idInput: gtk.NewEntry(),
snowLineInput: gtk.NewEntry(),
nameInput: gtk.NewEntry(),
colorInput: gtk.NewColorButton(),
}
frm.idInput.SetSizeRequest(40, -1)
frm.snowLineInput.SetSizeRequest(40, -1)
frm.idInput.Connect("changed", frm.unlockApply)
frm.nameInput.Connect("changed", frm.unlockApply)
frm.snowLineInput.Connect("changed", frm.unlockApply)
frm.applyBtn.SetSensitive(false)
vbox := gtk.NewVBox(false, 0)
hbox := gtk.NewHBox(false, 0)
frm.idInput.SetTooltipText("The data value of the Biome [0-255]")
frm.snowLineInput.SetTooltipText(fmt.Sprintf("Height (Y coordinate) at which snowfall starts (-1 or %d for no snowfall, 0 for always snowy)", mcmap.ChunkSizeY))
hbox.PackStart(gtk.NewLabel("Color:"), false, false, 0)
hbox.PackStart(frm.colorInput, false, false, 3)
hbox.PackStart(gtk.NewLabel("ID:"), false, false, 0)
hbox.PackStart(frm.idInput, false, false, 3)
hbox.PackStart(gtk.NewLabel("Snowline:"), false, false, 0)
hbox.PackStart(frm.snowLineInput, false, false, 3)
hbox.PackStart(gtk.NewLabel("Name:"), false, false, 0)
hbox.PackStart(frm.nameInput, true, true, 3)
vbox.PackStart(hbox, false, false, 0)
vbox.PackStart(frm.applyBtn, false, false, 3)
frm.Add(vbox)
frm.applyBtn.Connect("clicked", frm.doApply)
return frm
}
示例12: updateBiomeInfo
func (g *GUI) updateBiomeInfo() {
vbox := gtk.NewVBox(false, 0)
var grp *glib.SList
for _, biome := range g.biomes {
biohbox := gtk.NewHBox(false, 0)
cbox := colorBox(gdk.NewColor(biome.Color))
cbox.SetSizeRequest(20, 20)
biohbox.PackStart(cbox, false, false, 3)
rbutton := gtk.NewRadioButtonWithLabel(grp, biome.Name)
grp = rbutton.GetGroup()
rbutton.Connect("toggled", g.mkUpdateBiomeFx(rbutton, biome.ID))
biohbox.PackEnd(rbutton, true, true, 3)
vbox.PackStart(biohbox, false, false, 3)
}
g.bioVBoxWrap.Remove(g.bioVBox)
g.bioVBoxWrap.PackStart(vbox, false, false, 3)
vbox.ShowAll()
g.bioVBox = vbox
g.mapw.updateBioLookup(MkBiomeLookup(g.biomes))
}
示例13: NewBiomeInfoEditor
func NewBiomeInfoEditor(biomes []BiomeInfo) *BiomeInfoEditor {
ed := &BiomeInfoEditor{
Dialog: gtk.NewDialog(),
biolist: newBiomeList(),
}
ed.SetModal(true)
vbox := ed.GetVBox()
btnHBox := gtk.NewHBox(true, 0)
resetBtn := gtk.NewButtonWithLabel("Reset to defaults")
resetBtn.Connect("clicked", ed.reset)
loadBtn := gtk.NewButtonWithLabel("Load from file ...")
loadBtn.Connect("clicked", ed.load)
saveBtn := gtk.NewButtonWithLabel("Save to file ...")
saveBtn.Connect("clicked", ed.save)
btnHBox.PackStart(resetBtn, true, true, 3)
btnHBox.PackStart(loadBtn, true, true, 3)
btnHBox.PackStart(saveBtn, true, true, 3)
vbox.PackStart(btnHBox, false, false, 3)
ed.biolist.SetBiomes(biomes)
vbox.PackStart(ed.biolist, true, true, 3)
editFrame := newBiomeEditFrame()
connectBiomeListEditFrame(ed.biolist, editFrame)
vbox.PackStart(editFrame, false, false, 3)
ed.AddButton("Cancel", gtk.RESPONSE_CANCEL)
ed.AddButton("OK", gtk.RESPONSE_OK)
ed.ShowAll()
return ed
}
示例14: main
func main() {
runtime.LockOSThread()
gtk.Init(&os.Args)
gdk.ThreadsInit()
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("DMS GUI")
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(false, 0)
window.Add(vbox)
hbox := gtk.NewHBox(false, 0)
vbox.PackStart(hbox, false, true, 0)
hbox.PackStart(gtk.NewLabel("Shared directory: "), false, true, 0)
dialog := gtk.NewFileChooserDialog(
"Select directory to share", window, gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)
button := gtk.NewFileChooserButtonWithDialog(dialog)
hbox.Add(button)
logView := gtk.NewTextView()
logView.SetEditable(false)
logView.ModifyFontEasy("monospace")
logView.SetWrapMode(gtk.WRAP_WORD_CHAR)
logViewScroller := gtk.NewScrolledWindow(nil, nil)
logViewScroller.Add(logView)
logViewScroller.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
vbox.PackEnd(logViewScroller, true, true, 0)
getPath := func() string {
return button.GetFilename()
}
window.ShowAll()
if dialog.Run() != gtk.RESPONSE_ACCEPT {
return
}
go func() {
dmsServer := dms.Server{
RootObjectPath: getPath(),
}
if err := dmsServer.Serve(); err != nil {
log.Fatalln(err)
}
defer dmsServer.Close()
runtime.LockOSThread()
gdk.ThreadsEnter()
button.Connect("selection-changed", func() {
dmsServer.RootObjectPath = getPath()
})
gdk.ThreadsLeave()
runtime.UnlockOSThread()
dmsServer.Serve()
}()
gtk.Main()
runtime.UnlockOSThread()
}
示例15: win_start
func win_start() {
defer catch() // Panic Handler
// Initiate GTK
gtk.Init(&os.Args)
// Window Setup
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
// Create the Main Window
// Set title & size
win := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
win.SetTitle("0x_Calc")
// on Exit -> Quit the program
win.Connect("destroy", gtk.MainQuit)
box_win := gtk.NewVBox(Homogeneous, Default_Spacing)
// Menu Bar
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
/*
// Vertical Box for menu
box_menu := gtk.NewVBox(false, 1)
// MenuBar - menu
mb_menu := gtk.NewMenuBar()
box_menu.PackStart(mb_menu, false, false, 0)
// Menu Items
// [File]
mi_file := gtk.NewMenuItemWithMnemonic("_File2")
mb_menu.Append(mi_file)
// Submenu for [File]
subm_file := gtk.NewMenu()
mi_file.SetSubmenu(subm_file)
mi_exit := gtk.NewMenuItemWithMnemonic("_Exit2")
mb_menu.Append(mi_exit)
mi_exit.Connect("activate", func() {
gtk.MainQuit()
})
// Add the menubox
win.Add(box_menu)
*/
// Frame - Calculation
// This frame contains radix(16,10,8) and result labels
// ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====
fm_calc := gtk.NewFrame("Calculation")
// (inner) Box of Calculation
fm_calc_box := gtk.NewHBox(false, 1)
fm_calc.Add(fm_calc_box)
// Box for Radix Buttons.
box_rdx := gtk.NewVBox(false, 1)
btn_hex := button("Hex") // [Hex] : Hexadecimal
btn_dec := gtk.NewButtonWithLabel("Dec") // [Dec] : Decimal
btn_oct := gtk.NewButtonWithLabel("Oct") // [Oct] : Octal
box_rdx.Add(btn_hex)
box_rdx.Add(btn_dec)
box_rdx.Add(btn_oct)
// Box for Result Labels
box_labels := gtk.NewVBox(false, 1)
lbl_prev := gtk.NewLabel("Previous Result") // Previous Calculation
lbl_late := gtk.NewLabel("Current Result") // Latest Calculaltion
box_labels.Add(lbl_prev)
box_labels.Add(lbl_late)
// Add both Boxes (Radix & Result) to frame box
fm_calc_box.Add(box_rdx)
fm_calc_box.Add(box_labels)
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
// Frame - Numbers
// This frame contains number buttons for calculation
// Hexadecimal : 0 ~ 9, A ~ F
// Decimal : 0 ~ 9
// Octal : 0 ~ 7
// ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====
fm_nums := gtk.NewFrame("Numbers")
// (inner) Box of Numbers
fm_nums_box := gtk.NewVBox(false, 1)
fm_nums.Add(fm_nums_box)
// Table Initialization
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
tbl_nums := gtk.NewTable(5, 4, false)
// Jagged slice of buttons
// nums := [][]*gtk.Button{}
// Button for Number
num := [17]*gtk.Button{
// 0~7 : Oct
button("0"), button("1"), button("2"), button("3"),
//.........這裏部分代碼省略.........