Initialization Files

Hi Everyone

I am wondering how is the best way in wxPython to manage initialization files. Is there any module that would do that easily?

Sorry for the basic questions.

Thanks in advance

Paulo

Hi Paulo,

I am wondering how is the best way in wxPython to manage initialization files. Is there any module that would do that easily?

Sorry, I'm not sure what you mean by initialization files...? (maybe it's just me). Do you mean a file that contains settings for the program? If this is the case you may want to look into the ConfigParser built in module. This allows an easy way to access files in a structure such as:

[config_section]
option1="foo"
option2="bar"

HTH,

Regards,
Wayne

Paulo Nuin wrote:

Hi Everyone

I am wondering how is the best way in wxPython to manage initialization files. Is there any module that would do that easily?

Well I don't know the answer (yet), so I'm curious to solutions too :wink:
In other languages I save the settings on destruction of a form and load settings on the creation of a form

Or do you mean, how to save / reload settings ?
Well as a windows guy, I usually use ini-files (not with the extension "ini" !!),
and the standard Python module is something like configparser, which sucks.
A better solution is ConfigObj, which works quit nice.
Coming from windows even this I find complicated, so I wrote a small wrapper,
making it even more easy than in my previous language (Delphi).

cheers,
Stef Mientki

···

Sorry for the basic questions.

Thanks in advance

Paulo

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Wayne Koorts wrote:

Hi Paulo,

I am wondering how is the best way in wxPython to manage initialization files. Is there any module that would do that easily?

Sorry, I'm not sure what you mean by initialization files...? (maybe it's just me). Do you mean a file that contains settings for the program? If this is the case you may want to look into the ConfigParser built in module. This allows an easy way to access files in a structure such as:

funny,
that some people find that easy :wink:
I wonder what your background is.

cheers,
Stef Mientki

I am wondering how is the best way in wxPython to manage initialization files. Is there any module that would do that easily?

Sorry, I'm not sure what you mean by initialization files...? (maybe it's just me). Do you mean a file that contains settings for the program? If this is the case you may want to look into the ConfigParser built in module. This allows an easy way to access files in a structure such as:

funny,
that some people find that easy :wink:
I wonder what your background is.

I'm a nuclear physicist. Just kidding. It's all relative. In this case I find it far easier to use ConfigParser than to write my own equivalent.

Regards,
Wayne

Wayne Koorts wrote:

I am wondering how is the best way in wxPython to manage initialization files. Is there any module that would do that easily?

Sorry, I'm not sure what you mean by initialization files...? (maybe it's just me). Do you mean a file that contains settings for the program? If this is the case you may want to look into the ConfigParser built in module. This allows an easy way to access files in a structure such as:

funny,
that some people find that easy :wink:
I wonder what your background is.

I'm a nuclear physicist. Just kidding. It's all relative. In this case I find it far easier to use ConfigParser than to write my own equivalent.

Well than you must be open-minded :wink:
so you should definitly take a look at ConfigObj.
cheers,
Stef

Wayne Koorts wrote:

Hi Paulo,

I am wondering how is the best way in wxPython to manage initialization files. Is there any module that would do that easily?

Sorry, I'm not sure what you mean by initialization files...? (maybe it's just me). Do you mean a file that contains settings for the program? If this is the case you may want to look into the ConfigParser built in module. This allows an easy way to access files in a structure such as:

There is also the wx.Config classes, which on Windows will by default use the registry, use INI-like files on unix-like systems in ~/.appname, and a file in ~/Library/Preferences on Mac.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

HI Everyone

The files I am intending to save, have the paths for some programs that are needed by the application.

Thanks a lot for all the suggestions.

Regards

Paulo

Robin Dunn wrote:

···

Wayne Koorts wrote:

Hi Paulo,

I am wondering how is the best way in wxPython to manage initialization files. Is there any module that would do that easily?

Sorry, I'm not sure what you mean by initialization files...? (maybe it's just me). Do you mean a file that contains settings for the program? If this is the case you may want to look into the ConfigParser built in module. This allows an easy way to access files in a structure such as:

