# Gotk4 NewMessageDialog doesn't take the message\_format argument

**URL:** <https://forum.golangbridge.org/t/gotk4-newmessagedialog-doesnt-take-the-message-format-argument/41951>\
**Category:** Getting Help\
**Created:** [May 26, 2026, 8:59am UTC](https://forum.golangbridge.org/t/gotk4-newmessagedialog-doesnt-take-the-message-format-argument/41951 "2026-05-26T08:59:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![eliotttak](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/eliotttak/32/17115_2.png) [@eliotttak](https://forum.golangbridge.org/u/eliotttak)\
**Post date:** [May 26, 2026, 8:59am UTC](https://forum.golangbridge.org/t/gotk4-newmessagedialog-doesnt-take-the-message-format-argument/41951/1 "2026-05-26T08:59:12Z")

</div>

Hi, I’ve a problem with GOTK4. You can find the question on [StackOverflow](https://stackoverflow.com/questions/79946669/gotk4-newmessagedialog-doesnt-take-the-message-format-argument), and if possible, I would prefer you answer on it.

> I use `github.com/diamondburned/gotk4/pkg/gtk/v4`. I’d like to create a modal dialog, like this:
> 
> ```go
> dialog := gtk.NewMessageDialog(
> &window.Window,
> gtk.DialogModal|gtk.DialogDestroyWithParent,
> gtk.MessageInfo,
> gtk.ButtonsOK,
> "Some info I want to let the user know",
> )
> dialog.SetTitle("Information")
> dialog.SetVisible(true)
> 
> ```
> 
> Only, `NewMessageDialog()` is declared like this:
> 
> ```go
> func gtk.NewMessageDialog(parent *gtk.Window, flags gtk.DialogFlags, typ gtk.MessageType, buttons gtk.ButtonsType) *gtk.MessageDialog
> 
> ```
> 
> Unkike the C function [`gtk_message_dialog_new()`](https://docs.gtk.org/gtk4/ctor.MessageDialog.new.html), the Go one doesn’t have the `message_format` argument, nor the `...` (parameters for `message_format`) one.
> 
> My question is: How to create a information dialog in Go, with just a title, a body and one button?

---

<div class="post-metadata">

**Author:** ![Vio](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/vio/32/17601_2.png) [@Vio](https://forum.golangbridge.org/u/Vio)\
**Post date:** [May 26, 2026, 1:23pm UTC](https://forum.golangbridge.org/t/gotk4-newmessagedialog-doesnt-take-the-message-format-argument/41951/2 "2026-05-26T13:23:08Z")

</div>

```auto
package main

import (
	"os"

	"github.com/diamondburned/gotk4/pkg/gio/v2"
	"github.com/diamondburned/gotk4/pkg/gtk/v4"
)

func main() {
	var flags gio.ApplicationFlags
	app := gtk.NewApplication("com.example.dialog", flags)

	app.ConnectActivate(func() {
		window := gtk.NewApplicationWindow(app)
		window.SetTitle("MyApp")
		window.SetDefaultSize(400, 200)

		button := gtk.NewButtonWithLabel("Show messagebox")
		button.ConnectClicked(func() {
			showInfoDialog(&window.Window)
		})

		window.SetChild(button)
		window.SetVisible(true)
	})

	os.Exit(app.Run(os.Args))
}

func showInfoDialog(parent *gtk.Window) {
	var dialogFlags gtk.DialogFlags
	dialogFlags |= gtk.DialogModal
	dialogFlags |= gtk.DialogDestroyWithParent

	var msgType gtk.MessageType = gtk.MessageType(gtk.MessageInfo)
	var btnType gtk.ButtonsType = gtk.ButtonsType(gtk.ButtonsOK)

	dialog := gtk.NewMessageDialog(
		parent,
		dialogFlags,
		msgType,
		btnType,
	)
	dialog.SetTitle("Info")
	dialog.SetMarkup("Your message...")

	area := dialog.MessageArea()
	if box, ok := area.(*gtk.Box); ok {
		lbl := gtk.NewLabel("Click OK to continue...")
		lbl.SetWrap(true)
		box.Append(lbl)
	}

	dialog.ConnectResponse(func(responseID int) {
		dialog.Destroy()
	})

	dialog.SetVisible(true)
}

```

---

<div class="post-metadata">

**Author:** ![pekim](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/pekim/32/14094_2.png) [@pekim](https://forum.golangbridge.org/u/pekim)\
**Post date:** [May 26, 2026, 1:34pm UTC](https://forum.golangbridge.org/t/gotk4-newmessagedialog-doesnt-take-the-message-format-argument/41951/3 "2026-05-26T13:34:38Z")

</div>

You could try setting the MessageDialog’s `text` property.

This is completely untested. I’m just going from gtk and gobject documentation, along with gotk4 docs on pkg.go.dev.

```go
dialog := gtk.NewMessageDialog(
	&window.Window,
	gtk.DialogModal|gtk.DialogDestroyWithParent,
	gtk.MessageInfo,
	gtk.ButtonsOK,
)

var textValue glib.Value
textValue.InitValue(glib.TypeString)
textValue.SetString("Some info I want to let the user know")

dialog.SetObjectProperty("text", textValue)

```

---

<div class="post-metadata">

**Author:** ![eliotttak](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/eliotttak/32/17115_2.png) [@eliotttak](https://forum.golangbridge.org/u/eliotttak)\
**Post date:** [May 26, 2026, 4:53pm UTC](https://forum.golangbridge.org/t/gotk4-newmessagedialog-doesnt-take-the-message-format-argument/41951/4 "2026-05-26T16:53:41Z")

</div>

Hi,

Your solution also works, but I prefer the @Vio’s one, for these reasons:

- His own does not use `SetObjectProperty()`, that I keep for cases where I can’t do otherwise.
- Your one contains an error: I must not create a nil `*glib.Value`, then set it a type and a value (by the way, the InitValue doesn’t exists), I just have to run `glib.NewValue("...")` and it automatically infers type.

Thanks you for answering

---

<div class="post-metadata">

**Author:** ![system](https://forum.golangbridge.org/uploads/default/original/2X/5/5ad234f7c3dbc68b6cc72d338ce4f2973d9fd81c.png) [@system](https://forum.golangbridge.org/u/system)\
**Post date:** [August 24, 2026, 4:54pm UTC](https://forum.golangbridge.org/t/gotk4-newmessagedialog-doesnt-take-the-message-format-argument/41951/5 "2026-08-24T16:54:15Z")

</div>

Closed on August 24, 2026, 4:54pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
