~jtaylor/ubuntu/oneiric/soya/fix-780305

« back to all changes in this revision

Viewing changes to editor/main.py

  • Committer: Bazaar Package Importer
  • Author(s): Marc Dequènes (Duck)
  • Date: 2005-01-30 09:55:06 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050130095506-f21p6v6cgaobhn5j
Tags: 0.9.2-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
 
import os, atexit, cPickle as pickle, soya, soya.soya3d as soya3d, soya.model as model, soya.editor, editobj, editobj.main, editobj.treewidget as treewidget
 
18
import os, atexit, cPickle as pickle, soya, soya.editor, editobj, editobj.main, editobj.treewidget as treewidget
19
19
from Tkinter import *
20
20
 
21
21
class Config(object):
22
 
  pathes = ("image_path", "material_path", "shape_path", "world_path")
23
22
  def __init__(self):
24
 
    self.image_path = self.material_path = self.shape_path = self.world_path = os.environ["HOME"]
 
23
    self.path = os.environ["HOME"]
25
24
    
26
25
  def apply(self):
27
 
    model .Image   .PATH = self.image_path
28
 
    model .Material.PATH = self.material_path
29
 
    model .Shape   .PATH = self.shape_path
30
 
    soya3d.World   .PATH = self.world_path
 
26
    soya.path = [self.path]
31
27
    
32
28
  def save(self, file = None):
33
29
    file = file or open(CONFIG_FILE, "w")
39
35
if os.path.exists(CONFIG_FILE):
40
36
  try:
41
37
    CONFIG = pickle.load(open(CONFIG_FILE))
 
38
    CONFIG.apply()
42
39
  except:
43
40
    import sys
44
41
    sys.excepthook(*sys.exc_info())
45
42
    print "Bugged config file (%s) -- I create a new one !" % CONFIG_FILE
46
43
    CONFIG = Config()
47
 
    #CONFIG.save()
 
44
    CONFIG.save()
 
45
    CONFIG.apply()
48
46
    
49
47
else:
50
48
  print "No config file -- I create a new one !"
51
49
  
52
50
  CONFIG = Config()
53
51
  CONFIG.save()
 
52
  CONFIG.apply()
54
53
  
55
 
CONFIG.apply()
56
54
 
57
55
atexit.register(CONFIG.save)
58
56
 
95
93
    CONFIG.apply()
96
94
    
97
95
  def new_material(self, event = None):
98
 
    editobj.edit(model.Material())
 
96
    editobj.edit(soya.Material())
99
97
    
100
98
  def new_world(self, event = None):
101
 
    editobj.edit(soya3d.World())
 
99
    editobj.edit(soya.World())
102
100
    
103
101
  def load(self, event = None):
104
102
    import tkFileDialog