r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!RebGUI] A lightweight alternative to VID

Graham
3-Jan-2010
[8629x2]
I often have the need to set a date on a field ... and use a symbol 
to invoke the request-date .. .but this usually means I have to name 
the date field like this


datefld: field 25 symbol data 'look on-click [ use [d][ if d: request-date 
[ set-text datefld form d ]]]


To avoid naming the datefield, I have this function which returns 
the prior face


get-prior-widget: func [ f
    /local pane priorface
][
    pane: f/parent-face/pane
    priorface: pick pane -1 + index? find pane f
]

and here's a request date that uses it


request-date-priorface: func [ f /local d ]
[
    if d: request-date [
        set-text get-prior-widget f form d
    ]
]

so we can now do:


 field 25 symbol data 'look on-click [  request-date-priorface face 
 ]
Can't use funct as using the SDK :)
Ashley
3-Jan-2010
[8631]
1) set-values.r ... removed in build#212. Plan is to add accessors 
(e.g. add, update, delete) to each "complex" widget.

2) named widgets ... don't forget the 'in-widget function, it does 
what you want above (see biuld#213 release note from Aug 27).

3) funct ... you'll have to build your own collection of SDK+ mezz 
funcs as the SDK diverges further from R3 (and R2 releases without 
an SDK update).
Graham
3-Jan-2010
[8632x3]
and how to set  a check-group?
Just looked at in-widget, and it does different things. I want to 
find a specific widget ...
And this doesn't seem to work either


>> display "" [ gb: group-box -1x-1 data [ t: table "test" options 
[ "a" left 1 ] data [ 1 2 3 ]] return button "Get" [ probe get-values 
gb ]] do-events
[[]]
Graham
4-Jan-2010
[8635x3]
Ashley, I posted a simple function that grabs spelling suggestions 
from the google spell checker.  I  am going to see if I can use it 
in the rebgui spell checker to provide suggestions as currently the 
spell checker does not ....
posted in the core group
I've managed to incorporate the google spell check into rebgui's 
spell checker... but it is slower of course but more accurate.

Some optimizations would be to add correctly spelled words unknown 
to the local dictionary automatically, and to also spell check a 
number of words at the same time ... it probably makes not much difference 
to the google spell checker, and is less expensive in terms of web 
calls.
Graham
5-Jan-2010
[8638x2]
What I am doing now .. is scanning all the words in the face, and 
checking them against the dictionary.  If not found, I collect them 
all and then submit all of them to google.  This then gives me lists 
of choices for each word which is not recognized.
Seems to be working ...
Pekr
5-Jan-2010
[8640]
In RebDOC, Request-font throws an error ...
Graham
5-Jan-2010
[8641]
4.  I can't see a way to update the check-group so looks like it 
is easier for me to just  rebuild the check-group on the fly
jack-ort
24-Feb-2010
[8642]
Hi!  maybe I should ask this in the "I'm New" group.  Wanted to try 
out RebGUI for my 2nd REBOL project.  I'm stuck early on trying to 
refresh a table based on a SQL query in a parent window when closing 
a child window that would have added a record to table.  I've gotten 
the examples on click and away events to work, but do not understand 
how to use focus events apparently.  Can someone point me to some 
sample code that would help w/ moving focus from window to window 
and refreshing tables?  With that, I think most of my GUI problems 
would be solved. 

TIA!  -Jack
Graham
24-Feb-2010
[8643]
Post some sample code somewhere ...
Ashley
25-Feb-2010
[8644]
http://www.dobeash.com/RebGUI/cookbook.html#section-1might help 
you get started.
jack-ort
25-Feb-2010
[8645x3]
Ashley - that got me started, but where I get stuck is on the syntax 
to refer to a widget *in another window*.  In the sample below, I 
want my "Save" button to not only write a new record to my SQLite 
db, but also to refresh the query that loads the table in the parent 
window (OR, can I refresh the parent window table after the child 
window closes and the focus returns to the parent?  I cannot seem 
to trigger any focus events.).  I was trying to wrap my windows in 
objects, which are new to me also, so I'm sure that is part of my 
problem.  Obviously my attempt to refer to my table by this path 
(adddelusers/gui/tbl/data) is incorrect, since I get this error:

