On Friday, 24 April 2020 at 13:45:22 UTC, Phrozen wrote:
I need something simple - a modal window with 3 buttons and a two text boxes

This sounds easy with my minigui.d. My library doesn't have a lot of features, no fancy graphics, and layout can be a bit clunky... but check out this code:

Well first grab the library files from here:


The three files you'll need are minigui.d, simpledisplay.d, and color.d. Just download them to your directory and compile all together with your file:

dmd yourfile.d minigui.d simpledisplay.d color.d

and it will make yourfile.exe. To get rid of the console, add `-L/subsystem:windows` to that build command. If making a 64 bit exe, you will need -m64 and -L/entry:mainCRTStartup as well. So the total thing can be:

dmd yourfile.d minigui.d simpledisplay.d color.d -L/subsystem:windows -L/entry:mainCRTStartup -m64

And that will create your stand-alone Windows exe that does not have a console, just the gui window.

Here's a screenshot:


The library also works on Linux but it is quirky there since it is 100% DIY. It has no Mac support at all right now. But if all you need is basic building blocks on Windows, it should be OK.

Anyway, the code, I hope is is kinda self-explanatory or at least you can try poking around and see changes yourself. If not let me know and I'll write more here.

import arsd.minigui;

class CustomSpacer : Widget {
        this(Widget parent) { super(parent); }

        override int paddingLeft() { return 32; }
        override int paddingRight() { return 32; }
        override int paddingTop() { return 32; }
        override int paddingBottom() { return 32; }

void main() {
        auto window = new Window(400, 180, "My Calculator");

        auto spacer = new CustomSpacer(window);

        auto box1 = new LabeledLineEdit("Fahrenheit: ", spacer);
        auto box2 = new LabeledLineEdit("Celsius: ", spacer);

        new VerticalSpacer(spacer);

        auto layout = new class HorizontalLayout {
                this() { super(spacer); }
                override int maxHeight() { return 40; }

        auto button1 = new Button("F to C", layout);
        auto button2 = new Button("C to F", layout);
        auto button3 = new Button("Close", layout);

button1.addEventListener(EventType.triggered, delegate () {
                import std.conv;
                import std.format;
                try {
                        auto f = to!float(box1.content);
                        auto c = (f - 32) / 1.8;

                        box2.content = format("%0.2f", c);
                } catch(Exception e) {
                        messageBox("Exception", e.msg);

button2.addEventListener(EventType.triggered, delegate () {
                import std.conv;
                import std.format;
                try {
                        auto c = to!float(box2.content);
                        auto f = c * 1.8 + 32;

                        box1.content = format("%0.2f", f);
                } catch(Exception e) {
                        messageBox("Exception", e.msg);

        button3.addEventListener(EventType.triggered, delegate() {


I wrote some docs for the lib here but it is incomplete. http://dpldocs.info/experimental-docs/arsd.minigui.html

It is also possible to use my library with dub


It is the "arsd-official:minigui" subpackage there. But I think it is easier to just download the file yourself and build it since it doesn't have a fancy build system.

Reply via email to