Jump to page: 1 2
Thread overview
GUI library for DMD 2.090 or DMD 2.091
Apr 24, 2020
Phrozen
Apr 24, 2020
Adam D. Ruppe
Apr 24, 2020
Phrozen
Apr 24, 2020
Adam D. Ruppe
Apr 24, 2020
Russel Winder
Apr 25, 2020
Paulo Pinto
Apr 25, 2020
Russel Winder
Apr 26, 2020
Antonio Corbi
Apr 27, 2020
Paulo Pinto
Apr 27, 2020
Antonio Corbi
May 11, 2020
Russel Winder
Apr 24, 2020
Basile B.
Apr 25, 2020
Marcone
Apr 25, 2020
Murilo
Apr 26, 2020
dangbinghoo
April 24, 2020
I'm too new to DLang and I have a lot to learn. Probably that's why I have a lot of difficulties. Has anyone tried using a GUI library to the latest DMD 2.090 or DMD 2.091? I plan to use this language for a specific Thermal calculator application for Windows, but for two days I've been struggling with dub and elementary examples in GUI libraries. I need something simple - a modal window with 3 buttons and a two text boxes. So far I have tested DWT, TKD, DFL, dlangui without success.
Can anyone help me with advice or some more recent tutorial. Thank you!
April 24, 2020
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:

https://github.com/adamdruppe/arsd

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:

http://arsdnet.net/calc.png

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() {
                window.close();
        });


        window.loop();
}
---

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

https://code.dlang.org/packages/arsd-official

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.
April 24, 2020
On Friday, 24 April 2020 at 13:45:22 UTC, Phrozen wrote:
> I'm too new to DLang and I have a lot to learn. Probably that's why I have a lot of difficulties. Has anyone tried using a GUI library to the latest DMD 2.090 or DMD 2.091? I plan to use this language for a specific Thermal calculator application for Windows, but for two days I've been struggling with dub and elementary examples in GUI libraries. I need something simple - a modal window with 3 buttons and a two text boxes. So far I have tested DWT, TKD, DFL, dlangui without success.
> Can anyone help me with advice or some more recent tutorial. Thank you!

you also have GTK-D[1], and you have up to date sources to learn[2] it.

[1] https://code.dlang.org/packages/gtk-d
[2] https://gtkdcoding.com/
April 24, 2020
On Friday, 24 April 2020 at 14:13:25 UTC, Adam D. Ruppe wrote:
> On Friday, 24 April 2020 at 13:45:22 UTC, Phrozen wrote:
>> [...]
>
> 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:
>
> [...]

@Adam D. Ruppe, your idea is great, especially for small and unpretentious applications! Very good work, man!

@Basile B., thanks for the suggestion. I'll try this library too.

Thank you both, guys!
Be healthy!
April 24, 2020
On Friday, 24 April 2020 at 15:50:15 UTC, Phrozen wrote:
> @Adam D. Ruppe, your idea is great, especially for small and unpretentious applications! Very good work, man!

if you do decide to use my thingy let me know how it goes for you.

I often don't recommend it in threads cuz it kinda sucks, but I just think your use case sounded like a good fit.
April 24, 2020
On Fri, 2020-04-24 at 15:50 +0000, Phrozen via Digitalmars-d-learn wrote:
> 
[…]
> @Basile B., thanks for the suggestion. I'll try this library too.
> 

Just a bit of confirmation: I am a fan of D and GtkD for desktop UI work.

GTK+ is just a UI framework unlike Qt (which is UI and networking,
database, etc.) and is fairly straightforward to work with after the
initial learning hump – which is the same between GTK+ and Qt. Qt is
really C++ and Python only though many languages have bindings to QML.
GTK+ has many bindings, C++, Go, Rust, and D to name just the obvious
native code languages. C++ (gtkmm) and Go (gotk3) bindings are manuals
ones, Rust (gtk-rs) and D (GtkD) bindings are generated from the API
specification (GIR files). I believe this makes gtk-rs and GtkD far
superior to gtkmm and gotk3.

I have done a number of projects in Rust/gtk-rs and D/GtkD. Overall I prefer the code of D/GtkD over Rust/gtk-rs *but* there is much more IDE and editor support for Rust compared to D. This makes Rust code easier to write than the equivalent  D code, even if that Rust code is more ugly than the equivalent D code.

So whilst I keep wanting to do D/GtkD, I keep getting pulled to Rust/gtk-rs simply because CLion (and Emacs) support for Rust is so much nicer than the D support.