** Script Error: Invalid path value: tbl
** Where: on-click

** Near: insert adddelusers/gui/tbl/data (sql/flat "select * from 
users order by userid") adddelusers/gui/tbl/redraw

adddelusers: context [
			title: {Add/Remove Users}

   tbldata: copy esql/rtn [sql/flat "select * from users order by userid"][]
			gui: [

    tbl: table 125x50 options ["UserID" left 0.2 "Password" left 0.8] 
				return
				button "Add User" 30 on [
										click [display/parent adduser/title adduser/gui ]
									]
				button "Remove User" 30 [alert "need to add code here..."]
						]	
]

adduser: context [
		title: {Add User}
		gui: [	
				user:	field text "username" return
				pwd:	field text "password" return

    button "Save" [sql compose ["insert or replace into users values 
    (?,?)" (to-word user/text) (to-binary checksum/secure pwd/text)]

         insert adddelusers/gui/tbl/data (sql/flat "select * from users order 
         by userid") adddelusers/gui/tbl/redraw
								unview adduser/gui ]
				button "Cancel" [unview adduser/gui]
		]
	]
Ashley - that got me started, but where I get stuck is on the syntax 
to refer to a widget *in another window*.  In the sample below, I 
want my "Save" button to not only write a new record to my SQLite 
db, but also to refresh the query that loads the table in the parent 
window (OR, can I refresh the parent window table after the child 
window closes and the focus returns to the parent?  I cannot seem 
to trigger any focus events.).  I was trying to wrap my windows in 
objects, which are new to me also, so I'm sure that is part of my 
problem.  Obviously my attempt to refer to my table by this path 
(adddelusers/gui/tbl/data) is incorrect, since I get this error:

** Script Error: Invalid path value: tbl
** Where: on-click

** Near: insert adddelusers/gui/tbl/data (sql/flat "select * from 
users order by userid") adddelusers/gui/tbl/redraw

adddelusers: context [
			title: {Add/Remove Users}

   tbldata: copy esql/rtn [sql/flat "select * from users order by userid"][]
			gui: [

    tbl: table 125x50 options ["UserID" left 0.2 "Password" left 0.8] 
				return
				button "Add User" 30 on [
										click [display/parent adduser/title adduser/gui ]
									]
				button "Remove User" 30 [alert "need to add code here..."]
						]	
]

adduser: context [
		title: {Add User}
		gui: [	
				user:	field text "username" return
				pwd:	field text "password" return

    button "Save" [sql compose ["insert or replace into users values 
    (?,?)" (to-word user/text) (to-binary checksum/secure pwd/text)]

         insert adddelusers/gui/tbl/data (sql/flat "select * from users order 
         by userid") adddelusers/gui/tbl/redraw
								unview adduser/gui ]
				button "Cancel" [unview adduser/gui]
		]
	]
sorry for the double-send.  and I realize that in cleaning up the 
code I left out the initial table load using the "tbldata" in the 
first window, but I think the rest of the sample represents my issue.

TIA for helping a newbie!
Graham
25-Feb-2010
[8648]
syntax is

on-click [] and not on [ click [ ] ]
jack-ort
25-Feb-2010
[8649]
Graham - either syntax works.  I had been testing several events 
(away, over, etc.) and Ashley's documentation mentions that you can 
put them all inside a single "on [...]" block.

I find I can refer to my parent table easily with a short path, by 
just doing "insert clear tbl/data ...." from the child window "Save" 
button action and I get what I want.  BUT, that means I didn't encapsulate 
my table name at all like I had hoped within my adddelusers object. 
 I would like to setup each window display with generic widget names, 
and not worry about uniqueness - that's why I thought about trying 
to wrap the guis in objects.  Can that be done?  and if so, will 
I be back to my problem of not knowing how to reference an encapsulated 
widget on another window?

Thanks!
Graham
25-Feb-2010
[8650x2]
If you're going to try and encapsulate inside a context, why not 
provide the method to update the gui inside the context?
BTW, if you're hiding field names then my experience is that you 
need to use closures instead of functions.
jack-ort
25-Feb-2010
[8652]
Thank you, Graham, for the continued feedback.  I'm ashamed to say 
I don't even understand your last comment - this newbie will have 
to go research "closures".


Your previous comment - that sounds like a good approach - I'll have 
to learn more to do that.  I can only learn something by trying to 
use it to solve real problems; the bad news for me is that in this 
case I'm new to GUIs, REBOL and RebGUI.
Graham
25-Feb-2010
[8653]
If you search on closures in this thread it will explain the issue 
it solves
Ashley
26-Feb-2010
[8654]
Get something that's simple working first ... then add complexity. 
I tend to "encapsulate" my GUIs in functions with generic widget 
identifiers, such as:

show-add-user: make function! [/local f1 f2 f3] [
	display "Add User" [
		after 2
		text ...		f1: field
		text ...		f2: field
		text ...		f3: field
		bar
		reverse
		button [f1/text: ...]
		do [...]
	]
]


If you can get this working then the problem shifts from being a 
RebGUI problem to a context problem (which more people can assist 
with in the Core or REBOL2 groups).
jack-ort
26-Feb-2010
[8655]
Ashley - thanks for pointing me in the right direction!
Claude
10-Mar-2010
[8656x2]
hi, rebgui 1.1.8 don't work with rebol 2.7.7 for linux !!!!! segment 
fault !!!!
ashley, do you have a fixe for it , regards
Graham
10-Mar-2010
[8658]
Isn't the issue with 2.7.7 linux
Claude
10-Mar-2010
[8659x4]
for windows no problem
rebol 2.7.7 + rebgui 1.1.8 + my program  => no problem
rebol 2.7.7 linux + regbui 1.18 + tour.r of rebgui => segment fault 
!!!!!
i use a mint based on ubuntu 8.10 !!!!
Graham
10-Mar-2010
[8663]
It's a linux build issue ... keep using 2.7.6
Claude
10-Mar-2010
[8664]
oki thanks
Graham
10-Mar-2010
[8665x2]
check the linux group here
Gabriele mentions a segm. fault
Gabriele
10-Mar-2010
[8667]
If RebGUI is using draw, that would confirm what I'm seeing here 
as well. Must say that I'm using Mint as well, so this still does 
not rule out that it is a distribution specific issue (as other people 
reported it working).
Henrik
10-Mar-2010
[8668]
Gabriele, could you try the style browser for the vid extension kit, 
please? AFAIR there is little to no DRAW used in it.


do http://97.107.135.89/www.hmkdesign.dk/data/projects/vid-ext-kit/downloads/style-browser.r
Andreas
10-Mar-2010
[8669x3]
vid-ext seems to work fine for me, using rebview 2.7.7 on ubuntu
(if that's any help)
the vid ext style browser works, that is
Henrik
10-Mar-2010
[8672]
Andreas, if rebgui fails on your setup, then there is possibly a 
DRAW issue.
Andreas
10-Mar-2010
[8673x3]
hm, let me see if i have something to test rebgui lying around
a small rebgui app of mine using build 93 of rebgui works just fine
and the rebgui demo app using build 117 from the viewtop also works 
fine
Henrik
10-Mar-2010
[8676]
if you didn't have problems before, then your setup is probably not 
the cause like in Claude's case.
Gabriele
11-Mar-2010
[8677]
Henrik: that seems to work fine. I haven't clicked all the styles, 
but most of them. I think that only DRAW crashes.
Henrik
11-Mar-2010
[8678]
Gabriele, ok. also try to simply click the first style and hold down 
the down cursor key. then you will scroll through all styles.