On Dec 4, 2007 9:17 AM, johnf <[EMAIL PROTECTED]> wrote:
>
> On Tuesday 04 December 2007 01:26:20 am Henning Hraban Ramm wrote:
> > > def _openDialog(self,evt):
> > > # need to receive the evt (in this case a click or Hit)
> > > evt.stop()
> > > theDialog=dabo.ui.dFileDialog(self)
> > > theDialog.show()
> > > if sys.platform == 'win32':
> > > myseperator = "\\" # someone should post why I
> > > needed two slashes
> > > else:
> > > myseperator = "/"
> >
> > You get the backslash simply this way:
> > >>> r'\' # this a raw Python string
> >
> > In a "normal" Python string, the backslash starts a control character like
> > \n for newline or \t for tabulator - and \\ for backslash.
> >
> > But just use os.sep instead of that myseparator distinction. Python does
> > that for you!
> > (I.e. os.sep is \ on Windows, / on Unices, : on MacOS Classic and maybe
> > something other on VMS...)
> >
> > > Run our form or any Dabo form and type a "control-d" (might be something
> > > different for the Mac).
> >
> > Every "Control" is a "Command" on the Mac, i.e. "Cmd-D" instead of
> > "Ctrl-D". (Mac keyboards also have a Ctrl key, but that' seldom used at all
> > and then mostly for accessing additional characters.)
> >
> > Greetlings,Hraban
>
> Thanks for the input and of course you are correct. You answered the question
> and more. You get an extra star. Not having a Mac I didn't realize the
> command key worked that way.
Also note that instead of combining things by yourself, you can use
the os.path.join function. It takes any number of arguments and will
automatically add in the right separator. Ex. os.path.join("usr",
"local", "MyDirectory", "MyFile") will spit back
"/usr/local/MyDirectory/MyFile" on Linux.
It you have to write some code that deals with files and directories,
you should never need an if statement checking for platform. Use the
Standard Library and you won't regret it.
Cheers,
Nate L.
_______________________________________________
Post Messages to: [email protected]
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/dabo-users/[EMAIL PROTECTED]