Help with Panes
[1/4] from: martin::middleton::speechworks::com at: 21-Dec-2001 17:46
OK, I'm sure somebody has already asked this question before, but it's
beyond my simple mind. I'm trying to create a GUI where I click on a button
and it opens a pane. Within that pane is another button, that opens up
another pane. When I click on the "Done" button I want to get back to the
same state I was in at the beginning, but I can't make it work.
Any help is GREATLY appreciated!
REBOL [Title: "Pain with Panes"]
main: layout [
vh2 "Automated Software Manufacturing Build System"
guide
button "Setup Phase" [panels/pane: init_panel show panels]
button "Source Phase" [panels/pane: source_panel show panels]
button "Build Phase" [panels/pane: build_panel show panels]
button "Package Phase" [panels/pane: package_panel show panels]
button "Post Phase" [panels/pane: post_panel show panels]
button "Quit" [quit]
return
guide box 2x300 maroon
return
panels: box 400x300 coal
]
; Initialization Functionality
init_panel: layout [
origin 0x0
vh3 "Setup the Environment"
guide
button "Add" [init_panel/pane: init_add_panel show init_panel]
button "Remove" [init_panel/pane: init_remove_panel show init_panel]
button "Modify" [init_panel/pane: init_modify_panel show init_panel]
button "View All" [init_panel/pane: init_view_panel show init_panel]
return
guide box 2x200 blue
return
init_panel: box 300x300 gray
]
init_add_panel: layout [
vtext "Enter the name of a variable and"
vtext "the value you want to assign to it."
across
label "Name:" var-name: field return
label "Value:" var-value: field return
button "Enter"
button "Cancel"
button "Done"
return
below
vtext "Click Enter to create the variable"
vtext "Click Cancel to clear the entries"
vtext "Click Done when all variables have been created"
]
init_remove_panel: layout [
vh1 "TBD"
]
init_modify_panel: layout [
vh1 "TBD"
]
init_view_panel: layout [
vh1 "TBD"
]
; Source Functionality
source_panel: layout [
origin 0x0
vh3 "Source Phase"
]
build_panel: layout [
origin 0x0
vh3 "Building Phase"
]
package_panel: layout [
origin 0x0
vh3 "Packaging Phase"
]
post_panel: layout [
origin 0x0
vh3 "Post Phase"
]
init_panel/offset: 0x0
source_panel/offset: 0x0
build_panel/offset: 0x0
package_panel/offset: 0x0
post_panel/offset: 0x0
view main
- martin
[2/4] from: al:bri:xtra at: 22-Dec-2001 12:11
There's a tutorial on panes in the rebol site here:
http://www.rebol.com/how-to.html
and click on the Subpanels link.
I hope that helps!
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[3/4] from: sunandadh:aol at: 21-Dec-2001 18:29
Hi Nartin,
> OK, I'm sure somebody has already asked this question before, but it's
> beyond my simple mind. I'm trying to create a GUI where I click on a
button
> and it opens a pane. Within that pane is another button, that opens up
> another pane. When I click on the "Done" button I want to get back to the
> same state I was in at the beginning, but I can't make it work.
>
It looks to me like you've accidently redefined Init_panel. It goes a lot
further if you have another name for the other panel (eg Init_Panel1)
init_panel: layout [
origin 0x0
vh3 "Setup the Environment"
guide
button "Add" [init_panel1/pane: init_add_panel show init_panel]
button "Remove" [init_panel1/pane: init_remove_panel show init_panel]
button "Modify" [init_panel1/pane: init_modify_panel show init_panel]
button "View All" [init_panel1/pane: init_view_panel show init_panel]
return
guide box 2x200 blue
return
init_panel1: box 300x300 gray
]
(I've written an application that looks spookily similar to yours--mine isn't
source management, but there's something appealing about vertical button bars
in Rebol)
Sunanda.
[4/4] from: brett:codeconscious at: 22-Dec-2001 18:14
Hi,
As Sunanda has pointed out "init_panel" is redefined.
Once you fix this though you still need to deal with getting your initial
state back.
A simplistic approach would be that when the done button is pushed you
reverse the changes your other buttons made to that point.
Very simplistically you could do this for your current program:
(sub_panel is what I called your box within init_panel).
button "Done" [
panels/pane: sub_panel/pane: none
show panels
]
However, this is unlikely to be a concise/maintainable solution when your
program takes more shape. I posted it because it solves you immediate
question :)
You will probably want a more sophisticated approach to manage the panels.
Possibly the object! datatype will be handy when you structure your
solution. It is also handy to remember that Rebol script can be treated like
data so your program can build a "just in time" layout or other things when
it needs them.
It is a good problem. With your current structure it you could even encode
it in a block as a tree and have something automatically build and manage
the panels as required. It reminds me a bit of a wizard interface. You could
bind the commands to it later.
Just speculating :)
Brett.