Golang gtk.GtkWidget類代碼示例- 純淨天空

文章推薦指數: 80 %
投票人數:10人

本文整理匯總了Golang中github.com/agl/go-gtk/gtk.GtkWidget類的典型用法代碼示例。

如果您正苦於以下問題:Golang GtkWidget類的具體用法?Golang GtkWidget怎麽用? 當前位置:首頁>>代碼示例>>Golang>>正文 本文整理匯總了Golang中github.com/agl/go-gtk/gtk.GtkWidget類的典型用法代碼示例。

如果您正苦於以下問題:GolangGtkWidget類的具體用法?GolangGtkWidget怎麽用?GolangGtkWidget使用的例子?那麽恭喜您,這裏精選的類代碼示例或許可以為您提供幫助。

在下文中一共展示了GtkWidget類的4個代碼示例,這些例子默認根據受歡迎程度排序。

您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Golang代碼示例。

示例1:configureWidget ​點讚9 ​ funcconfigureWidget(w*gtk.GtkWidget,bwidgetBase){ width:=-1 ifb.width!=0{ width=b.width } height:=-1 ifb.height!=0{ height=b.height } ifwidth!=-1||height!=-1{ w.SetSizeRequest(width,height) } w.SetSensitive(!b.insensitive) ifcolor:=b.Foreground();color!=0{ w.ModifyFG(gtk.GTK_STATE_NORMAL,toColor(color)) } ifcolor:=b.Background();color!=0{ w.ModifyBG(gtk.GTK_STATE_NORMAL,toColor(color)) } iflen(b.font)!=0{ w.ModifyFontEasy(b.font) } }開發者ID:shpedoikal,項目名稱:pond,代碼行數:27,代碼來源:gtk.go 示例2:handle ​點讚7 ​ func(ui*GTKUI)handle(actioninterface{}){ switchaction:=action.(type){ caseReset: ui.widgets=make(map[string]gtk.WidgetLike) ui.entries=make(map[string]*gtk.GtkEntry) ui.textViews=make(map[string]*gtk.GtkTextView) ui.combos=make(map[string]*gtk.GtkComboBoxText) ui.radioGroups=make(map[string]int) ui.checks=make(map[string]*gtk.GtkCheckButton) ui.radioGroups=make(map[string]int) ui.calendars=make(map[string]*gtk.GtkCalendar) ui.spinButtons=make(map[string]*gtk.GtkSpinButton) ifui.topWidget!=nil{ ui.window.Remove(ui.topWidget) ui.topWidget=nil } ui.topWidget=ui.newWidget(action.root) ui.window.Add(ui.topWidget) ui.window.ShowAll() caseAppend: box:=ui.getWidget(action.name).(gtk.BoxLike) for_,child:=rangeaction.children{ widget:=ui.newWidget(child) box.PackStart(widget,child.Expand(),child.Fill(),child.Padding()) } ui.window.ShowAll() caseAddToBox: box:=ui.getWidget(action.box).(gtk.BoxLike) widget:=ui.newWidget(action.child) box.PackStart(widget,action.child.Expand(),action.child.Fill(),action.child.Padding()) box.ReorderChild(widget,action.pos) ui.window.ShowAll() caseSetChild: bin:=gtk.GtkBin{gtk.GtkContainer{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}} for_,child:=rangebin.GetChildren(){ child.Destroy() } bin.Add(ui.newWidget(action.child)) ui.window.ShowAll() caseSetBoxContents: box:=gtk.GtkBox{gtk.GtkContainer{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}} for_,child:=rangebox.GetChildren(){ child.Destroy() } child:=action.child widget:=ui.newWidget(child) box.PackStart(widget,child.Expand(),child.Fill(),child.Padding()) ui.window.ShowAll() caseSetBackground: widget:=gtk.GtkWidget{ui.getWidget(action.name).ToNative()} widget.OverrideBackgroundColor(gtk.GTK_STATE_FLAG_NORMAL,toColor(action.color)) caseSensitive: widget:=gtk.GtkWidget{ui.getWidget(action.name).ToNative()} widget.SetSensitive(action.sensitive) caseStartSpinner: widget:=gtk.GtkSpinner{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}} widget.Start() caseStopSpinner: widget:=gtk.GtkSpinner{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}} widget.Stop() caseSetText: widget:=gtk.GtkLabel{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}} widget.SetText(action.text) caseSetButtonText: widget:=gtk.GtkButton{gtk.GtkBin{gtk.GtkContainer{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}}} widget.SetLabel(action.text) caseSetEntry: widget:=ui.getWidget(action.name).(gtk.TextInputLike) widget.SetText(action.text) caseSetTextView: widget:=gtk.GtkTextView{gtk.GtkContainer{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}} buffer:=gtk.TextBuffer(gtk.TextTagTable()) buffer.SetText(action.text) widget.SetBuffer(buffer) caseScrollTextViewToEnd: widget:=gtk.GtkTextView{gtk.GtkContainer{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}} mark:=widget.GetBuffer().GetMark("insert") widget.ScrollToMark(mark,0.0,true,0,1) caseSetImage: widget:=gtk.GtkImage{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}} widget.SetFromPixbuf(action.image.Image()) caseSetFocus: widget:=gtk.GtkWidget{ui.getWidget(action.name).ToNative()} widget.GrabFocus() caseDestroy: widget:=gtk.GtkWidget{ui.getWidget(action.name).ToNative()} widget.Destroy() delete(ui.widgets,action.name) caseFileOpen: fileAction:=gtk.GTK_FILE_CHOOSER_ACTION_OPEN button:=gtk.GTK_STOCK_OPEN ifaction.save{ fileAction=gtk.GTK_FILE_CHOOSER_ACTION_SAVE button=gtk.GTK_STOCK_SAVE } dialog:=gtk.FileChooserDialog(action.title,ui.window,fileAction,gtk.GTK_STOCK_CANCEL,int(gtk.GTK_RESPONSE_CANCEL),button,int(gtk.GTK_RESPONSE_ACCEPT)) ifaction.save{ iflen(action.filename)>0{ dialog.SetCurrentName(action.filename) //.........這裏部分代碼省略......... 開發者ID:jwilkins,項目名稱:pond,代碼行數:101,代碼來源:gtk.go 示例3:configureWidget ​點讚5 ​ funcconfigureWidget(w*gtk.GtkWidget,bwidgetBase){ width:=-1 ifb.width!=0{ width=b.width } height:=-1 ifb.height!=0{ height=b.height } ifwidth!=-1||height!=-1{ w.SetSizeRequest(width,height) } w.SetSensitive(!b.insensitive) ifcolor:=b.Foreground();color!=0{ w.OverrideColor(gtk.GTK_STATE_FLAG_NORMAL,toColor(color)) } ifcolor:=b.Background();color!=0{ w.OverrideBackgroundColor(gtk.GTK_STATE_FLAG_NORMAL,toColor(color)) } iflen(b.font)!=0{ w.OverrideFont(b.font) } ifb.hExpand{ w.SetHExpand(true) } ifb.vExpand{ w.SetVExpand(true) } ifb.margin>0{ w.SetMargin(b.margin) } ifb.marginTop>0{ w.SetMarginTop(b.marginTop) } ifb.marginBottom>0{ w.SetMarginBottom(b.marginBottom) } ifb.marginLeft>0{ w.SetMarginLeft(b.marginLeft) } ifb.vAlign!=AlignNone{ w.SetVAlign(alignToGTK(b.vAlign)) } ifb.hAlign!=AlignNone{ w.SetHAlign(alignToGTK(b.hAlign)) } }開發者ID:jwilkins,項目名稱:pond,代碼行數:51,代碼來源:gtk.go 示例4:handle ​點讚2 ​ func(ui*GTKUI)handle(actioninterface{}){ switchaction:=action.(type){ caseReset: ui.widgets=make(map[string]gtk.WidgetLike) ui.entries=make(map[string]*gtk.GtkEntry) ui.textViews=make(map[string]*gtk.GtkTextView) ui.combos=make(map[string]*gtk.GtkComboBox) ifui.topWidget!=nil{ ui.window.Remove(ui.topWidget) ui.topWidget=nil } ui.topWidget=ui.newWidget(action.root) ui.window.Add(ui.topWidget) ui.window.ShowAll() caseAppend: box:=ui.getWidget(action.name).(gtk.BoxLike) for_,child:=rangeaction.children{ widget:=ui.newWidget(child) box.PackStart(widget,child.Expand(),child.Fill(),child.Padding()) } ui.window.ShowAll() caseAddToBox: box:=ui.getWidget(action.box).(gtk.BoxLike) widget:=ui.newWidget(action.child) box.PackStart(widget,action.child.Expand(),action.child.Fill(),action.child.Padding()) box.ReorderChild(widget,action.pos) ui.window.ShowAll() caseSetChild: bin:=gtk.GtkBin{gtk.GtkContainer{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}} for_,child:=rangebin.GetChildren(){ child.Destroy() } bin.Add(ui.newWidget(action.child)) ui.window.ShowAll() caseSetBoxContents: box:=gtk.GtkBox{gtk.GtkContainer{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}} for_,child:=rangebox.GetChildren(){ child.Destroy() } child:=action.child widget:=ui.newWidget(child) box.PackStart(widget,child.Expand(),child.Fill(),child.Padding()) ui.window.ShowAll() caseSetBackground: widget:=gtk.GtkWidget{ui.getWidget(action.name).ToNative()} widget.ModifyBG(gtk.GTK_STATE_NORMAL,toColor(action.color)) caseSensitive: widget:=gtk.GtkWidget{ui.getWidget(action.name).ToNative()} widget.SetSensitive(action.sensitive) caseStartSpinner: widget:=gtk.GtkSpinner{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}} widget.Start() caseStopSpinner: widget:=gtk.GtkSpinner{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}} widget.Stop() caseSetText: widget:=gtk.GtkLabel{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}} widget.SetText(action.text) caseSetTextView: widget:=gtk.GtkTextView{gtk.GtkContainer{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}} buffer:=gtk.TextBuffer(gtk.TextTagTable()) buffer.SetText(action.text) widget.SetBuffer(buffer) caseSetImage: widget:=gtk.GtkImage{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}} widget.SetFromPixbuf(action.image.Image()) caseSetFocus: widget:=gtk.GtkWidget{ui.getWidget(action.name).ToNative()} widget.GrabFocus() caseDestroy: widget:=gtk.GtkWidget{ui.getWidget(action.name).ToNative()} widget.Destroy() caseFileOpen: fileAction:=gtk.GTK_FILE_CHOOSER_ACTION_OPEN but:=gtk.GTK_STOCK_OPEN ifaction.save{ fileAction=gtk.GTK_FILE_CHOOSER_ACTION_SAVE but=gtk.GTK_STOCK_SAVE } dialog:=gtk.FileChooserDialog(action.title,ui.window,fileAction,gtk.GTK_STOCK_CANCEL,int(gtk.GTK_RESPONSE_CANCEL),but,int(gtk.GTK_RESPONSE_ACCEPT)) switchgtk.GtkResponseType(dialog.Run()){ casegtk.GTK_RESPONSE_ACCEPT: ui.events



請為這篇文章評分?