Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /newedit/src/, /newedit/src/modules/

newedit
Discussion topic

Back to topic list

CVS update: /newedit/src/, /newedit/src/modules/

Reply

Author limodou
Full name limodou
Date 2004-05-09 08:01:59 PDT
Message User: limodou
Date: 04/05/09 08:01:58

Modified:
 /newedit/src/
  PrefDialog.py, Preference.py
 /newedit/src/modules/
  Pref.py, StatusBar.py, Toolbar.py, __init__.py

Log:
 Issue number:
 Obtained from:
 Submitted by:
 Reviewed by:

File Changes:

Directory: /newedit/src/
========================

File [changed]: PrefDialog.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/PrefDial​og.py?r1=1.1&r2=​1.2
Delta lines: +76 -30
---------------------
--- PrefDialog.py 8 May 2004 14:23:05 -0000 1.1
+++ PrefDialog.py 9 May 2004 15:01:53 -0000 1.2
@@ -1,49 +1,95 @@
 import wx
+import wx.lib.maskednumctrl
 import Preference
+import types
+import Mixin
 
-class PrefDialog(wx.Dialog):
- def __init__(self, parent):
- wx.Dialog.__init__(self, parent, -1, title="Preference...", size=wx.Size(600, 400), style=wx.DEFAULT_DIALOG_STYLE)
+class PrefDialog(wx.Dialog, Mixin.Mixin):
+ __mixinname__ = 'prefdialog'
 
- self.box1 = wx.BoxSizer(wx.VERTICAL)
+ def __init__(self, parent):
+ self.initmixin()
 
- self.box2 = wx.BoxSizer(wx.HORIZONTAL)
+ wx.Dialog.__init__(self, parent, -1, title="Preference...", size=wx.Size(600, 400), style=wx.DEFAULT_DIALOG_STYLE)
 
- self.box3 = wx.BoxSizer(wx.VERTICAL)
- label = wx.StaticText(self, -1, "Catalog")
- self.box3.Add(label, 0, wx.ALIGN_LEFT|wx.BOT​TOM|wx.LEFT, 2)
- self.tree = wx.TreeCtrl(self, -1, size=(150, 100), style=wx.TR_HAS_BUTTONS | wx.TR_HIDE_ROOT)
- self.addCatalog(self.tree)
- self.box3.Add(self.tree, 1, wx.EXPAND|wx.ALL)
- self.box2.Add(self.box3, 0, wx.EXPAND|wx.ALL, 5)
-
- self.box4 = wx.BoxSizer(wx.VERTICAL)
- self.notebook = wx.Notebook(self, -1, style=wx.CLIP_CHILDREN)
- self.panel = wx.Panel(self.notebook, -1, style=wx.CLIP_CHILDREN)
- self.notebook.AddPag​e(self.panel, 'test')
- self.box4.Add(self.notebook, 1, wx.EXPAND|wx.ALL)
- self.box2.Add(self.box4, 1, wx.EXPAND|wx.ALL, 5)
+ self.items = []
 
- self.box1.Add(self.box2, 1, wx.EXPAND|wx.ALL)
+ self.parent = parent
+ self.box1 = wx.BoxSizer(wx.VERTICAL)
+ self.notebook = wx.Notebook(self, -1)
+ self.addPages(self.notebook)
+ self.box1.Add(self.notebook, 1, wx.EXPAND|wx.ALL, 5)
 
         line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
- self.box1.Add(line, 0, wx.EXPAND|wx.ALIGN_C​ENTER_VERTICAL|wx.LE​FT|wx.RIGHT|wx.TOP, 5)
+ self.box1.Add(line, 0, wx.EXPAND|wx.LEFT|wx​.RIGHT|wx.TOP, 5)
 
- self.box5 = wx.BoxSizer(wx.HORIZONTAL)
+ self.box2 = wx.BoxSizer(wx.HORIZONTAL)
 
         self.btnok = wx.Button(self, wx.ID_OK, " OK ")
         self.btnok.SetDefault()
