本文整理汇总了Golang中github.com/mattn/go-gtk/gtk.NewWindow函数的典型用法代码示例。如果您正苦于以下问题:Golang NewWindow函数的具体用法?Golang NewWindow怎么用?Golang NewWindow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewWindow函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: initPage
func initPage(title string, uri string, size_x int, size_y int) {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle(title)
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(false, 1)
swin := gtk.NewScrolledWindow(nil, nil)
swin.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
swin.SetShadowType(gtk.SHADOW_IN)
webview := webkit.NewWebView()
webview.LoadUri(uri)
swin.Add(webview)
vbox.Add(swin)
window.Add(vbox)
window.SetSizeRequest(size_x, size_y)
window.ShowAll()
proxy := os.Getenv("HTTP_PROXY")
if len(proxy) > 0 {
soup_uri := webkit.SoupUri(proxy)
webkit.GetDefaultSession().Set("proxy-uri", soup_uri)
soup_uri.Free()
}
gtk.Main()
}
开发者ID:nnoco,项目名称:GoLiathChat,代码行数:30,代码来源:Goliath.go
示例2: 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()
}
开发者ID:mattn,项目名称:go-gtk,代码行数:29,代码来源:arrow.go
示例3: 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())
}
开发者ID:kch42,项目名称:biomed,代码行数:34,代码来源:main.go
示例4: main
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetTitle("Hello GTK+Go world!")
window.SetIconName("gtk-dialog-info")
window.Connect("destroy", func(ctx *glib.CallbackContext) {
gtk.MainQuit()
}, "foo")
vbox := gtk.NewVBox(false, 1)
button := gtk.NewButtonWithLabel("Hello world!")
button.SetTooltipMarkup("Say Hello World to everybody!")
button.Clicked(func() {
messagedialog := gtk.NewMessageDialog(
button.GetTopLevelAsWindow(),
gtk.DIALOG_MODAL,
gtk.MESSAGE_INFO,
gtk.BUTTONS_OK,
"Hello!")
messagedialog.Response(func() {
messagedialog.Destroy()
})
messagedialog.Run()
})
vbox.PackStart(button, false, false, 0)
window.Add(vbox)
window.SetSizeRequest(300, 50)
window.ShowAll()
gtk.Main()
}
开发者ID:olecya,项目名称:goeg,代码行数:30,代码来源:golang_hello.go
示例5: main
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("GTK Icon View")
window.Connect("destroy", gtk.MainQuit)
swin := gtk.NewScrolledWindow(nil, nil)
store := gtk.NewListStore(gdkpixbuf.GetType(), glib.G_TYPE_STRING)
iconview := gtk.NewIconViewWithModel(store)
iconview.SetPixbufColumn(0)
iconview.SetTextColumn(1)
swin.Add(iconview)
gtk.StockListIDs().ForEach(func(d unsafe.Pointer, v interface{}) {
id := glib.GPtrToString(d)
var iter gtk.TreeIter
store.Append(&iter)
store.Set(&iter,
gtk.NewImage().RenderIcon(id, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf,
id)
})
window.Add(swin)
window.SetSizeRequest(500, 200)
window.ShowAll()
gtk.Main()
}
开发者ID:pocke,项目名称:go-gtk,代码行数:29,代码来源:iconview.go
示例6: board_display
func board_display() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetTitle("Gomoku")
window.SetResizable(false)
window.Connect("destroy", gtk.MainQuit)
player = 1
game = Gomoku{make([]int, 361), true, false, false, 1, [2]int{10, 10}, 0}
vbox := gtk.NewVBox(false, 1)
menu_bar(vbox)
configure_board(vbox)
status_bar(vbox)
hintx, hinty, lastx, lasty = -1, -1, -1, -1
go calc_hint()
window.Add(vbox)
window.SetSizeRequest(WIDTH+40, HEIGHT+50)
window.ShowAll()
gtk.Main()
}
开发者ID:Khady,项目名称:gomoku,代码行数:26,代码来源:display.go
示例7: main
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("Clock")
vbox := gtk.NewVBox(false, 1)
label := gtk.NewLabel("")
vbox.Add(label)
window.Add(vbox)
window.SetDefaultSize(300, 20)
window.ShowAll()
timer, _ := uv.TimerInit(nil)
timer.Start(func(h *uv.Handle, status int) {
label.SetLabel(fmt.Sprintf("%v", time.Now()))
}, 1000, 1000)
idle, _ := uv.IdleInit(nil)
idle.Start(func(h *uv.Handle, status int) {
gtk.MainIterationDo(false)
})
window.Connect("destroy", func() {
timer.Close(nil)
idle.Close(nil)
})
uv.DefaultLoop().Run()
}
开发者ID:zchee,项目名称:gouv,代码行数:28,代码来源:gui.go
示例8: 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
}
开发者ID:uvgroovy,项目名称:dmx,代码行数:30,代码来源:dmxd.go
示例9: 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()
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:34,代码来源:notebook.go
示例10: main
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("GTK Stock Icons")
window.Connect("destroy", gtk.MainQuit)
swin := gtk.NewScrolledWindow(nil, nil)
store := gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_BOOL, gdkpixbuf.GetGdkPixbufType())
treeview := gtk.NewTreeView()
swin.Add(treeview)
treeview.SetModel(store)
treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("name", gtk.NewCellRendererText(), "text", 0))
treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("check", gtk.NewCellRendererToggle(), "active", 1))
treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("icon", gtk.NewCellRendererPixbuf(), "pixbuf", 2))
n := 0
gtk.StockListIDs().ForEach(func(d interface{}, v interface{}) {
id := glib.GPtrToString(d)
var iter gtk.TreeIter
store.Append(&iter)
store.Set(&iter, id, (n == 1), gtk.NewImage().RenderIcon(id, gtk.ICON_SIZE_SMALL_TOOLBAR, "").Pixbuf)
n = 1 - n
})
window.Add(swin)
window.SetSizeRequest(400, 200)
window.ShowAll()
gtk.Main()
}
开发者ID:arip33,项目名称:go-gtk,代码行数:31,代码来源:listview.go
示例11: main
func main() {
mc := memcache.New("127.0.0.1:11211")
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("memcachedclient")
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(false, 1)
swin := gtk.NewScrolledWindow(nil, nil)
textview := gtk.NewTextView()
textview.SetEditable(false)
textview.SetCursorVisible(false)
textview.ModifyFontEasy("monospace 12")
swin.Add(textview)
vbox.Add(swin)
buffer := textview.GetBuffer()
input := gtk.NewEntry()
input.SetEditable(true)
vbox.PackEnd(input, false, false, 0)
tag := buffer.CreateTag("red", map[string]string{"foreground": "#FF0000"})
input.Connect("activate", func() {
var iter gtk.TextIter
tokens := strings.SplitN(input.GetText(), " ", 3)
if len(tokens) == 2 && strings.ToUpper(tokens[0]) == "GET" {
if t, err := mc.Get(tokens[1]); err == nil {
buffer.GetEndIter(&iter)
buffer.Insert(&iter, string(t.Value)+"\n")
} else {
buffer.InsertWithTag(&iter, err.Error()+"\n", tag)
}
input.SetText("")
} else if len(tokens) == 3 && strings.ToUpper(tokens[0]) == "SET" {
if err := mc.Set(
&memcache.Item{
Key: tokens[1],
Value: []byte(tokens[2]),
}); err == nil {
buffer.GetEndIter(&iter)
buffer.InsertWithTag(&iter, "OK\n", tag)
} else {
buffer.InsertWithTag(&iter, err.Error()+"\n", tag)
}
input.SetText("")
}
})
input.GrabFocus()
window.Add(vbox)
window.SetSizeRequest(300, 500)
window.ShowAll()
gtk.Main()
}
开发者ID:mattn,项目名称:memcachedclient,代码行数:58,代码来源:memcachedclient.go
示例12: 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()
}
开发者ID:kisom,项目名称:socialgopher,代码行数:58,代码来源:app.go
示例13: main
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("webkit")
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(false, 1)
entry := gtk.NewEntry()
entry.SetText("http://golang.org/")
vbox.PackStart(entry, false, false, 0)
swin := gtk.NewScrolledWindow(nil, nil)
swin.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
swin.SetShadowType(gtk.SHADOW_IN)
webview := webkit.NewWebView()
webview.Connect("load-committed", func() {
entry.SetText(webview.GetUri())
})
swin.Add(webview)
vbox.Add(swin)
entry.Connect("activate", func() {
webview.LoadUri(entry.GetText())
})
button := gtk.NewButtonWithLabel("load String")
button.Clicked(func() {
webview.LoadString("hello Go GTK!", "text/plain", "utf-8", ".")
})
vbox.PackStart(button, false, false, 0)
button = gtk.NewButtonWithLabel("load HTML String")
button.Clicked(func() {
webview.LoadHtmlString(HTML_STRING, ".")
})
vbox.PackStart(button, false, false, 0)
button = gtk.NewButtonWithLabel("Google Maps")
button.Clicked(func() {
webview.LoadHtmlString(MAP_EMBED, ".")
})
vbox.PackStart(button, false, false, 0)
window.Add(vbox)
window.SetSizeRequest(600, 600)
window.ShowAll()
proxy := os.Getenv("HTTP_PROXY")
if len(proxy) > 0 {
soup_uri := webkit.SoupUri(proxy)
webkit.GetDefaultSession().Set("proxy-uri", soup_uri)
soup_uri.Free()
}
entry.Emit("activate")
gtk.Main()
}
开发者ID:bright-sparks,项目名称:go-webkit,代码行数:58,代码来源:webview.go
示例14: CreateWindow
func CreateWindow() *gtk.Window {
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetDefaultSize(700, 300)
vbox := gtk.NewVBox(false, 1)
CreateMenuAndToolbar(window, vbox)
CreateActivatableDemo(vbox)
window.Add(vbox)
return window
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:9,代码来源:action.go
示例15: main
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetTitle("Hello world!")
window.SetIconName("Hello go!")
window.Connect("destroy", gtk.MainQuit)
window.SetSizeRequest(800, 800)
window.ShowAll()
gtk.Main()
}
开发者ID:davidamin,项目名称:VanGo,代码行数:11,代码来源:window.go
示例16: main
func main() {
FreeConsole()
gtk.Init(nil)
screenHeight := gdk.ScreenHeight()
screenWidth := gdk.ScreenWidth()
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("mgc")
window.SetIconName("gtk-about")
window.Connect("destroy", func() {
gtk.MainQuit()
})
vbox := gtk.NewVBox(false, 0)
menubar := gtk.NewMenuBar()
vbox.PackStart(menubar, false, false, 0)
menu := gtk.NewMenuItemWithMnemonic("_File")
menubar.Append(menu)
submenu := gtk.NewMenu()
menu.SetSubmenu(submenu)
menuitem := gtk.NewMenuItemWithMnemonic("E_xit")
menuitem.Connect("activate", func() {
gtk.MainQuit()
})
submenu.Append(menuitem)
hpaned := gtk.NewHPaned()
leftFrame := gtk.NewFrame("")
rightFrame := gtk.NewFrame("")
leftLabel := gtk.NewLabel("Left")
rightLabel := gtk.NewLabel("Right")
leftFrame.Add(leftLabel)
rightFrame.Add(rightLabel)
hpaned.Pack1(leftFrame, true, false)
hpaned.Pack2(rightFrame, true, false)
vbox.Add(hpaned)
window.Add(vbox)
window.SetSizeRequest(screenWidth/4*3, screenHeight/4*3)
window.ShowAll()
gtk.Main()
}
开发者ID:vsannikov,项目名称:mgc,代码行数:54,代码来源:main.go
示例17: main
func main() {
gtk.Init(nil)
win := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
win.SetTitle("Goodbye, World!")
win.SetSizeRequest(300, 200)
win.Connect("destroy", gtk.MainQuit)
button := gtk.NewButtonWithLabel("Goodbye, World!")
win.Add(button)
button.Connect("clicked", gtk.MainQuit)
win.ShowAll()
gtk.Main()
}
开发者ID:jefferyyuan,项目名称:RosettaCodeData,代码行数:12,代码来源:hello-world-graphical.go
示例18: main
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("SourceView")
window.Connect("destroy", gtk.MainQuit)
swin := gtk.NewScrolledWindow(nil, nil)
swin.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
swin.SetShadowType(gtk.SHADOW_IN)
sourcebuffer := gsv.NewSourceBufferWithLanguage(gsv.SourceLanguageManagerGetDefault().GetLanguage("cpp"))
sourceview := gsv.NewSourceViewWithBuffer(sourcebuffer)
var start gtk.TextIter
sourcebuffer.GetStartIter(&start)
sourcebuffer.BeginNotUndoableAction()
sourcebuffer.Insert(&start, `#include <iostream>
template<class T>
struct foo_base {
T operator+(T const &rhs) const {
T tmp(static_cast<T const &>(*this));
tmp += rhs;
return tmp;
}
};
class foo : public foo_base<foo> {
private:
int v;
public:
foo(int v) : v(v) {}
foo &operator+=(foo const &rhs){
this->v += rhs.v;
return *this;
}
operator int() { return v; }
};
int main(void) {
foo a(1), b(2);
a += b;
std::cout << (int)a << std::endl;
}
`)
sourcebuffer.EndNotUndoableAction()
swin.Add(sourceview)
window.Add(swin)
window.SetSizeRequest(400, 300)
window.ShowAll()
gtk.Main()
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:53,代码来源:sourceview.go
示例19: main
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("GTK DrawingArea")
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(true, 0)
vbox.SetBorderWidth(5)
targets := []gtk.TargetEntry{
{"text/uri-list", 0, 0},
{"STRING", 0, 1},
{"text/plain", 0, 2},
}
dest := gtk.NewLabel("drop me file")
dest.DragDestSet(
gtk.DEST_DEFAULT_MOTION|
gtk.DEST_DEFAULT_HIGHLIGHT|
gtk.DEST_DEFAULT_DROP,
targets,
gdk.ACTION_COPY)
dest.DragDestAddUriTargets()
dest.Connect("drag-data-received", func(ctx *glib.CallbackContext) {
sdata := gtk.SelectionDataFromNative(unsafe.Pointer(ctx.Args(3)))
if sdata != nil {
a := (*[2000]uint8)(sdata.GetData())
files := strings.Split(string(a[0:sdata.GetLength()-1]), "\n")
for i := range files {
filename, _, _ := glib.FilenameFromUri(files[i])
files[i] = filename
}
dialog := gtk.NewMessageDialog(
window,
gtk.DIALOG_MODAL,
gtk.MESSAGE_INFO,
gtk.BUTTONS_OK,
strings.Join(files, "\n"))
dialog.SetTitle("D&D")
dialog.Response(func() {
dialog.Destroy()
})
dialog.Run()
}
})
vbox.Add(dest)
window.Add(vbox)
window.SetSizeRequest(300, 100)
window.ShowAll()
gtk.Main()
}
开发者ID:JessonChan,项目名称:go-gtk,代码行数:52,代码来源:dnd.go
示例20: main
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("GTK Folder View")
window.Connect("destroy", gtk.MainQuit)
swin := gtk.NewScrolledWindow(nil, nil)
store := gtk.NewTreeStore(gdkpixbuf.GetGdkPixbufType(), glib.G_TYPE_STRING)
treeview := gtk.NewTreeView()
swin.Add(treeview)
treeview.SetModel(store.ToTreeModel())
treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("pixbuf", gtk.NewCellRendererPixbuf(), "pixbuf", 0))
treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("text", gtk.NewCellRendererText(), "text", 1))
for n := 1; n <= 10; n++ {
var iter1, iter2, iter3 gtk.TreeIter
store.Append(&iter1, nil)
store.Set(&iter1, gtk.NewImage().RenderIcon(gtk.STOCK_DIRECTORY, gtk.ICON_SIZE_SMALL_TOOLBAR, "").Pixbuf, "Folder"+strconv.Itoa(n))
store.Append(&iter2, &iter1)
store.Set(&iter2, gtk.NewImage().RenderIcon(gtk.STOCK_DIRECTORY, gtk.ICON_SIZE_SMALL_TOOLBAR, "").Pixbuf, "SubFolder"+strconv.Itoa(n))
store.Append(&iter3, &iter2)
store.Set(&iter3, gtk.NewImage().RenderIcon(gtk.STOCK_FILE, gtk.ICON_SIZE_SMALL_TOOLBAR, "").Pixbuf, "File"+strconv.Itoa(n))
}
treeview.Connect("row_activated", func() {
var path *gtk.TreePath
var column *gtk.TreeViewColumn
treeview.GetCursor(&path, &column)
mes := "TreePath is: " + path.String()
dialog := gtk.NewMessageDialog(
treeview.GetTopLevelAsWindow(),
gtk.DIALOG_MODAL,
gtk.MESSAGE_INFO,
gtk.BUTTONS_OK,
mes)
dialog.SetTitle("TreePath")
dialog.Response(func() {
dialog.Destroy()
})
dialog.Run()
})
window.Add(swin)
window.SetSizeRequest(400, 200)
window.ShowAll()
gtk.Main()
}
开发者ID:arip33,项目名称:go-gtk,代码行数:50,代码来源:treeview.go
注:本文中的github.com/mattn/go-gtk/gtk.NewWindow函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论