Re: [Tutor] save configuration of one application.
On Wednesday 04 October 2006 11:54, John Fouhy wrote: > On 04/10/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > > you can make a config.ini file and use that one module that parses ini > > files. > > I can't remember what it's called. > > configparser I think, but I wouldn't bet my life on it :) > > Yes, ConfigParser. > > The docs for ConfigParser are a bit confusing in places (IMO), but > there are people here who can help if you get stuck. > > > Or you could just write the settings out to a file. > > Using ConfigParser means your configuratino files will be > human-readable and human-editable. If you don't care about that, you > could stick them in a dictionary and use pickle to write it to a file. > Or use the shelve module. > > > If you choose to go the latter route, keep in mind that modules are > > compiled to .pyc files upon importation, > > so you'll have to remove those anytime you modify config.py or the old > > code will be used instead. > > The python interpreter should check the timestamps on foo.py vs > foo.pyc, and recompile if it thinks things have changed. Thank both of you. I'd have added some points about it. I used PyQt for designing GUI. Hence, in this case, I want to open a Font Dialog box in order to choose fontname, size and so on. Then set all these values to the textEdit. For the secode time we open the font dialog, the previous selected font will be set to the font family and font size of the font dialog. Is there any way to do it? Thanks again, da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] save configuration of one application.
On 04/10/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > you can make a config.ini file and use that one module that parses ini > files. > I can't remember what it's called. > configparser I think, but I wouldn't bet my life on it :) Yes, ConfigParser. The docs for ConfigParser are a bit confusing in places (IMO), but there are people here who can help if you get stuck. > Or you could just write the settings out to a file. Using ConfigParser means your configuratino files will be human-readable and human-editable. If you don't care about that, you could stick them in a dictionary and use pickle to write it to a file. Or use the shelve module. > If you choose to go the latter route, keep in mind that modules are > compiled to .pyc files upon importation, > so you'll have to remove those anytime you modify config.py or the old > code will be used instead. The python interpreter should check the timestamps on foo.py vs foo.pyc, and recompile if it thinks things have changed. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] save configuration of one application.
hok kakada wrote: > Hi, > > Can anybody guide me how to write the code for configure one application? > For example, I want to set Font and Color for a textbox; later when the > application is opened again. the previous font is set. > > So, which related function are used to form this feature? > you can make a config.ini file and use that one module that parses ini files. I can't remember what it's called. configparser I think, but I wouldn't bet my life on it :) Or you could just write the settings out to a file. Even better, if you're not making a real-world application and/or you can trust your users not to muck around with stuff, just make all your settings in a class in a module you import. Eg: # config.py class Settings(object): font = 'Veranda' color = 'Black' #- program.py from config import Settings print Settings.color # Hope that makes sense. If you choose to go the latter route, keep in mind that modules are compiled to .pyc files upon importation, so you'll have to remove those anytime you modify config.py or the old code will be used instead. -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor