473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

saving settings

Hi,

I was wondering how to make a single .exe file, say some kind od clock,
and be able to save some settings (alarm for example) into the same
file? Basically make code rewrite it self...

thanks!
May 29 '06 #1
11 1409
aum
On Mon, 29 May 2006 09:05:36 +0200, SuperHik wrote:
Hi,

I was wondering how to make a single .exe file, say some kind od clock,
and be able to save some settings (alarm for example) into the same
file? Basically make code rewrite it self...

thanks!


Yikes!!!

I'd strongly suggest you read the doco for ConfigParser, and load/save
your config file to/from os.path.join(os.path.expanduser("~")).

Another option - save your stuff in the Windows Registry

--

Cheers
aum
May 29 '06 #2
aum wrote:
On Mon, 29 May 2006 09:05:36 +0200, SuperHik wrote:
Hi,

I was wondering how to make a single .exe file, say some kind od clock,
and be able to save some settings (alarm for example) into the same
file? Basically make code rewrite it self...

thanks!


Yikes!!!

I'd strongly suggest you read the doco for ConfigParser, and load/save
your config file to/from os.path.join(os.path.expanduser("~")).

Another option - save your stuff in the Windows Registry


but if I copy this file on the other computer settings will be lost...
May 29 '06 #3
SuperHik wrote:
aum wrote:
On Mon, 29 May 2006 09:05:36 +0200, SuperHik wrote:
Hi,

I was wondering how to make a single .exe file, say some kind od clock,
and be able to save some settings (alarm for example) into the same
file? Basically make code rewrite it self...

thanks!


Yikes!!!

I'd strongly suggest you read the doco for ConfigParser, and load/save
your config file to/from os.path.join(os.path.expanduser("~")).

Another option - save your stuff in the Windows Registry


but if I copy this file on the other computer settings will be lost...


It _might_ come as a shock to you, but when you install e.g. Word on another
computer, there aren't any documents coming with it. Especially not the
ones you wrote on that other machine.

Seriously: Who is going to copy a executable around? Do you know of any
other program that behaves like that?

Diez
May 29 '06 #4
SuperHik wrote:
aum wrote:
On Mon, 29 May 2006 09:05:36 +0200, SuperHik wrote:
Hi,

I was wondering how to make a single .exe file, say some kind od clock,
and be able to save some settings (alarm for example) into the same
file? Basically make code rewrite it self...

thanks!


Yikes!!!

I'd strongly suggest you read the doco for ConfigParser, and load/save
your config file to/from os.path.join(os.path.expanduser("~")).

Another option - save your stuff in the Windows Registry


but if I copy this file on the other computer settings will be lost...


Put your program in a writable folder and save configuration right into
that folder. Then your can transfer the whole folder. Tip: sys.path[0]
always contains the path to the directory where "__main__" module is
located.

May 29 '06 #5
Diez B. Roggisch wrote:
SuperHik wrote:
aum wrote:
On Mon, 29 May 2006 09:05:36 +0200, SuperHik wrote:

Hi,

I was wondering how to make a single .exe file, say some kind od clock,
and be able to save some settings (alarm for example) into the same
file? Basically make code rewrite it self...

thanks!
Yikes!!!

I'd strongly suggest you read the doco for ConfigParser, and load/save
your config file to/from os.path.join(os.path.expanduser("~")).

Another option - save your stuff in the Windows Registry
but if I copy this file on the other computer settings will be lost...


It _might_ come as a shock to you, but when you install e.g. Word on another
computer, there aren't any documents coming with it. Especially not the
ones you wrote on that other machine.

that doesn't shock me :p
anyway you're talking about instalation while I'm talkig about single
standalone file.
Besides, if it was neccessary I bet MS would make that option (and it
wouldn't be a problem since installation is not done from a sinlge file
but from the CD (should be CD-RW in that case) with lots of files and
directories so they'd create just another directory on the installation
CD, say \All Documents\ )
Seriously: Who is going to copy a executable around? Obviously I am. :D
Do you know of any other program that behaves like that? No, but for most programs I used I never bothered to check where did
they put their settings.
That's just the thing, I'm not a professional programmer so I was
wondering is it possible to do it, and if it is how much trouble would
it be. If nothing I will just make a config file right next to the
executable..
Diez

thanks!
May 29 '06 #6
> that doesn't shock me :p
anyway you're talking about instalation while I'm talkig about single
standalone file.
Besides, if it was neccessary I bet MS would make that option (and it
wouldn't be a problem since installation is not done from a sinlge file
but from the CD (should be CD-RW in that case) with lots of files and
directories so they'd create just another directory on the installation
CD, say \All Documents\ )


But that is a folder then. Go put your config-file & program in a folder,
and copy it.

Seriously: Who is going to copy a executable around?

Obviously I am. :D
Do you know of any
other program that behaves like that?

No, but for most programs I used I never bothered to check where did
they put their settings.
That's just the thing, I'm not a professional programmer so I was
wondering is it possible to do it, and if it is how much trouble would
it be. If nothing I will just make a config file right next to the
executable..


Nobody does it that way for a simple reason: lets say you stored some
config-information like an IP-address. Now moving your program somewhere
else makes that a wrong config option - and possibly your program crashes
even before you have the chance to _change_ that config setting. Now you
need either a fresh copy - or just edit/delete the config file. The latter
sounds better to me - and most probably quite a few others programmers.

