Форум сайта python.su
(r'^$', 'django.views.generic.simple.direct_to_template', {
'template': 'base.html',
'extra_context' : {'title':'Main page',},
'title' : ''Main page',
}),
<title>{{ title }}</title>
<p>{{ params.title }}</p>
ICONS_PATH = u'C:\\Data\\python\\pytree\\'
basic = pyTreeControl(None, user_callback = key_callback) # название basic осталось от примера на основе которого делал, но это не важно
appuifw.app.body = basic.control()
tree = cTreeOssa(u'----')
controll = pyTreeControl(tree, user_callback = key_callback)
basic.set_tree(tree) # после этого вызова контрол сам перерисует дерево
# -*- coding: cp1251 -*-
import wx
from wx.lib.mixins import listctrl
import locale
locale.setlocale(locale.LC_ALL,'Russian_Russia.1251')
import wx.lib.customtreectrl, wx.gizmos
from wx.lib.mixins import treemixin
from random import randint
class VirtualTreeListCtrl(treemixin.VirtualTree, wx.gizmos.TreeListCtrl,listctrl.ListCtrlAutoWidthMixin):
''' View:Виртуальное дерево
'''
def __init__(self, *args, **kwargs):
''' Виртуальное дерево
'''
self.model = kwargs.pop('treemodel')
kwargs['style'] = wx.TR_DEFAULT_STYLE | wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_ROW_LINES | wx.TR_COLUMN_LINES
super(VirtualTreeListCtrl, self).__init__(*args, **kwargs)
listctrl.ListCtrlAutoWidthMixin.__init__(self)
size = (16, 16)
self.imageList = wx.ImageList(*size)
self.red16 = self.imageList.Add(wx.Bitmap('red16.gif', wx.BITMAP_TYPE_GIF))
self.silver16 = self.imageList.Add(wx.Bitmap('silver16.gif', wx.BITMAP_TYPE_GIF))
self.green16 = self.imageList.Add(wx.Bitmap('green16.gif' ,wx.BITMAP_TYPE_GIF))
self.ivory16 = self.imageList.Add(wx.Bitmap('ivory16.gif' ,wx.BITMAP_TYPE_GIF))
self.AssignImageList(self.imageList)
columns = ['0','1','2','3','4','5','6']
for item in columns:
self.AddColumn(item[0])
def UpdateAllData(self):
''' обновить данные в модели.
'''
self.model.UpdateAllData()
self.RefreshItems()
def OnGetChildrenCount(self,indices):
return self.model.GetChildrenCount(indices)
def OnGetItemBackgroundColour(self,indices):
if indices[0] % 2 == 0:
return wx.Colour(207,229,255)
if indices[0] % 2 == 1:
return wx.Colour(217,255,237)
def OnGetItemText(self, indices, column=0):
return '%s' % (self.model.GetText(indices,column))
def OnGetItemImage(self, indices, which, column=0):
''' вернуть имидж в колонке
'''
return -1
class TreeModel(object):
''' Model:Модель обеспечивающая данные для виртуального дерева
'''
def __init__(self, *args, **kwargs):
self._DoSort()
super(TreeModel, self).__init__(*args, **kwargs)
self.k = 0
def UpdateAllData(self):
self._DoSort()
def GetItem(self, indices):
return self.jobs[indices[0]][0]
def _DoSort(self):
self.orig_items = []
count = 1000
for i in xrange(count):
a = [i,]
for i in xrange(6):
a.append(randint(0, 1000))
self.orig_items.append(a)
self.jobs = self.orig_items
def GetText(self, indices,column):
""" Запрос отображения строки, колонки
"""
return self.jobs[indices[0]][column]
def GetChildren(self, indices):
return "GetChildren"
def GetChildrenCount(self, indices):
try:
self.jobs
except:
return 0
if indices == ():
return len(self.jobs)
else:
return 0
class Job2Panel(wx.Panel):
def __init__(self, parent):
super(Job2Panel, self).__init__(parent)
self.treemodel = TreeModel()
sizer = wx.BoxSizer()
self.tree = VirtualTreeListCtrl(self,treemodel=self.treemodel)
sizer.Add(self.tree, proportion=1, flag=wx.EXPAND)
self.SetSizer(sizer)
# #зарядка дерева
self.tree.RefreshItems()
self.tree.SetFocus()
def UpdateAllData(self):
self.tree.UpdateAllData()
class App(wx.App):
def __init__(self):
wx.App.__init__(self, True, 'log.txt')
frame = wx.Frame(None, size=(800, 500))
frame.panel = Job2Panel(frame)
self.SetTopWindow(frame)
frame.Show()
if __name__ == "__main__":
app = App()
app.MainLoop()
def createDataModel(self):
self.treestore = gtk.TreeStore(str, str, int, int, int)
for product in Product.query.all():
self.treestore.append(None, [product.name, product.category, product.fat, product.protein, product.carbo])
return self.treestore
class ClassProblem(models.Model):
classproblem = models.CharField((u'Название класса поломки'),max_length=30)
def __unicode__(self):
return u'%s ' % (self.classproblem)
User.add_to_class('classproblem',models.ManyToManyField(ClassProblem, blank=True))
Unhandled exception in thread started by
Error in sys.excepthook:
<здесь пустые строки>
Exception _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now") in <bound method Cursor.__del__ of <MySQLdb.cursors.Cursor object at 0x2fe37a0c>> ignored
Exception _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now") in <bound method Cursor.__del__ of <MySQLdb.cursors.Cursor object at 0x2ac0caac>> ignored
Exception _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now") in <bound method Cursor.__del__ of <MySQLdb.cursors.Cursor object at 0x303c992c>> ignored
class Adesc(models.Model):
aname = models.CharField(max_length=300)
def __unicode__(self):
return self.aname
class Linker(models.Model):
link = models.ManyToManyField(Adesc, through='SymVes')
name = models.CharField(max_length=128, verbose_name = "Название")
linkA = models.ForeignKey('Alphabet', verbose_name = "Алфавит") #!не важно
linkR = models.ManyToManyField("Razdel", verbose_name = "В разделах") #важно, но не так
def __unicode__(self):
return self.name
class SymVes(models.Model):
symptom = models.ForeignKey(Adesc)
linker = models.ForeignKey(Linker)
vesves = models.CharField(max_length=1, choices=VES_CHOICES, default = 1)
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
PythonDebug On
PythonAutoReload Off
PythonPath "['htdocs', 'C:/Python25/lib/site-packages/django'] + sys.path"
</Location>
<Location "/static/">
SetHandler None
</Location>