I must laud Samael's efforts on the IntelliJ IDEA/CLion D support, it is magnificent, but the project needs more resource to get the CLion D plugin somewhere near as good as the Rust CLion plugin. I am sure VisualStudio fans, indeed any other IDE users, will say the same about their IDE, I am a CLion user so try to push CLion support.

-- 
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk



April 25, 2020
On Friday, 24 April 2020 at 18:52:55 UTC, Russel Winder wrote:
> On Fri, 2020-04-24 at 15:50 +0000, Phrozen via Digitalmars-d-learn wrote:
>> 
> […]
>> @Basile B., thanks for the suggestion. I'll try this library too.
>> 
>
> Just a bit of confirmation: I am a fan of D and GtkD for desktop UI work.
>
> GTK+ is just a UI framework unlike Qt (which is UI and networking,
> database, etc.) and is fairly straightforward to work with after the
> initial learning hump – which is the same between GTK+ and Qt. Qt is
> really C++ and Python only though many languages have bindings to QML.
> GTK+ has many bindings, C++, Go, Rust, and D to name just the obvious
> native code languages. C++ (gtkmm) and Go (gotk3) bindings are manuals
> ones, Rust (gtk-rs) and D (GtkD) bindings are generated from the API
> specification (GIR files). I believe this makes gtk-rs and GtkD far
> superior to gtkmm and gotk3.
>
> I have done a number of projects in Rust/gtk-rs and D/GtkD. Overall I prefer the code of D/GtkD over Rust/gtk-rs *but* there is much more IDE and editor support for Rust compared to D. This makes Rust code easier to write than the equivalent  D code, even if that Rust code is more ugly than the equivalent D code.
>
> So whilst I keep wanting to do D/GtkD, I keep getting pulled to Rust/gtk-rs simply because CLion (and Emacs) support for Rust is so much nicer than the D support.
>
> I must laud Samael's efforts on the IntelliJ IDEA/CLion D support, it is magnificent, but the project needs more resource to get the CLion D plugin somewhere near as good as the Rust CLion plugin. I am sure VisualStudio fans, indeed any other IDE users, will say the same about their IDE, I am a CLion user so try to push CLion support.

Just curious, how do you handle the whole RC<RefCell<>> story in Gtk-rs?

For me it made the point that languages with tracing GC or implicit reference counting are much better solution for doing GUI programming.


April 25, 2020
On Sat, 2020-04-25 at 09:30 +0000, Paulo Pinto via Digitalmars-d-learn
wrote:
[…]
> 
> Just curious, how do you handle the whole RC<RefCell<>> story in Gtk-rs?
> 
> For me it made the point that languages with tracing GC or implicit reference counting are much better solution for doing GUI programming.
> 

I am still not sure I have truly come to terms with the whole Rc/Arc and RefCell stuff. It isn't so much the using them, it is trying to decide what is the right combination for a given situation.

Big D win here due to garbage collection.

-- 
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk



April 25, 2020
On Friday, 24 April 2020 at 13:45:22 UTC, Phrozen wrote:
> I'm too new to DLang and I have a lot to learn. Probably that's why I have a lot of difficulties. Has anyone tried using a GUI library to the latest DMD 2.090 or DMD 2.091? I plan to use this language for a specific Thermal calculator application for Windows, but for two days I've been struggling with dub and elementary examples in GUI libraries. I need something simple - a modal window with 3 buttons and a two text boxes. So far I have tested DWT, TKD, DFL, dlangui without success.
> Can anyone help me with advice or some more recent tutorial. Thank you!

You can create easy GUI using Qt or Win32Api.
See step-by-step easy vides:

GUI Qt: https://www.youtube.com/watch?v=Es9Qs9_1ipk
GUI Win32Api: https://www.youtube.com/watch?v=_QqyPTLbgHU
April 25, 2020
On Friday, 24 April 2020 at 13:45:22 UTC, Phrozen wrote:
> I'm too new to DLang and I have a lot to learn. Probably that's why I have a lot of difficulties. Has anyone tried using a GUI library to the latest DMD 2.090 or DMD 2.091? I plan to use this language for a specific Thermal calculator application for Windows, but for two days I've been struggling with dub and elementary examples in GUI libraries. I need something simple - a modal window with 3 buttons and a two text boxes. So far I have tested DWT, TKD, DFL, dlangui without success.
> Can anyone help me with advice or some more recent tutorial. Thank you!

Here is everything you need to know: https://madscientisthaven.blogspot.com/2020/01/beginning-multimedia-with-arsd.html
« First   ‹ Prev
1 2