There is also the wx.Config classes, which on Windows will by default use the registry, use INI-like files on unix-like systems in ~/.appname, and a file in ~/Library/Preferences on Mac.

Stef Mientki schrieb:

Paulo Nuin wrote:

Hi Everyone

I am wondering how is the best way in wxPython to manage initialization files. Is there any module that would do that easily?

Well I don't know the answer (yet), so I'm curious to solutions too :wink:
In other languages I save the settings on destruction of a form and load settings on the creation of a form

Or do you mean, how to save / reload settings ?
Well as a windows guy, I usually use ini-files (not with the extension "ini" !!),
and the standard Python module is something like configparser, which sucks.
A better solution is ConfigObj, which works quit nice.
Coming from windows even this I find complicated, so I wrote a small wrapper,
making it even more easy than in my previous language (Delphi).

cheers,
Stef Mientki

Sorry for the basic questions.

Thanks in advance

Paulo

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Hi,

what is wrong with a config class?

class Config(object):
    path = '/home/ralf'
    databaseFile = 'english.db'

This one can be imported with
from config import Config

Why are you using the ConfigObj or ConfigParser modules? What is their advantage?

Regards,
Ralf Schoenian

Ralf,

I use ConfigParser for the following reasons:

1) It's included in the default Python libraries
2) I don't have to "reinvent the wheel"
3) It creates a human readable "INI-like" file that can be edited by
anyone with half a brain
4) I think it's cross-platform
5) I don't have to store anything in the registry, which is something my
boss encourages
6) The code to manipulate it seems "Pythonic" (i.e. straightforward) to me

My two cents...

Mike

···

-----Original Message-----
From: Ralf Schönian [mailto:ralf@schoenian-online.de]
Sent: Tuesday, October 16, 2007 10:43 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] Initialization Files

Stef Mientki schrieb:
>
>
> Paulo Nuin wrote:
>> Hi Everyone
>>
>> I am wondering how is the best way in wxPython to manage
>> initialization files. Is there any module that would do
that easily?
>>
> Well I don't know the answer (yet), so I'm curious to solutions too
> :wink: In other languages I save the settings on destruction of a form
> and load settings on the creation of a form
>
> Or do you mean, how to save / reload settings ?
> Well as a windows guy, I usually use ini-files (not with
the extension
> "ini" !!), and the standard Python module is something like
> configparser, which sucks.
> A better solution is ConfigObj, which works quit nice.
> Coming from windows even this I find complicated, so I
wrote a small
> wrapper, making it even more easy than in my previous language
> (Delphi).
>
> cheers,
> Stef Mientki
>
>
>> Sorry for the basic questions.
>>
>> Thanks in advance
>>
>> Paulo

>
Hi,

what is wrong with a config class?

class Config(object):
    path = '/home/ralf'
    databaseFile = 'english.db'

This one can be imported with
from config import Config

Why are you using the ConfigObj or ConfigParser modules? What
is their advantage?

Regards,
Ralf Schoenian

Ralf,

I use ConfigParser for the following reasons:

1) It's included in the default Python libraries
  

Good reason, ConfigObj is not

2) I don't have to "reinvent the wheel"
  

Me neither

3) It creates a human readable "INI-like" file that can be edited by
anyone with half a brain
  

No, complex ini files manipulated with ConfigParser are not readable by the user,
moreover case sensitive of keys is lost (not very Pythonic :wink:
ConfigObj remains perfectly readable and casesensitivity is completely preserved.

4) I think it's cross-platform
  

I think ConfigObj is too

5) I don't have to store anything in the registry, which is something my
boss encourages
  

Very good !

6) The code to manipulate it seems "Pythonic" (i.e. straightforward) to me

In ConfigObj it's exactly the same.

7) When making fairly innocent program mistakes in ConfigParser,
you can loose the complete contents of the ini-files,
which won't happen with ConfigObj.

8) don't use "ini" as the file-extension, yields for both packages

cheers,
Stef Mientki

···

My two cents...

Mike