Pastey budget.ex

include GtkEngine.e
include std/eds.e 
 
db_fatal_id = routine_id("ShowError") -- global procedure in utils.e; 
 
constant tips = {    -- these add tooltips to the buttons, and  are useful   
 "Exit the program", -- as a reminder of what this file is expected to do; 
 "Insert a new record", 
 "Edit the selected record", 
 "Delete the selected record" 
 } 
  
include record_funcs.e -- contains functions called by buttons below; 
 
constant -- Main Window 
    win = create(GtkWindow,"name=MainWin;size=600x500;border=10;$destroy=BailOut"), 
    pan = create(GtkBox,"orientation=vertical;name=MainWin:Panel"), 
    bar = create(GtkMenuBar,"name=MainWin:MenuBar"),-- exported by name so constant bar is local; 
    box = create(GtkButtonBox,"margin top=10"),  
    btn = create(GtkButton,"gtk-quit","BailOut") -- calls Bailout (in utils.e) directly; 
        & create(GtkButton,"gtk-add",_("Insert"))   -- call local functions in record_funcs.e 
        & create(GtkButton,"gtk-edit",_("Edit"))    -- there are also Edit and Delete funcs 
        & create(GtkButton,"gtk-delete",_("Delete"))-- in other menus, but they aren't visible here; 
 
for i = 1 to length(tips) do 
    set(btn[i],"tooltip text",tips[i]) 
end for 
         
include file_menu.e  -- These *_menu.e files contain the drop-down menu contents, 
include table_menu.e -- and add themselves to the main menu, in the order they are included; 
include record_menu.e 
include utils.e 
include help.e 
 
add(win,pan) 
add(box,btn) 
pack(pan,bar) 
pack(pan,"View",1,1) -- View is exported by name from view.e - in this case, it's a ListView 
pack(pan,-box) 
 
show_all(win) 
main() 

1. Comment by irv 1 week ago

I'm posting some code to show how easy it is to create a user-friendly interface to your programs. These four files contain a fairly complete and generic program interface. You could use it for other purposes with minor modifications.

Breaking code up into easy-to understand chunks makes development a lot easier. This particular "budget" project is substatially complete, and has:

----------------------------------------- 
Lines of code  (comments count as code) 
----------------------------------------- 
File: budget.ex 36 lines 
File: dump.txt 10 lines 
File: file_funcs.e 87 lines 
File: file_menu.e 39 lines 
File: help.e 15 lines 
File: prefs.e 12 lines 
File: record_funcs.e 51 lines 
File: record_menu.e 24 lines 
File: sl_input.e 39 lines 
File: table_funcs.e 96 lines 
File: table_menu.e 26 lines 
File: utils.e 132 lines 
File: view.e 33 lines 
------------------------------------- 
600 lines of code in /home/irv/WORK 
------------------------------------- 

There is one more interface file to write - a multi-line record edit form. Should take less than 100 loc.

I'm posting the interface which you can run, the code to handle the database functions is written (file_funcs.e, table_funcs.e, and record_funcs.e - see list above). I'll post that later if anyone is interested.

2. Comment by irv 1 week ago

Looks like I clipped off the function that should have been at the bottom of this file:

------------------------- 
global function BailOut() 
------------------------- 
return Quit() 
end function 

Search



Quick Links

User menu

Not signed in.

Help Fund OpenEuphoria

Misc Menu