GtkD CRUD Application

Alaindevos devosalain at ymail.com
Sat Oct 17 14:53:35 UTC 2020


I've written the beginning but dont know how to end.
What is the way to add functionality for the add,edit,delete 
button ?
//==================================
import gtk.Button;
import gtk.Box;
import gtk.Label;
import gtk.Entry;
import gtk.Grid;
import gtk.Main;
import gtk.MainWindow;
import gtk.Widget;
import gdk.Event: Event;
import std.array: assocArray;
import std.conv: to;
import std.format : format;
import std.range: iota, retro, drop, zip;
import std.stdio: writeln;



struct nameage {
	string name;
	int age;
}

class Row: Box {
	ulong index;
	this(nameage anameage,ulong index){
		this.index=index;
		super(Orientation.HORIZONTAL,5);
	    this.packStart((new Label(anameage.name)),0,0,0);
	    this.packStart((new Label(to!string(anameage.age))),0,0,0);
	    this.packStart((new Button("Edit")),0,0,0);
	    this.packStart((new Button("Delete")),0,0,0);

	}
}

class MyWindow : MainWindow {
	
	Box vbox;
	nameage []mynameage;
	
	void quit(){
		this.quit();
	}

	void addclicked(){
	}

	this(int sizex,int sizey){
		nameage nameage1=nameage("Alain",20);
		nameage nameage2=nameage("Eddy",30);
		mynameage ~= nameage1;
		mynameage ~= nameage2;
		super("My Locate D-lang App");
		setSizeRequest(sizex,sizey);
		setHexpand(0);
		addOnDestroy(delegate void(Widget w) { quit(); } );
		vbox=new Box(Orientation.VERTICAL,5);
			foreach (ulong i,anameage;mynameage){
				Row arow=new Row(anameage,i);
				vbox.packStart(arow,0,0,0);
			}
			Button addbutton=new Button("Add");
			addbutton.addOnClicked(delegate void(Button b){addclicked();});
	        vbox.packStart(addbutton,0,0,0);

		add(vbox);
		showAll();
	}
}


int main(string[] args){
	int sizex=800;
	int sizey=600;
	Main.init(args);
	MyWindow window=new MyWindow(sizex,sizey);
	Main.run();
	return 0;
}
//==================================



More information about the Digitalmars-d-learn mailing list