/usr/share/pyshared/soya/editor/main.py is in python-soya 0.15~rc1-10.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | # -*- indent-tabs-mode: t -*-
# Soya 3D
# Copyright (C) 2001-2002 Jean-Baptiste LAMY
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os, atexit, cPickle as pickle, soya, soya.editor, editobj, editobj.main, editobj.treewidget as treewidget
from Tkinter import *
class Config(object):
def __init__(self):
self.path = os.environ["HOME"]
def apply(self):
soya.path = [self.path]
def save(self, file = None):
file = file or open(CONFIG_FILE, "w")
pickle.dump(self, file)
CONFIG_FILE = os.path.join(os.environ["HOME"], ".soya_editor")
if os.path.exists(CONFIG_FILE):
try:
CONFIG = pickle.load(open(CONFIG_FILE))
CONFIG.apply()
except:
import sys
sys.excepthook(*sys.exc_info())
print "Bugged config file (%s) -- I create a new one !" % CONFIG_FILE
CONFIG = Config()
CONFIG.save()
CONFIG.apply()
else:
print "No config file -- I create a new one !"
CONFIG = Config()
CONFIG.save()
CONFIG.apply()
atexit.register(CONFIG.save)
class App(Toplevel):
def __init__(self, extra_classes = ()):
# Get, or create if needed, the root Tk.
try:
from Tkinter import _default_root
tkroot = _default_root
except ImportError: pass
if not tkroot:
tkroot = Tk(className = "Soya Editor")
tkroot.withdraw()
menubar = Menu(tkroot)
file_menu = Menu(menubar, tearoff = 1)
file_menu.add_command(label = "New Material...", command = self.new_material)
file_menu.add_command(label = "New World..." , command = self.new_world)
for clazz in extra_classes:
file_menu.add_command(label = "New %s..." % clazz.__name__, command = lambda clazz = clazz: editobj.edit(clazz()))
file_menu.add_separator()
file_menu.add_command(label = "Load..." , command = self.load)
file_menu.add_command(label = "Quit" , command = self.quit)
menubar.add_cascade(label = "File", menu = file_menu)
Toplevel.__init__(self, tkroot, menu = menubar)
self.edit_config = editobj.main.EditPropertyFrame(self)
self.edit_config.edit(CONFIG)
self.edit_config.pack(fill = BOTH)
Button(self, text = "Apply", command = self.validate).pack()
self.wm_protocol("WM_DELETE_WINDOW", self.quit)
def validate(self, event = None):
self.focus_set()
CONFIG.apply()
def new_material(self, event = None):
editobj.edit(soya.Material())
def new_world(self, event = None):
editobj.edit(soya.World())
def load(self, event = None):
import tkFileDialog
s = tkFileDialog.askopenfilename()
if s:
obj = pickle.load(open(s, "rb"))
editobj.edit(obj)
def quit(self, event = None):
import sys
sys.exit()
|