Skip to content
Advertisement

How do I make Python remember settings?

I wrote the beautiful python example code below. Now how do I make it so when I exit then restart the program it remembers the last position of the scale?

JavaScript

Edit:

I tried the following code

JavaScript

But get the following error

JavaScript

Advertisement

Answer

Write the scale value to a file and read it in on startup. Here’s one way to do it (roughly),

JavaScript

Obviously you could make it more robust/intricate/complicated if, for instance, you want to save and restore additional values.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement