Re: [dabo-users] To get the '#!/usr/bin/python' line in the first line of myApp.py

Author: Ed Leafe

Posted: 2012-08-03 at 07:53:55

On Aug 3, 2012, at 4:06 AM, Csanyi Pal wrote:

> I wish to get automatically (or by setup in the Dabo Class Designer) the

> line:

>

> #!/usr/bin/python

>

> in the first line of the application so I can run it just by clicking

> on the myApp.py filename, or just by running it in its directory by the

> command:

>

> ./myApp.py

>

> At present this behavior can't one get in Dabo Class Designer, right?

The Class Designer creates classes, not entire applications. Normally you would start an application by running Dabo's quickStart:

[ed@MGM6AEDV7M ~/projects]$ python

Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01)

[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import dabo

>>> dabo.quickStart()

Enter the name for your application: testing

Application 'testing' has been created for you

>>>

This has now created a skeleton application called 'testing'. If you look at the directory listing you will see the following:

[ed@MGM6AEDV7M ~/projects]$ cd testing

[ed@MGM6AEDV7M ~/projects/testing]$ ll

total 8

drwxr-xr-x 3 ed staff 102B Aug 3 07:49 biz

drwxr-xr-x 3 ed staff 102B Aug 3 07:49 cache

drwxr-xr-x 3 ed staff 102B Aug 3 07:49 db

drwxr-xr-x 3 ed staff 102B Aug 3 07:49 lib

-rwxr--r-- 1 ed staff 282B Aug 3 07:49 main.py

drwxr-xr-x 3 ed staff 102B Aug 3 07:49 reports

drwxr-xr-x 3 ed staff 102B Aug 3 07:49 resources

drwxr-xr-x 3 ed staff 102B Aug 3 07:49 test

drwxr-xr-x 3 ed staff 102B Aug 3 07:49 ui

The script that launches the app is 'main.py', and it looks like this:

[ed@MGM6AEDV7M ~/projects/testing]$ cat main.py

#!/usr/bin/env python

# -*- coding: utf-8 -*-

import dabo

dabo.ui.loadUI("wx")

app = dabo.dApp()

# IMPORTANT! Change app.MainFormClass value to the name

# of the form class that you want to run when your

# application starts up.

app.MainFormClass = dabo.ui.dFormMain

app.start()

[ed@MGM6AEDV7M ~/projects/testing]$

Note that it has the #! line at the top. Now all you need to do is design your main form in the Class Designer, and then change the next-to-last line of main.py to the name of the cdxml file containing your main form.

-- Ed Leafe

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/1F9B3E5E-5487-476A-A9E4-DE6924CA141B@leafe.com

©2012 Ed Leafe