- self.box5.Add(self.btnok, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
+ self.box2.Add(self.btnok, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
         self.btncancel = wx.Button(self, wx.ID_CANCEL, " Cancel ")
- self.box5.Add(self.btncancel, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
+ self.box2.Add(self.btncancel, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
 
- self.box1.Add(self.box5, 0, wx.EXPAND|wx.ALL, 5)
+ self.box1.Add(self.box2, 0, wx.ALIGN_CENTER|wx.ALL, 5)
 
         self.SetSizer(self.box1)
         self.SetAutoLayout(True)
-# self.box1.Fit(self)
-
- def addCatalog(self, tree):
- self.root = tree.AddRoot('')
- tree.AppendItem(self.root, 'test1')
+ wx.EVT_BUTTON(self, wx.ID_OK, self.OnOk)
 
+ def addPages(self, notebook):
+ pages = []
+ for v in self.parent.pref.preflist:
+ pagename, order, kind, prefname, prefvalue, message, extern = v
+ prefvalue = getattr(self.parent.pref, prefname)
+ if pagename == '':
+ continue
+ if pages.count(pagename)==0:
+ page = wx.Panel(notebook, -1)
+ notebook.AddPage(page, pagename)
+ pages.append(pagename)
+ page.box = wx.BoxSizer(wx.VERTICAL)
+ page.SetSizer(page.box)
+ page.SetAutoLayout(True)
+ else:
+ page = notebook.GetPage(pag​es.index(pagename))
+ self.addItem(page, kind, prefname, prefvalue, message, extern)
+
+ def addItem(self, page, kind, prefname, prefvalue, message, extern):
+ if self.execplugin(self, page, type, prefname, prefvalue, message, extern):
+ return
+ if kind == 'check':
+ obj = wx.CheckBox(page, -1, message)
+ obj.SetValue(prefvalue)
+ self.items.append((prefname, obj.GetValue))
+ elif kind == 'num':
+ obj = wx.BoxSizer(wx.HORIZONTAL)
+ obj.Add(wx.StaticText(page, -1, message), 0, wx.ALIGN_CENTER_VERT​ICAL|wx.RIGHT, 10)
+ nc = wx.lib.maskednumctrl​.MaskedNumCtrl(page,​ value=prefvalue, integerWidth=5)
+ obj.Add(nc, 0)
+ self.items.append((prefname, nc.GetValue))
+ elif kind == 'choice':
+ obj = wx.BoxSizer(wx.HORIZONTAL)
+ obj.Add(wx.StaticText(page, -1, message), 0, wx.ALIGN_CENTER_VERT​ICAL|wx.RIGHT, 10)
+ cb = wx.ComboBox(page, -1, '', choices = extern, style = wx.CB_DROPDOWN)
+ obj.Add(cb, 0)
+ if types.IntType == type(prefvalue):
+ #cb.SetValue(cb.GetS​tring(prefvalue))
+ cb.SetSelection(prefvalue)
+ self.items.append((prefname, cb.GetSelection))
+ else:
+ cb.SetValue(prefvalue)
+ self.items.append((prefname, cb.GetValue))
+ elif kind == 'text':
+ obj = wx.BoxSizer(wx.HORIZONTAL)
+ obj.Add(wx.StaticText(page, -1, message), 0, wx.ALIGN_CENTER_VERT​ICAL|wx.RIGHT, 10)
+ tc = wx.TextCtrl(page, -1, prefvalue)
+ obj.Add(tc, 0)
+ self.items.append((prefname, tc.GetValue))
+ page.box.Add(obj, 0, wx.LEFT|wx.TOP|wx.RIGHT, 5)
+
+ def OnOk(self, event):
+ for name, func in self.items:
+ setattr(self.parent.pref, name, func())
+ self.parent.pref.save()
+ event.Skip()
\ No newline at end of file

File [changed]: Preference.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/Preferen​ce.py?r1=1.1&r2=​1.2
Delta lines: +18 -3
--------------------
--- Preference.py 8 May 2004 14:23:05 -0000 1.1
+++ Preference.py 9 May 2004 15:01:53 -0000 1.2
@@ -2,10 +2,17 @@
 import Debug
 import copy
 import pickle
+import os.path
 
 class Preference(Mixin.Mixin):
     __mixinname__ = 'preference'
- preflist = [('generic', 100, 'wildcard', 'All files (*.*)|*', None),
+ preflist = [
+ ('generic', 100, 'check', 'utf8_encoding_auto_detect', True, 'UTF-8 encoding auto detect', None),
+ ('generic', 200, 'num', 'int', 100, 'int value', None),
+ ('generic', 150, 'choice', 'select1', 'one', 'combox1', ['two', 'one', 'three']),
+ ('generic', 150, 'choice', 'select2', 3, 'combox2', ['two', 'one', 'three']),
+ ('generic', 300, 'text', 'name', 'limodou','enter your name', None),
+ ('HTML', 100, 'check', 'html', False, 'Html format', None),
     ]
     defaultfile = 'newedit.opt'
 
@@ -25,11 +32,19 @@
     def load(self, filename=''):
         if not filename:
             filename = self.defaultfile
+ if os.path.exists(filename):
         return pickle.load(open(filename))
+ else:
+ return self
 
     def initpref(self):
- for catalog, order, name, value, extern in self.preflist:
+ for catalog, order, kind, name, value, message, extern in self.preflist:
             setattr(self, name, value)
+ Preference.preflist.sort()
+
+ def printValues(self):
+ for catalog, order, kind, name, value, message, extern in self.preflist:
+ print name, getattr(self, name)
 
 if __name__ == '__main__':
     Debug.debuginit('out.txt')

Directory: /newedit/src/modules/
====================​============

File [changed]: Pref.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/modules/​Pref.py?r1=1.1&r​2=1.2
Delta lines: +6 -0
-------------------
--- Pref.py 8 May 2004 14:25:28 -0000 1.1
+++ Pref.py 9 May 2004 15:01:53 -0000 1.2
@@ -1,6 +1,7 @@
 import Mixin
 import wx
 import PrefDialog
+import Preference
 
 menulist = [ (0,
     [
@@ -12,6 +13,11 @@
     ]),
 ]
 Mixin.setMixin('mainframe', 'menulist', menulist)
+
+def initpreference(win):
+ pref = Preference.Preference()
+ win.pref = pref.load()
+Mixin.setPlugin('mainframe', 'init', initpreference)
 
 def OnOptionPreference(win, event):
     dlg = PrefDialog.PrefDialog(win)

File [changed]: StatusBar.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/modules/​StatusBar.py?r1=1.1​&r2=1.2
Delta lines: +1 -1
-------------------
--- StatusBar.py 8 May 2004 14:25:28 -0000 1.1
+++ StatusBar.py 9 May 2004 15:01:53 -0000 1.2
@@ -2,6 +2,6 @@
 import wx
 
 def init(win):
- win.statusbar = win.CreateStatusBar(3, style=wx.ST_SIZEGRIP, id=-1)
+ win.statusbar = win.CreateStatusBar(3)
     win.SetStatusWidths([-1, 60, 60])
 Mixin.setPlugin('mainframe', 'init', init)

File [changed]: Toolbar.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/modules/​Toolbar.py?r1=1.1​&r2=1.2
Delta lines: +3 -0
-------------------
--- Toolbar.py 8 May 2004 14:25:28 -0000 1.1
+++ Toolbar.py 9 May 2004 15:01:53 -0000 1.2
@@ -16,6 +16,8 @@
     (170, '|'),
     (180, 'undo'),
     (190, 'redo'),
+ (200, '|'),
+ (210, 'preference'),
     (900, '|'),
 ]
 Mixin.setMixin('mainframe', 'toollist', toollist)
@@ -30,6 +32,7 @@
     'paste':('IDM_EDIT_PASTE', 'images/paste.gif', 'paste', 'Paste text from clipboard', 'DoSTCBuildIn'),
     'undo':('IDM_EDIT_UNDO', 'images/undo.gif', 'undo', 'Undo last command', 'OnEditUndo'),
     'redo':('IDM_EDIT_REDO', 'images/redo.gif', 'redo', 'Redo last command', 'OnEditRedo'),
+ 'preference':('IDM_O​PTION_PREFERENCE', 'images/prop.gif', 'preference', 'Preferences of software', 'OnOptionPreference'),
 }
 Mixin.setMixin('mainframe', 'toolbaritems', toolbaritems)
 

File [changed]: __init__.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/modules/​__init__.py?r1=1.1​&r2=1.2
Delta lines: +1 -1
-------------------
--- __init__.py 8 May 2004 14:25:28 -0000 1.1
+++ __init__.py 9 May 2004 15:01:53 -0000 1.2
@@ -1,4 +1,5 @@
 __all__ = [
+ 'Pref',
     'MainFrame',
     'EditorCtrl',
     'DefaultMenu',
@@ -9,5 +10,4 @@
     'ComEdit',
     'Toolbar',
     'icon',
- 'Pref',
 ]




--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@newe​dit.tigris.org
For additional commands, e-mail: cvs-help at newedit dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /newedit/src/, /newedit/src/modules/ limodou limodou 2004-05-09 08:01:59 PDT
Messages per page: