Git Product home page Git Product logo

zenity's Introduction

Zenity dialogs for Golang, Windows and macOS

Go Reference Go Report Go Coverage Mentioned in Awesome Go

This repo includes:

  • a cross-platform Go package providing Zenity-like dialogs (simple dialogs that interact graphically with the user)
  • a “port” of the zenity command to both Windows and macOS based on that library.

Implemented dialogs:

Behavior on Windows, macOS and other Unixes might differ slightly. Some of that is intended (reflecting platform differences), other bits are unfortunate limitations.

Installing

The Go package:

go get github.com/ncruces/zenity@latest

The zenity command on macOS/WSL using Homebrew 🍺:

brew install ncruces/tap/zenity

The zenity command on Windows using Scoop 🍨:

scoop install https://ncruces.github.io/scoop/zenity.json

The zenity command on macOS/Windows, if you have Go:

go install github.com/ncruces/zenity/cmd/zenity@latest

Or download the latest release.

Using

For the Go package, consult the documentation and examples.

The zenity command does its best to be compatible with the GNOME version.
Consult the documentation and man page of that command.

Why?

Benefits of the Go package:

  • no cgo (see benefits, mostly cross-compilation)
  • no main loop (or any other threading or initialization requirements)
  • cancelation through context
  • on Windows:
    • no additional dependencies
      • Explorer shell not required
      • works in Server Core
    • Unicode support
    • High DPI (no manifest required)
    • Visual Styles (no manifest required)
    • WSL/Cygwin/MSYS2 support
  • on macOS:
    • only dependency is osascript
  • on other Unixes:
    • wraps either one of zenity, matedialog, qarma

Zenity wrappers

Zenity wrappers for languages other than Go can benefit from our zenity command. On Unix (Linux, FreeBSD, etc) they can use the original tool, and on Windows/macOS they may use the command from this repo for portability.

Examples:

Credits

I'd like to thank all contributors, but @gen2brain in particular for dlgs, which was instrumental to the Windows port of zenity.

zenity's People

Contributors

dependabot[bot] avatar gabyx avatar gen2brain avatar hfmrow avatar ncruces avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

zenity's Issues

Printing

This looks like a really clean bring up of Native desktop stuff that lots of project needs.

Any plans for Printing.

Saw this: github.com/alexbrainman/printer

  • ONYL works on windows

Dialog window underneath

Hi,

I ran zenity.SelectFile(zenity.Filename(""),zenity.Directory()) in a astilectron project, and the dialog window is underneath the main window.
Seams to be an old problem, but can't see what's the fix

zenity 0.10.11 win32 cannot run on Windows 7

On Windows 7 0.10.10 works.
0.10.11 'zenity --help' output

PC=0x0

runtime.asmstdcall()
        runtime/sys_windows_386.s:35 +0x25 fp=0x12fe68 sp=0x12fe64 pc=0x46c975

eax     0x8
ebx     0x6f2cec
ecx     0x0
edx     0x12fe90
edi     0x12fe6c
esi     0x12fec4
ebp     0x12fe6c
esp     0x12fe60
eip     0x0
eflags  0x10202
cs      0x1b
fs      0x3b
gs      0x0

[linux] Use kdialog if zenity not available

On some distros (like Kubuntu, openSUSE) zenity is not pre-installed and system have kdialog instead. It would be nice to transparently invoke kdialog to work out of the box on more linux systems without proper packaging or asking users to install dependencies.

Kdialog documentation: https://develop.kde.org/deploy/kdialog/

Would you be interested in such contribution?

[macOS] Dialogs don't get focus automatically

Test code:

package main

import (
	"fmt"
	"github.com/ncruces/zenity"
)

func main() {
	file, err := zenity.SelectFile(zenity.Title("Test focus on MacOS"))
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(file)
}

Run in iTerm2, the SelectFile dialog does not get focus unless click the title bar.
Similar to https://discussions.apple.com/thread/2548172

Run in native Terminal, the SelectFile dialog get focus with one click.
Is it possible to get focus automatically?

FileFilter with ".xlsx" doesn't work

Thank you for your great product. I tried the following code on Mac, that doesn't enable *.xlsx file selection.

package main

import (
	"log"

	"github.com/ncruces/zenity"
)


func main() {
	path, err := zenity.SelectFile(
		zenity.Title("Select xlsx file"),
		zenity.FileFilter{
			Name: "Excel files",
			Patterns: []string{"*.xlsx"},
		},
	)
	log.Println(path, err)
}

I tried the following extensions, only MS office files are not acceptable.

  • .xlsx: ng
  • .pptx: ng
  • .pdf: ok
  • .png: ok
  • .tar.gz: ok
  • .dmg: ok

How to use zenity.Question

Not sure where I should ask this but how exactly zenity.Question is used? For an example, how do I know if the user selected "Yes" ("Sim" on the screenshot)?
Big thanks for maintaining this project

Message Dialogs

Is there any way to specify the size of a message box or the position where it appears on the screen?

[macOS] progress doesn't pop up in front since v0.8.8

  1. Open iTerm2 or Terminal, not full screen.
  2. Steps to reproduce
git clone https://github.com/ncruces/zenity.git
cd zenity

git checkout v0.8.7
go build ./cmd/zenity
./zenity --progress

git checkout v0.8.8
go build ./cmd/zenity
./zenity --progress

v0.8.8 doesn't pop up in front without fullscreen.

Dialog progress crashing at dlg.Complete()

Using the progress bar dialog, after the dlg.Complete() function I got the following error:

Failed to find SetWindowLongPtrW procedure in user32.dll: Could not find the specified procedure.

On older versions it was working fine.

dialog.vtbl.SetDefaultFolder should be dialog.vtbl.SetFolder

Bug in file_windows.go :

  • SetDefaultFolder always uses the "recently used folder" if any is set in the system
  • Also the filename (path) needs to be
  • opts.filename, err = filepath.Abs(filepath.FromSlash(opts.filename)) before shCreateItemFromParsingName is called.

crashes on syscall.Syscall6

Hi,I've encounter crash on updating zenity.Progress, it happens frequently when fast updating progress dialog value.

env: windows 2012 server
go: 1.18
ui: zenity.progress

crash stacks:

Exception 0xc0000005 0x0 0xc00063b8c8 0x7ffe000f4d56
PC=0x7ffe000f4d56

runtime.cgocall(0x41b9e0, 0xc000066ec0)
	/opt/homebrew/Cellar/go/1.18.3/libexec/src/runtime/cgocall.go:157 +0x4a fp=0xc0004d9780 sp=0xc0004d9748 pc=0x3b458a
syscall.SyscallN(0xd45f58?, {0xc00063b818?, 0x41685b?, 0x7ffe000e1970?})
	/opt/homebrew/Cellar/go/1.18.3/libexec/src/runtime/syscall_windows.go:538 +0x109 fp=0xc0004d97f8 sp=0xc0004d9780 pc=0x416c49
syscall.Syscall6(0xc00013ca20?, 0x23d7b634e19?, 0x23d7b634e19?, 0x0?, 0xc0004d98f0?, 0x3bdda5?, 0x23d744a0108?, 0xc0004d9908?)
	/opt/homebrew/Cellar/go/1.18.3/libexec/src/runtime/syscall_windows.go:482 +0x50 fp=0xc0004d9858 sp=0xc0004d97f8 pc=0x4168d0
github.com/ncruces/zenity/internal/win.MessageLoop(0xc0002f0340?)
	/Users/test/go/pkg/mod/github.com/ncruces/[email protected]/internal/win/user32.go:307 +0x152 fp=0xc0004d9940 sp=0xc0004d9858 pc=0x703c12
github.com/ncruces/zenity.(*progressDialog).setup(_, {0xc0001e20c0, 0x0, 0x190, 0xc0001e2100, 0xc0001e2120, 0x0, 0x0, {0x0, 0x0}, ...})
	/Users/test/go/pkg/mod/github.com/ncruces/[email protected]/progress_windows.go:198 +0x95b fp=0xc0004d9eb0 sp=0xc0004d9940 pc=0x709dfb
github.com/ncruces/zenity.progress.func1()
	/Users/test/go/pkg/mod/github.com/ncruces/[email protected]/progress_windows.go:38 +0x58 fp=0xc0004d9fe0 sp=0xc0004d9eb0 pc=0x7090d8
runtime.goexit()
	/opt/homebrew/Cellar/go/1.18.3/libexec/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc0004d9fe8 sp=0xc0004d9fe0 pc=0x41a121
created by github.com/ncruces/zenity.progress
	/Users/test/go/pkg/mod/github.com/ncruces/[email protected]/progress_windows.go:37 +0x26e

There is similar crash and solution, plz see ref here

I think a possible solution maybe here for [email protected], hope helps:

diff --git a/internal/win/kernel32.go b/internal/win/kernel32.go
index 7f44fe7..aea9658 100644
--- a/internal/win/kernel32.go
+++ b/internal/win/kernel32.go
@@ -45,3 +45,5 @@ func GetSystemDirectory() (string, error) { return windows.GetSystemDirectory()
 //sys GetConsoleWindow() (ret HWND) = kernel32.GetConsoleWindow
 //sys GetModuleHandle(moduleName *uint16) (ret Handle, err error) = kernel32.GetModuleHandleW
 //sys ReleaseActCtx(actCtx Handle) = kernel32.ReleaseActCtx
+//sys GlobalAlloc(flags uint32, dwBytes uintptr) (ret uintptr) = kernel32.GlobalAlloc
+//sys GlobalFree(dwBytes uintptr) (ret uintptr) = kernel32.GlobalFree
diff --git a/internal/win/user32.go b/internal/win/user32.go
index bf52b0a..c893979 100644
--- a/internal/win/user32.go
+++ b/internal/win/user32.go
@@ -303,20 +303,24 @@ func MessageLoop(wnd HWND) error {
 	isDialogMessage := procIsDialogMessageW.Addr()
 
 	for {
-		var msg MSG
-		s, _, err := syscall.Syscall6(getMessage, 4, uintptr(unsafe.Pointer(&msg)), 0, 0, 0, 0, 0)
+		// var msg MSG
+		msg := (*MSG)(unsafe.Pointer(GlobalAlloc(0, unsafe.Sizeof(MSG{}))))
+		s, _, err := syscall.Syscall6(getMessage, 4, uintptr(unsafe.Pointer(msg)), 0, 0, 0, 0, 0)
 		if int32(s) == -1 {
+			GlobalFree(uintptr(unsafe.Pointer(msg)))
 			return err
 		}
 		if s == 0 {
+			GlobalFree(uintptr(unsafe.Pointer(msg)))
 			return nil
 		}
 
-		s, _, _ = syscall.Syscall(isDialogMessage, 2, uintptr(wnd), uintptr(unsafe.Pointer(&msg)), 0)
+		s, _, _ = syscall.Syscall(isDialogMessage, 2, uintptr(wnd), uintptr(unsafe.Pointer(msg)), 0)
 		if s == 0 {
-			syscall.Syscall(translateMessage, 1, uintptr(unsafe.Pointer(&msg)), 0, 0)
-			syscall.Syscall(dispatchMessage, 1, uintptr(unsafe.Pointer(&msg)), 0, 0)
+			syscall.Syscall(translateMessage, 1, uintptr(unsafe.Pointer(msg)), 0, 0)
+			syscall.Syscall(dispatchMessage, 1, uintptr(unsafe.Pointer(msg)), 0, 0)
 		}
+		GlobalFree(uintptr(unsafe.Pointer(msg)))
 	}
 }
 
diff --git a/internal/win/zsyscall_windows.go b/internal/win/zsyscall_windows.go
index d28d2ae..69dbd2f 100644
--- a/internal/win/zsyscall_windows.go
+++ b/internal/win/zsyscall_windows.go
@@ -61,6 +61,8 @@ var (
 	procGenerateConsoleCtrlEvent     = modkernel32.NewProc("GenerateConsoleCtrlEvent")
 	procGetConsoleWindow             = modkernel32.NewProc("GetConsoleWindow")
 	procGetModuleHandleW             = modkernel32.NewProc("GetModuleHandleW")
+	procGlobalAlloc                  = modkernel32.NewProc("GlobalAlloc")
+	procGlobalFree                   = modkernel32.NewProc("GlobalFree")
 	procReleaseActCtx                = modkernel32.NewProc("ReleaseActCtx")
 	procCoCreateInstance             = modole32.NewProc("CoCreateInstance")
 	procSHBrowseForFolder            = modshell32.NewProc("SHBrowseForFolder")
@@ -203,6 +205,18 @@ func GetModuleHandle(moduleName *uint16) (ret Handle, err error) {
 	return
 }
 
+func GlobalAlloc(flags uint32, dwBytes uintptr) (ret uintptr) {
+	r0, _, _ := syscall.Syscall(procGlobalAlloc.Addr(), 2, uintptr(flags), uintptr(dwBytes), 0)
+	ret = uintptr(r0)
+	return
+}
+
+func GlobalFree(dwBytes uintptr) (ret uintptr) {
+	r0, _, _ := syscall.Syscall(procGlobalFree.Addr(), 1, uintptr(dwBytes), 0, 0)
+	ret = uintptr(r0)
+	return
+}
+
 func ReleaseActCtx(actCtx Handle) {
 	syscall.Syscall(procReleaseActCtx.Addr(), 1, uintptr(actCtx), 0, 0)
 	return

Defect in initFilters

Hi.

I use this repo for my project with VS Code IDE on Linux.
When I add a Pattern to SelectFile dialog, its not appearing, just drop a error: dialog canceled

I have found the issue, in the initFilters function add an extra character to the end of string.

I added a fix - avoid a new space char to end - and everything is okay:

		for i, p := range f.Patterns {
			buf.WriteString(p)
			if i < len(f.Patterns)-1 {
				buf.WriteRune(' ')
			}
		}

(You can't reproduce the issue, if run it with "go run" or "go build", just when debugging, I don't know why)

Bye

zenity file-selection

Is there any way to implement this on linux, where the file selector is opened in the application and attached to a window? I'm using attach to a window id, and found that it doesn't work on arch linux.

Icon option should specify supported file extension

On the documention, I think it should be specified that PNG files are supported (tested on Windows, haven't checked MacOS).

Also, do you plan adding support for .ico files? I thinking it would be useful using .ico instead of .png (Or maybe even use the .ico files present on some Windows DLLs like shell32.dll)

Print dialogue

I think we can build a Print dialogue for golang apps.

So then you can send a pdf or Image to Print dialogue.

I investigated it a year ago but there was not zenith back then that can do no cgo which will make it much easier .

Thanks @gen2brain and @ncruces for this great project

@gen2brain built a printing api but it did not bring up the dialogue if I recall

--help output to stderr on Windows

On windows
zenity --help 2>&1 | findstr color
It need '2>&1' to correctly get the help text about color.
Most command line tools print --help or /? to the stdout.
It is unnatural.

Notification style

@ncruces hello, i met a problem when I run zenity on Win11 OS. I get an undesired result:
image

how can i get the Windows style but not Win server core
image

Collaboration on Swift for Darwin

Hi Nuno,

I thought I drop a note here:

I was experimenting recently with the fact that Swift is able to compile an NSAlert message box far better than the shitty AppleScript thing we are both doing in our libs.

I was wondering if we could collaborate on making the dialogs more robust and nicer and more native on macOS. The message box I have already together, the thing would be to run the script with swift or just execute the script if its chmod +x.

Run the following script with

swift dialog.swift message info warning "Title here..." "Message here..." Ok Cancel 3 A B C

I have not yet together the NSAlert with NSViewTable where we put all options in, that would be awesome. Maybe we could give a try in hacking together a simple script which makes zenity --list at least with some basic options, basically extending my script above. What do you think =).
So far I am far more convinced this is a future proof solution (except the fact that apple changes stuff and it won't compile anymore (so far it works on Big Sur and High Sierra (which is a good thing) (probably needs compiler directives etc which is possible in Swift). Furthermore its not shitty ApplyScript which I have a hard time in understanding...

Progress dialog panics when cancelled on Linux

If a progress dialog is cancelled or closed by the user (by clicking on the "Cancel" button or by closing the window) it causes the whole program to panic.

The panic log looks like:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x4a2133]

goroutine 20 [running]:
bytes.(*Buffer).Bytes(...)
        /usr/lib/go/src/bytes/buffer.go:54
github.com/ncruces/zenity/internal/zenutil.(*progressDialog).wait(0xc0000d6000, 0x0, 0x0)
        /home/billy/go/pkg/mod/github.com/ncruces/[email protected]/internal/zenutil/progress_unix.go:81 +0x133
created by github.com/ncruces/zenity/internal/zenutil.RunProgress
        /home/billy/go/pkg/mod/github.com/ncruces/[email protected]/internal/zenutil/run_unix.go:80 +0x60c
exit status 2

I have made a repo with the code to reproduce the bug.

Thank you for this library and for the time and work you put into it btw, awesome job :)

Crystal wrapper

Hi @ncruces

I made a very simple tool for Zenity with the Crystal language. (It just runs Zenity commands.)

https://github.com/kojix2/zenity.cr

Crystal is a new language. Windows support for Crystal just started. Calling C library functions from Crystal in Windows is not yet easy. Because of this, it's hard to use existing GUI frameworks.

In this situation, I think this tool, which makes dialog boxes easily on Windows, could be very helpful. Your work can help people using new languages like Crystal to make simple GUIs for Windows.

Please keep up the good work.
Thanks.

Not interactable progress dialog

I'm creating a windows application that act as like Kiosk. We want show progress dialog to user to show payment processing progress, However It should not be able close by user interaction.

However, Zenity's Progress dialog is doesn't have options to do that.

Adding option or type to do this requirement would be nice.

Thanks.

Simple usage examples

Any simple usage examples would be great.
The screenshot is good but no code example.

I could (would) create a PR to add this to the readme once I can figure it out myself.

Question returning nothing in Windows

Hi!

firts of all, thank you for creating this library, it is very useful!

I'm running the latest windows binary (0.8.9) from command line like this:

zenity.exe --question --text "are you sure?" --title "test"

And it doesn't matter what button I'm pressing, it returns empty string (or nil, I don't know go :-) )

thanks in advance

WM_CLASS on Linux Xorg

I am using Zenity to create a progress bar for when my application is starting. In order to get the window icon working properly on Xorg Linux systems, I need to modify the WM_Class of the progress bar window. This usually comes from the title of the window. Currently, the WM_Class is set to zenity. Is there any way to change that?

I know I can just change the StartupWMClass attribute defined in my .desktop file, but changing that to "zenity" seems like a hacky solution and it might affect the icon of other applications that might be using this library.

Winetricks not working

Logs:

winetricks                    
warning: taskset/cpuset not available on your platform!
------------------------------------------------------
warning: You are using a 64-bit WINEPREFIX. Note that many verbs only install 32-bit versions of packages. If you encounter problems, please retest in a clean 32-bit WINEPREFIX before reporting a bug.
------------------------------------------------------
------------------------------------------------------
warning: You apppear to be using Wine's new wow64 mode. Note that this is EXPERIMENTAL and not yet fully supported. If reporting an issue, be sure to mention this.
------------------------------------------------------
Using winetricks 20240105 - sha256sum: 8f28985b06e9e04b5268e2aef3429b2a0f6abd4fd12c4a30472dfe66355128fa with wine-9.0-rc4 (Staging) and WINEARCH=win64
Running on OSX, but DISPLAY is not set...probably using Mac Driver.
winetricks GUI enabled, using zenity zenity v0.10.12 darwin/amd64
https://github.com/ncruces/zenity
flag provided but not defined: -hide-column

EOF

Using macOS 14.4.1, M1 Pro
Using zenity 0.10.12 (latest) and brew (latest) both don't work.

zenity.SelectFileSave adds a \n character

Hello!

This is weird, but when I call zenity.SelectFileSave(), it adds a newline character at the end of the filepath returned by the function, regardless of what I type in for the filename. Here's a quick test:

package main

import (
	"fmt"

	"github.com/ncruces/zenity"
)

func main() {

	filename, err := zenity.SelectFileSave()

	if err != nil {
		panic(err)
	}

	fmt.Println(fmt.Sprintf("%q", filename))

}

And here's the output with a saved file named test:
"/home/solarlune/Documents/Projects/Go/Tests/zenity/test\n"

This is a fresh project with freshly go getted zenity, Pop OS 20.10, go version 1.16.2.

Windows versions don't run in WINE and Proton

While trying out cross-compiled binaries, I noticed that zenity seems to crash when used in WINE and Proton:

Unhandled exception: 0xc0150010 in 64-bit code (0x000000007bc25af8).
Register dump:
 rip:000000007bc25af8 rsp:00000000008bfb70 rbp:000000000009ac80 eflags:00000202 (   - --  I   - - - )
 rax:00000000003e0000 rbx:00000000008bfb90 rcx:00000000008bfb90 rdx:0000000000000000
 rsi:0000000000000000 rdi:0000000000000000  r8:0000000000000000  r9:0000000000000000 r10:0000000000000000
 r11:0000000000030000 r12:000000c0001077d0 r13:0000000000000000 r14:000000c00003a000 r15:0000000000000006
Stack dump:
0x00000000008bfb70:  00000000008bfb90 000000007bc353f9
0x00000000008bfb80:  000000000c0a0049 000000006c891a80
0x00000000008bfb90:  00000001c0150010 0000000000000000
0x00000000008bfba0:  000000007bc25af8 0000000000000000
0x00000000008bfbb0:  0000000000000000 0000dbd40003a000
0x00000000008bfbc0:  0000000000000006 0000000000650d80
0x00000000008bfbd0:  000000c0001076f0 00000000003e0000
0x00000000008bfbe0:  00000000008bfcc0 000000007b600000
0x00000000008bfbf0:  00000000008bfc30 000000007b61be2f
0x00000000008bfc00:  0000000000000000 000000006eb0d6e3
0x00000000008bfc10:  0000000000000000 0000000000000000
0x00000000008bfc20:  000000000c0a0049 000000007b60c314
Backtrace:
=>0 0x000000007bc25af8 (0x000000000009ac80)
0x000000007bc25af8: jmp	0x000000007bc25af0
Modules:
Module	Address					Debug info	Name (41 modules)
PE	          400000-          6b9000	Deferred        flatpak-integrated-webserver
ELF	        7d000000-        7d005000	Deferred        <wine-loader>
ELF	    7fde161bf000-    7fde161c8000	Deferred        libxfixes.so.3
ELF	    7fde161c8000-    7fde161d5000	Deferred        libxcursor.so.1
ELF	    7fde161d5000-    7fde161e7000	Deferred        libxi.so.6
ELF	    7fde161e7000-    7fde161ec000	Deferred        libxcomposite.so.1
ELF	    7fde161ec000-    7fde161f9000	Deferred        libxrandr.so.2
ELF	    7fde161f9000-    7fde16206000	Deferred        libxrender.so.1
ELF	    7fde16206000-    7fde1620d000	Deferred        libxxf86vm.so.1
ELF	    7fde1620d000-    7fde16212000	Deferred        libxinerama.so.1
ELF	    7fde16312000-    7fde16318000	Deferred        libxau.so.6
ELF	    7fde16318000-    7fde16343000	Deferred        libxcb.so.1
ELF	    7fde16343000-    7fde1648b000	Deferred        libx11.so.6
ELF	    7fde164a5000-    7fde16566000	Deferred        winex11<elf>
ELF	    7fde16680000-    7fde16695000	Deferred        libxext.so.6
ELF	    7fde16695000-    7fde1669b000	Deferred        ws2_32.so
ELF	    7fde16715000-    7fde16741000	Deferred        liblzma.so.5
ELF	    7fde16741000-    7fde168ca000	Deferred        libxml2.so.2
ELF	    7fde168ca000-    7fde16919000	Deferred        libfontconfig.so.1
ELF	    7fde16919000-    7fde16991000	Deferred        libpcre.so.1
ELF	    7fde16991000-    7fde169b4000	Deferred        libbrotlicommon.so.1
ELF	    7fde169b4000-    7fde169d5000	Deferred        libgraphite2.so.3
ELF	    7fde169d5000-    7fde16b0f000	Deferred        libglib-2.0.so.0
ELF	    7fde16b0f000-    7fde16b1d000	Deferred        libbrotlidec.so.1
ELF	    7fde16b1d000-    7fde16bed000	Deferred        libharfbuzz.so.0
ELF	    7fde16bed000-    7fde16c07000	Deferred        libz.so.1
ELF	    7fde16c07000-    7fde16c40000	Deferred        libpng16.so.16
ELF	    7fde16c40000-    7fde16c53000	Deferred        libbz2.so.1
ELF	    7fde16c53000-    7fde16d17000	Deferred        libfreetype.so.6
ELF	    7fde16d31000-    7fde16d60000	Deferred        gdi32.so
ELF	    7fde16d60000-    7fde16ed7000	Dwarf           libwine.so.1
ELF	    7fde24507000-    7fde24522000	Deferred        libgcc_s.so.1
ELF	    7fde24522000-    7fde24666000	Deferred        libm.so.6
ELF	    7fde24666000-    7fde24680000	Deferred        libunwind.so.8
ELF	    7fde24680000-    7fde2468b000	Deferred        librt.so.1
ELF	    7fde2468b000-    7fde2475a000	Deferred        ntdll.so
ELF	    7fde2475d000-    7fde2492c000	Deferred        libc.so.6
ELF	    7fde2492c000-    7fde24933000	Deferred        libdl.so.2
ELF	    7fde24933000-    7fde24954000	Deferred        libpthread.so.0
ELF	    7fde24957000-    7fde2496e000	Deferred        user32.so
ELF	    7fde24970000-    7fde249a4000	Deferred        ld-linux-x86-64.so.2
Threads:
process  tid      prio (all id:s are in hex)
00000038 services.exe
	["C:\windows\system32\services.exe"]
	0000003c    0
	00000040    0
	00000080    0
	000000a0    0
	000000b8    0
	000000f0    0
	00000108    0
	0000012c    0
00000068 svchost.exe
	[C:\windows\system32\svchost.exe -k LocalServiceNetworkRestricted]
	0000006c    0
	00000084    0
	00000088    0
00000070 MicrosoftEdgeUpdate.exe
	00000074    0
	000000c8    0
	000000cc    0
	000000d0    0
	000000d4    0
00000090 winedevice.exe
	[C:\windows\system32\winedevice.exe]
	00000094    0
	000000a4    0
	000000a8    0
	000000ac    0
000000b0 winedevice.exe
	[C:\windows\system32\winedevice.exe]
	000000b4    0
	000000bc    0
	000000c0    0
	000000d8    0
	000000dc    0
	000000e0    0
	000000e4    0
000000e8 plugplay.exe
	[C:\windows\system32\plugplay.exe]
	000000ec    0
	000000f4    0
	000000f8    0
	000000fc    0
00000100 svchost.exe
	[C:\windows\system32\svchost.exe -k netsvcs]
	00000104    0
	0000010c    0
	00000110    0
	00000114    0
	0000014c    0
	00000154    0
	00000568    0
00000124 rpcss.exe
	[C:\windows\system32\rpcss.exe]
	00000128    0
	00000130    0
	00000134    0
	00000138    0
	0000013c    0
	00000614    0
	00000618    0
	00000654    0
000005f4 start.exe
	000005f8    0
000005fc conhost.exe
	["C:\windows\system32\conhost.exe" --unix --width 121 --height 23 --server 0xc]
	00000600    0
00000604 explorer.exe
	[C:\windows\system32\explorer.exe /desktop]
	00000608    0
	0000060c    0
	00000610    0
0000061c (D) Z:\tmp\go-build3797557352\b001\exe\flatpak-integrated-webserver.exe
	["Z:\tmp\go-build3797557352\b001\exe\flatpak-integrated-webserver.exe" ]
	00000620    0 <==
	00000624    0
	00000628    0
	0000062c    0
	00000630    0
	00000634    0
	00000640    0
00000644 explorer.exe
	[C:\windows\system32\explorer.exe /desktop]
	00000648    0
	0000064c    0
	00000650    0
System information:
    Wine build: wine-6.16 (Staging)
    Platform: x86_64
    Version: Windows 10
    Host system: Linux
    Host version: 5.13.13-200.fc34.x86_64

The Dialog displays correctly:

image

However as soon as it is closed (this is true for all dialogs), it crashes. Using GOARCH=386 gives a bit more info:

$ GOOS=windows GOARCH=386 go run .
0380:fixme:font:get_name_record_codepage encoding 20 not handled, platform 1.
0394:fixme:font:get_name_record_codepage encoding 20 not handled, platform 1.
0398:fixme:font:get_name_record_codepage encoding 20 not handled, platform 1.
03e4:fixme:font:get_name_record_codepage encoding 20 not handled, platform 1.
03e4:fixme:process:SetProcessPriorityBoost (FFFFFFFF,1): stub
Exception 0xc0150010 0x20104018 0x85fe58 0x7bc236b8
PC=0x7bc236b8

runtime.cgocall(0x45cd00, 0x60f61c)
        /usr/local/go/src/runtime/cgocall.go:156 +0x58 fp=0x200b7a94 sp=0x200b7a7c pc=0x4035b8
syscall.Syscall(0x7b60af68, 0x1, 0x8c33b8, 0x0, 0x0)
        /usr/local/go/src/runtime/syscall_windows.go:479 +0xbb fp=0x200b7ab0 sp=0x200b7a94 pc=0x45a09b
syscall.(*Proc).Call(0x20100040, {0x2010200c, 0x1, 0x1})
        /usr/local/go/src/syscall/dll_windows.go:183 +0x108 fp=0x200b7b44 sp=0x200b7ab0 pc=0x478d28
syscall.(*LazyProc).Call(0x2009d638, {0x2010200c, 0x1, 0x1})
        /usr/local/go/src/syscall/dll_windows.go:340 +0x58 fp=0x200b7b68 sp=0x200b7b44 pc=0x47a2b8
github.com/ncruces/zenity.setup.func2()
        /home/pojntfx/go/pkg/mod/github.com/ncruces/[email protected]/util_windows.go:135 +0xa7 fp=0x200b7b94 sp=0x200b7b68 
pc=0x4a7077
github.com/ncruces/zenity.listDlg({0x521f02, 0x21}, {0x2008a7a0, 0x4, 0x4}, 0x0, {0x20088618, 0x0, 0x0, 0x20088630, ...})
        /home/pojntfx/go/pkg/mod/github.com/ncruces/[email protected]/list_windows.go:190 +0x1168 fp=0x200b7dc4 sp=0x200b7b9
4 pc=0x4a5b68
github.com/ncruces/zenity.list({0x521f02, 0x21}, {0x2008a7a0, 0x4, 0x4}, {0x20088618, 0x0, 0x0, 0x0, 0x0, ...})
        /home/pojntfx/go/pkg/mod/github.com/ncruces/[email protected]/list_windows.go:9 +0x70 fp=0x200b7e60 sp=0x200b7dc4 pc
=0x4a4980
github.com/ncruces/zenity.List({0x521f02, 0x21}, {0x2008a7a0, 0x4, 0x4}, {0x200b7fa4, 0x2, 0x2})
        /home/pojntfx/go/pkg/mod/github.com/ncruces/[email protected]/list.go:8 +0xa0 fp=0x200b7f60 sp=0x200b7e60 pc=0x4a48c
0
main.main()
        /home/pojntfx/Projects/multi-browser-electron/flatpak-integrated-webserver/main.go:49 +0x231 fp=0x200b7fc8 sp=0x2
00b7f60 pc=0x4ef541
runtime.main()
        /usr/local/go/src/runtime/proc.go:255 +0x23a fp=0x200b7ff0 sp=0x200b7fc8 pc=0x434d9a
runtime.goexit()
        /usr/local/go/src/runtime/asm_386.s:1319 +0x1 fp=0x200b7ff4 sp=0x200b7ff0 pc=0x45c061
eax     0x0
ebx     0x85fd60
ecx     0x85fe40
edx     0x8c33b8
edi     0x0
esi     0x45bd8e
ebp     0x85fdd8
esp     0x85fd54
eip     0x7bc236b8
eflags  0x206
cs      0x23
fs      0x63
gs      0x6b
exit status 2

As a quick workaround, commenting out https://github.com/ncruces/zenity/blob/master/util_windows.go#L135 works (for all dialogs, on amd64 and i386.

Sadly I don't know much about the Windows-specific call in question; maybe there is an easy way to fix this?

Using keyboard on Windows

When I run the following example code on Linux:

package main

import (
	"github.com/ncruces/zenity"
)

func main() {
	zenity.Question("Are you sure you want to proceed?",
		zenity.Title("Question"),
		zenity.QuestionIcon)
}

I am able to use both the mouse and the keyboard.

However, when I run the same example on Windows, I can use the mouse but not keyboard.

Is this behavior to be expected or I am doing something wrong?

macos file-selection lose focus

The language of the file manager does not correspond to my system. My system is in Chinese, but when the file manager is opened, it is in English。

image

-notification show nothing in win7 git-for-windows

In win7 64bit / v0.7.9 / git-for-windows (in cmder):

./zenity.exe --notification --text "Good Morning"

show: nothing


run powershell gui in cmd:

powershell -Command "& {Add-Type -AssemblyName System.Windows.Forms; Add-Type -AssemblyName System.Drawing; $notify = New-Object System.Windows.Forms.NotifyIcon; $notify.Icon = [System.Drawing.SystemIcons]::Information; $notify.Visible = $true; $notify.ShowBalloonTip(0, 'Hello world', 'This is called from a batch script.', [System.Windows.Forms.ToolTipIcon]::None)}"

work great:
2021-08-07 14_14_11-Cmder

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.