本文整理汇总了Golang中github.com/agl/go-gtk/gtk.GtkWidget.SetFraction方法的典型用法代码示例。如果您正苦于以下问题:Golang GtkWidget.SetFraction方法的具体用法?Golang GtkWidget.SetFraction怎么用?Golang GtkWidget.SetFraction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/agl/go-gtk/gtk.GtkWidget
的用法示例。
在下文中一共展示了GtkWidget.SetFraction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: handle
//.........这里部分代码省略.........
widget := ui.newWidget(child)
box.PackStart(widget, child.Expand(), child.Fill(), child.Padding())
ui.window.ShowAll()
case SetBackground:
widget := gtk.GtkWidget{ui.getWidget(action.name).ToNative()}
widget.OverrideBackgroundColor(gtk.GTK_STATE_FLAG_NORMAL, toColor(action.color))
case Sensitive:
widget := gtk.GtkWidget{ui.getWidget(action.name).ToNative()}
widget.SetSensitive(action.sensitive)
case StartSpinner:
widget := gtk.GtkSpinner{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}
widget.Start()
case StopSpinner:
widget := gtk.GtkSpinner{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}
widget.Stop()
case SetText:
widget := gtk.GtkLabel{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}
widget.SetText(action.text)
case SetButtonText:
widget := gtk.GtkButton{gtk.GtkBin{gtk.GtkContainer{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}}}
widget.SetLabel(action.text)
case SetEntry:
widget := ui.getWidget(action.name).(gtk.TextInputLike)
widget.SetText(action.text)
case SetTextView:
widget := gtk.GtkTextView{gtk.GtkContainer{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}}
buffer := gtk.TextBuffer(gtk.TextTagTable())
buffer.SetText(action.text)
widget.SetBuffer(buffer)
case ScrollTextViewToEnd:
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)
case SetImage:
widget := gtk.GtkImage{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}
widget.SetFromPixbuf(action.image.Image())
case SetFocus:
widget := gtk.GtkWidget{ui.getWidget(action.name).ToNative()}
widget.GrabFocus()
case Destroy:
widget := gtk.GtkWidget{ui.getWidget(action.name).ToNative()}
widget.Destroy()
delete(ui.widgets, action.name)
case FileOpen:
fileAction := gtk.GTK_FILE_CHOOSER_ACTION_OPEN
button := gtk.GTK_STOCK_OPEN
if action.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))
if action.save {
if len(action.filename) > 0 {
dialog.SetCurrentName(action.filename)
} else {
panic("save dialog without filename")
}
}
switch gtk.GtkResponseType(dialog.Run()) {
case gtk.GTK_RESPONSE_ACCEPT:
ui.events <- OpenResult{
ok: true,
path: dialog.GetFilename(),
arg: action.arg,
}
default:
ui.events <- OpenResult{arg: action.arg}
}
dialog.Destroy()
case SetForeground:
widget := gtk.GtkWidget{ui.getWidget(action.name).ToNative()}
widget.OverrideColor(gtk.GTK_STATE_FLAG_NORMAL, toColor(action.foreground))
case SetProgress:
widget := gtk.GtkProgressBar{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}
widget.SetFraction(action.fraction)
widget.SetText(action.s)
case SetTitle:
ui.window.SetTitle(action.title)
case InsertRow:
grid := gtk.GtkGrid{gtk.GtkContainer{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}}
x := 0
for _, elem := range action.row {
if elem.widget != nil {
grid.Attach(ui.newWidget(elem.widget), x, action.pos, elem.width, elem.height)
}
x += elem.width
}
ui.window.ShowAll()
case GridSet:
grid := gtk.GtkGrid{gtk.GtkContainer{gtk.GtkWidget{ui.getWidget(action.name).ToNative()}}}
grid.Attach(ui.newWidget(action.widget), action.col, action.row, 1, 1)
ui.window.ShowAll()
case UIError:
case UIState:
// for testing.
default:
panic("unknown action")
}
}