On Tuesday 16 January 2007 11:20, Nate Lowrie wrote: > On 1/16/07, johnf <[EMAIL PROTECTED]> wrote: > > On Tuesday 16 January 2007 10:50, Nate Lowrie wrote: > > > On 1/16/07, johnf <[EMAIL PROTECTED]> wrote: > > > > On Tuesday 16 January 2007 10:15, Nate Lowrie wrote: > > > > > On 1/16/07, johnf <[EMAIL PROTECTED]> wrote: > > > > > > On Tuesday 16 January 2007 09:50, Paul McNett wrote: > > > > > > > johnf wrote: > > > > > > > > That works - now what if I want the dialog form class to be > > > > > > > > universally available to all forms? > > > > > > > > > > > > > > Then you break it out into a MyDialog.py file, contents like: > > > > > > > > > > > > > > import dabo > > > > > > > > > > > > > > class MyDialog(dabo.ui.dDialog): > > > > > > > ... > > > > > > > > > > > > > > You put the MyDialog.py file somewhere accessible to your forms > > > > > > > (same directory for simplicity is better. This is why I like > > > > > > > the AppWizard's ui/ directory). Then where you want to use it, > > > > > > > do: > > > > > > > > > > > > > > import MyDialog > > > > > > > dlg = MyDialog.MyDialog(...) > > > > > > > dlg.showModal() > > > > > > > > > > > > So I gather that it's OK to have multiple import statements of > > > > > > the same import everywhere. In VFP an universal function, > > > > > > procedure or class would be loaded at the beginning of an app. > > > > > > > > > > > > Set procedure to someProcedure or > > > > > > set classlib to someclass additive > > > > > > > > > > The import statement would be the equivalent of that. Also > > > > > consider brushing up on Python Classes and how they are > > > > > instantiated into objects. > > > > > > > > > > > I have no need to add something like above? > > > > > > > > > > > > -- > > > > > > John Fabiani > > > > > > > > No doubt I need to review most of Python. > > > > > > > > But I would have thought that I would create a file which contained > > > > my classes and import it at the beginning. > > > > > > > > import dabo > > > > import johnsClasses > > > > > > > > Then within a form I could say something like > > > > new_frm = johnsClasses.MydialogClass() #if this wrong say so please > > > > new_frm.show() > > > > > > > > I was sure I was right - but it does not work. I'm missing something > > > > or coding something wrong. > > > > > > Sounds right. You are doing what we suggested. Can you provide a > > > stack trace or something to help us help you? > > > > > > > -- > > > > John Fabiani > > > > > > > > _______________________________________________ > > > > Post Messages to: [email protected] > > > > Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev > > > > > > _______________________________________________ > > > Post Messages to: [email protected] > > > Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev > > > > OK I'm back where I started. I'm again asking how to call a form class > > from within form function. But below is the app. > > import os > > import inspect > > import dabo > > I think you need a "dabo.ui.loadUI('wx')" right here. > > > import johnClasses > > > > > > def main(): > > app = dabo.dApp() > > curdir = os.getcwd() > > # Get the current location's path > > fname = inspect.getfile(main) > > pth = os.path.split(fname)[0] > > if pth: > > # Switch to that path > > os.chdir(pth) > > app.MainFormClass = "custfrm1.cdxml" > > app.start() > > > > # Return to the original location > > os.chdir(curdir) > > > > > > if __name__ == '__main__': > > main() > > > > A function in the form > > def lookup(): > > new_frm = johnClasses.TestForm() > > new_frm.showModal() > > > > The traceback: > > Traceback (most recent call last): > > File "/home/johnf/downloads/dabo/dabo/lib/eventMixin.py", line 97, in > > raiseEvent > > bindingFunction(event) > > File "", line 971, in onHit > > File "/tmp/tmpfJx8q2.py", line 13, in onHit_1 > > self.Form.lookup() > > File "", line 949, in lookup > > File "/tmp/tmpfJx8q2.py", line 99, in lookup_3 > > new_frm = johnClasses.TestForm() > > NameError: global name 'johnClasses' is not defined > > Ed, Paul, thoughts on this....I was inclined to say that johnClasses > was not in the right directory, but then I saw the stack trace. If it > couldn't find the py file, it would traceback on the import statement. > > Could it possibly be something with the cdxml file? I have not used > these yet.....If I had to take a gander, I would say that you imported > johnClasses in the main file, but it is trying to access the > johnClasses class from a different file, which doesn't recognize the > import from the main. Paul, can you put import statements in the > cdxml file? > > This is why I like coding by hand........... > I believe it loses the johnClasses when the "app.setup" completes. In johnClasses I have import dabo dabo.ui.loadUI("wx") class TestForm(dabo.ui.dForm): def afterInit(self): # Set the caption self.Caption = "Hello, Dabo users!" # instantiate a textbox as a child of the dForm: tb = self.addObject(dabo.ui.dTextBox, "tbox") but = self.addObject(dabo.ui.dButton, RegID="but", Caption="Launch new form", Top=42, Width=150) # We can address the textbox directly... tb.Value = "Cool stuff!" # ...or in the containership hierarchy! self.tbox.FontBold = True
Help me I have fallen and can't use Dabo correctly! -- John Fabiani _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
