Author: JpoorRandP@aol.com
Posted: 2009-08-07 16:49:06 Link
Dabo folks:
I've gone through the dabo tutorials and constructed a few forms that
manipulate data in grids with parent-child relationships. Now I'd like to
attach some functions to buttons on the form. For example, if I have a parent
table with lots of entries, I'd like to add a "Find" button that lets the
user enter a key string, and then have the pointer moved to the matching
record before returning to the grid/form. I understand from some discussions
here that what I want to use is a dialog. I see how you can design a dialog
using the Class Designer.
But how do I call such a dialog from the Find button onHit method and have
the dialog return the value provided by the user?
General question: Is there a place that discusses these sorts of "how to"
issues?
I have found the API listing on dabodev.com, but I find I need more help.
I realize that understanding Python will help, and I am working on a
number of Python tutorials ...
Thanks,
Jonathan Poor
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
JpoorRandP@aol.com wrote:
> But how do I call such a dialog from the Find button onHit method and have
> the dialog return the value provided by the user?
def onHit_button1(self, evt):
dlg = MyDialog(self)
dlg.showModal()
ret_value = dlg.lookup.Value
dlg.release()
print ret_value
> General question: Is there a place that discusses these sorts of "how to"
> issues?
Have you seen the wiki? http://wiki.dabodev.com
Other than that, you found it here on the users list.
Paul
On Aug 7, 2009, at 3:49 PM, jpoorrandp@aol.com wrote:
> I've gone through the dabo tutorials and constructed a few forms that
> manipulate data in grids with parent-child relationships. Now I'd
> like to
> attach some functions to buttons on the form. For example, if I
> have a parent
> table with lots of entries, I'd like to add a "Find" button that
> lets the
> user enter a key string, and then have the pointer moved to the
> matching
> record before returning to the grid/form. I understand from some
> discussions
> here that what I want to use is a dialog. I see how you can design
> a dialog
> using the Class Designer.
Just in case you didn't know: incremental search is built into the
grid: click on any column and start typing. The grid will
automatically move to the first matching record.
Even if that isn't the exact interface you need, you can look at the
code for the 'runIncSearch' method of dGrid.py: it might coding your
custom search easier.
-- Ed Leafe
Author: JpoorRandP@aol.com
Posted: 2009-08-08 12:31:45 Link
In a message dated 8/7/2009 6:13:24 P.M. Eastern Daylight Time,
ed@leafe.com writes:
Just in case you didn't know: incremental search is built into the
grid: click on any column and start typing. The grid will
automatically move to the first matching record.
Even if that isn't the exact interface you need, you can look at the
code for the 'runIncSearch' method of dGrid.py: it might coding your
custom search easier.
-- Ed Leafe
I did notice the incremental searching. I found dGrid.py in the
dabo\ui\uiwx directory, and will take a look, thanks. We may well decide that we
don't need a find button for some applications.
What I'm really after is how to piece together an application. We're
longtime VFP programmers, and what I'm trying to figure out is very basic: how
to call one form from another, using your Class Designer. In VFP, the click
method of a button will call another form with "do form FindRun" and then
the FindRun form can process user input and move the pointer in a cursor or
table that's in a grid on the calling form. The find function is just an
example, the approach would be the same for other functions, such as buttons
for "Export Results" or "Revise Status"
Jonathan Poor
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
On Saturday 08 August 2009 09:31:45 am JpoorRandP@aol.com wrote:
> What I'm really after is how to piece together an application. We're =A0
> longtime VFP programmers, and what I'm trying to figure out is very basic:
> how =A0 to call one form from another, using your Class Designer. In VFP,=
the
> click method of a button will call another form with "do form FindRun" and
> then the =A0FindRun form can process user input and move the pointer in a
> cursor or table =A0that's in a grid on the calling form. The find functio=
n is
> just an example, the =A0approach would be the same for other functions, s=
uch
> as buttons for "Export =A0Results" or "Revise Status"
Larry and I are doing the same thing (we are VFP'ers). We use a table that=
=20
contain metadata (maybe the required select statement to retreive the corre=
ct=20
data associated with the request). I have a screencast that has a few=20
examples of the find button. But there is no code. I just display a grid=
=20
with the data and the user selects the record and I requery the mainform wi=
th=20
the selected pk. Not very fancy but works well.
Nate has a lookup, and I'm sure Paul does too. =20
I think someone earlier pointed out how to call a form and get the return=20
value. It works the same way for buttons or any other need that will call =
a=20
form or dialog.
Johnf
On Aug 8, 2009, at 11:31 AM, jpoorrandp@aol.com wrote:
> What I'm really after is how to piece together an application. We're
> longtime VFP programmers, and what I'm trying to figure out is very
> basic: how
> to call one form from another, using your Class Designer. In VFP,
> the click
> method of a button will call another form with "do form FindRun" and
> then
> the FindRun form can process user input and move the pointer in a
> cursor or
> table that's in a grid on the calling form. The find function is
> just an
> example, the approach would be the same for other functions, such
> as buttons
> for "Export Results" or "Revise Status"
In general, the "trick" is to use dialogs for these sorts of helper
forms, and use the fact that such modal dialogs stop the process that
called them until the dialog is either hidden or destroyed. You then
make sure that the ok/cancel buttons only *hide* the dialog, and not
close/destroy it. The calling code looks something like this:
dlg = MyDialogClass()
dlg.show()
# execution pauses here until the dialog is hidden
if dlg.Accepted:
# User clicked OK
result = dlg.someAttributeThatHoldsTheResult
self.doSomethingWithIt(result)
dlg.release()
The 'Accepted' property will be set to True when the user clicks
'OK'; otherwise, it is False. In your dialog code, you need to store
the user's input/selection into an attribute, or add a method to fetch
that value, so that the calling form can act on that value. And once
you have gotten the information from the dialog, you need to manually
call release() to destroy it.
Hope that gives you a general idea how to do this. If you have any
other questions, ask away!
-- Ed Leafe
Author: JpoorRandP@aol.com
Posted: 2009-08-08 13:00:38 Link
In a message dated 8/8/2009 12:48:57 P.M. Eastern Daylight Time,
ed@leafe.com writes:
In general, the "trick" is to use dialogs for these sorts of helper
forms, and use the fact that such modal dialogs stop the process that
called them until the dialog is either hidden or destroyed. You then
make sure that the ok/cancel buttons only *hide* the dialog, and not
close/destroy it. The calling code looks something like this:
dlg = MyDialogClass()
dlg.show()
# execution pauses here until the dialog is hidden
if dlg.Accepted:
# User clicked OK
result = dlg.someAttributeThatHoldsTheResult
self.doSomethingWithIt(result)
dlg.release()
The 'Accepted' property will be set to True when the user clicks
'OK'; otherwise, it is False. In your dialog code, you need to store
the user's input/selection into an attribute, or add a method to fetch
that value, so that the calling form can act on that value. And once
you have gotten the information from the dialog, you need to manually
call release() to destroy it.
Hope that gives you a general idea how to do this. If you have any
other questions, ask away!
-- Ed Leafe
Thanks, Ed, that's helpful. I do have some more questions! Paul also posted
some example code that parallels what you're saying:
def onHit_button1(self, evt):
dlg = MyDialog(self)
dlg.showModal()
ret_value = dlg.lookup.Value
dlg.release()
print ret_value
In this example, we have "dlg = MyDialog(self)" which instantiates your
MyDialog class as dlg. My question is how do I turn a dialog I've designed in
the class designer into a class that I can refer to in this way? I can't
seem to save the dialog form as anything but "cdxml" -- (why not as python
code?) -- I'm guessing there's a way to define the class using this cdxml
file? Is there a tool that will convert cdxml to python?
Thanks for you help!
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
Author: JpoorRandP@aol.com
Posted: 2009-08-08 13:11:01 Link
In a message dated 8/8/2009 12:46:58 P.M. Eastern Daylight Time,
jfabiani@yolo.com writes:
Larry and I are doing the same thing (we are VFP'ers). We use a table
that
contain metadata (maybe the required select statement to retreive the
correct
data associated with the request). I have a screencast that has a few
examples of the find button. But there is no code. I just display a grid
with the data and the user selects the record and I requery the mainform
with
the selected pk. Not very fancy but works well.
Thanks Johnf, I'd like to see that. Is this "screencast" on the dabodev
site?
Jonathan
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
On Aug 8, 2009, at 12:00 PM, jpoorrandp@aol.com wrote:
> In this example, we have "dlg = MyDialog(self)" which instantiates
> your
> MyDialog class as dlg. My question is how do I turn a dialog I've
> designed in
> the class designer into a class that I can refer to in this way?
The class is created dynamically from the cdxml; the way to do this is:
dlg = dabo.ui.createForm("mydialog.cdxml", self)
You call createForm with the path to the dialog file (it will find it
if you have it in the 'ui' folder and use the standard directory
structure), and include any parameters you need to pass after the file
name.
> I can't
> seem to save the dialog form as anything but "cdxml" -- (why not
> as python
> code?)
Because generated code is evil and hackish. It is also not re-
entrant: once you generate the code, you can no longer edit it with
the designer tool.
> -- I'm guessing there's a way to define the class using this cdxml
> file? Is there a tool that will convert cdxml to python?
Not permanently; it is much, much better to do this dynamically using
createForm()
-- Ed Leafe
On Saturday 08 August 2009 10:11:01 am JpoorRandP@aol.com wrote:
> In a message dated 8/8/2009 12:46:58 P.M. Eastern Daylight Time,
> jfabiani@yolo.com writes:
>
> Larry and I are doing the same thing (we are VFP'ers). We use a table
> that
> contain metadata (maybe the required select statement to retreive the
> correct
> data associated with the request). I have a screencast that has a few
> examples of the find button. But there is no code. I just display a grid
> with the data and the user selects the record and I requery the mainform
> with
> the selected pk. Not very fancy but works well.
>
>
>
> Thanks Johnf, I'd like to see that. Is this "screencast" on the dabodev
> site?
>
> Jonathan
http://cdn.cloudfiles.mosso.com/c129431/realworlddabo.html
It's not much but it does demo a realworld app. We haven't changed it much as
of today.
I'm not sure why the link went to the above address but it was working.
Johnf