Diez
May 29 '06 #7
On 2006-05-29, Diez B. Roggisch <de***@nospam.web.de> wrote:
It _might_ come as a shock to you, but when you install e.g.
Word on another computer, there aren't any documents coming
with it.
Documents and settings aren't quite the same thing, but it's a
valid point.
Especially not the ones you wrote on that other machine.

Seriously: Who is going to copy a executable around?
I do. I copy putty.exe around all of the time.
Do you know of any other program that behaves like that?


Back in the day, that used to be fairly common under
DOS/Windows. Not that it's still not a really bad idea.

--
Grant Edwards grante Yow! I'm wet! I'm wild!
at
visi.com
May 29 '06 #8
aum
On Mon, 29 May 2006 09:05:36 +0200, SuperHik wrote:
Hi,

I was wondering how to make a single .exe file, say some kind od clock,
and be able to save some settings (alarm for example) into the same
file? Basically make code rewrite it self...

thanks!


Another option I thought of:
- get the Nullsoft NSIS installer
- write a Python wrapper to NSIS if desired
- within your app, include:
- embedded py2exe
- embedded/wrapped NSIS
- within your app offer a menu option to 'export this
program', which changes data files as needed, then invokes
py2exe and NSIS to create a whole new installer exe

That way, you'd have what you're after - a way to distribute your app,
including its current state, as a single EXE file. Also, it would have the
advantage of this EXE being an installer which sets up start menu
shortcuts.

--

Cheers
aum
May 29 '06 #9
Grant Edwards wrote:

Documents and settings aren't quite the same thing, but it's a
valid point.
Especially not the ones you wrote on that other machine.

Seriously: Who is going to copy a executable around?


I do. I copy putty.exe around all of the time.


I download it every time, and if I didn't, I'd be pretty annoyed if I'd copy
it to a friends machine containing ALL MY KEYS embedded into it.
Do you know of any other program that behaves like that?


Back in the day, that used to be fairly common under
DOS/Windows. Not that it's still not a really bad idea.


Back in the day self-modifying code was the craze too. And _some_ people
even do it in python :)

Diez
May 30 '06 #10
Diez B. Roggisch wrote:
Grant Edwards wrote:

Documents and settings aren't quite the same thing, but it's a
valid point.
Especially not the ones you wrote on that other machine.

Seriously: Who is going to copy a executable around? I do. I copy putty.exe around all of the time.


I download it every time, and if I didn't, I'd be pretty annoyed if I'd copy
it to a friends machine containing ALL MY KEYS embedded into it.
Do you know of any other program that behaves like that?

Back in the day, that used to be fairly common under
DOS/Windows. Not that it's still not a really bad idea.


Back in the day self-modifying code was the craze too. And _some_ people
even do it in python :)

those crazy bastards! ;)
Diez

May 30 '06 #11
Ten
On Monday 29 May 2006 12:28, SuperHik wrote:
aum wrote:
On Mon, 29 May 2006 09:05:36 +0200, SuperHik wrote:
Hi,

I was wondering how to make a single .exe file, say some kind od clock,
and be able to save some settings (alarm for example) into the same
file? Basically make code rewrite it self...

thanks!


Yikes!!!

I'd strongly suggest you read the doco for ConfigParser, and load/save
your config file to/from os.path.join(os.path.expanduser("~")).

Another option - save your stuff in the Windows Registry


but if I copy this file on the other computer settings will be lost...


A pretty standard behaviour in this context is to have your program create
its own config file if it's absent, say on first run, per user, or if it's
copied to a new machine.

Just do it using whatever defaults are in the python file itself.

Regards,

Ten.
--
There are 10 types of people in this world,
those who understand binary, and those who don't.
May 31 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: MLH | last post by:
GHudson has working procedures posted at http://www.access-programmers.co.uk/forums/showthread.php?t=66320 They work. Relationships, however, and some minor default settings are not preserved....
3
by: Marco Roberto | last post by:
Hi, does anybody what is the best format to save particular system settings (ex: Default path to save files, etc) in .Net (XML, ini files, or registry)? Best Regards, Marco
7
by: timb | last post by:
Hi, is it possible to access the properties of a class or structure in a for each statement? I want to iterate through the stirng properties in my class or structure and then write them away to...
4
by: Kourosh | last post by:
I have a log file that is viewed on the local machine. There are some settings on the html page that allow the user to specify how the file is viewed. I'm just wnodering what are my options in...
4
by: Bill Nguyen | last post by:
How can I detect timezone and whether daylight saving is applied on a client PC/server using VB.NET? Thanks Bill
2
by: Tal Shachar | last post by:
Hi, I have a windows application that needs to save some user preferences to an xml and to load it on the next application run. Saving the preferences is done per user. I know that there is a way...
0
by: =?Utf-8?B?VHJhY2tz?= | last post by:
Does the toolstripcontainer etc work at all? I want to save the settings for the toolstrip positions in my app so they start up with the saved positions. Tried using: ...
3
by: RobEveryThingIsPossible | last post by:
IN VISTA MS Access 2000 Printer Settings Not Saving With Vista Bus. The printer settings (Label or Env.) keep on change back to another setting after saving them on a report or form, when...
27
by: RobG | last post by:
I was investigating a function to determine whether daylight saving was being observed on a particular date (given the platform's regional settings) and came across a suggestion at merlyn.com to...
2
by: AGP | last post by:
VB.NET 2005 i was reading some of the documentation on saving settings and i think i have a good grasp on things with the My.Settings classes. I understand how to bind a control to a setting and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.