Author: haakeyar
If you run pyPenNotes without a .penNotes.strokes_data-file, the pyPenNotes.pen_notes[] list is emptied in pyPenNotes.load(). This gives various unexpected behaviour, including not being able to save the notes you created. git-svn-id: http://www.neo1973-germany.de/svn@66 46df4e5c-bc4e-4628-a0fc-830ba316316d
This commit is contained in:
parent
512b36e1ac
commit
dbf974b473
1 changed files with 40 additions and 38 deletions
|
@ -399,10 +399,7 @@ class pyPenNotes:
|
||||||
|
|
||||||
data_file_name = os.path.expanduser(DATA_FILE)
|
data_file_name = os.path.expanduser(DATA_FILE)
|
||||||
|
|
||||||
if not os.path.exists(data_file_name):
|
if os.path.exists(data_file_name):
|
||||||
print "No notebook file found - using an empty one."
|
|
||||||
return
|
|
||||||
|
|
||||||
file_fd = open(data_file_name, 'r')
|
file_fd = open(data_file_name, 'r')
|
||||||
try:
|
try:
|
||||||
for line in file_fd.read().split('\n'):
|
for line in file_fd.read().split('\n'):
|
||||||
|
@ -438,13 +435,18 @@ class pyPenNotes:
|
||||||
self.pen_notes.append(self.current_note)
|
self.pen_notes.append(self.current_note)
|
||||||
finally:
|
finally:
|
||||||
file_fd.close()
|
file_fd.close()
|
||||||
|
else:
|
||||||
|
print "No notebook file found - using an empty one."
|
||||||
|
count += 1
|
||||||
|
self.current_note = PenNote()
|
||||||
|
self.pen_notes.append(self.current_note)
|
||||||
|
|
||||||
print "count: %s, current: %s" %(count, self.current_note_number)
|
print "count: %s, current: %s" %(count, self.current_note_number)
|
||||||
if count <= self.current_note_number:
|
if count <= self.current_note_number:
|
||||||
print "Sorry there is no note %4.4d left bringing you to note 0001"
|
print "Sorry there is no note %4.4d left bringing you to note 0001" % (count + 1) # Count is zero-indexed, while what is displayed to the user is not
|
||||||
self.current_note_number = 0
|
self.current_note_number = 0
|
||||||
self.next_note(None)
|
self.next_note(None) # Update the note number box
|
||||||
self.prev_note(None)
|
self.prev_note(None) #
|
||||||
|
|
||||||
self.current_note = self.pen_notes[self.current_note_number]
|
self.current_note = self.pen_notes[self.current_note_number]
|
||||||
self.redraw()
|
self.redraw()
|
||||||
|
|
Loading…
Reference in a new issue