Форум сайта python.su
# -*- coding: cp1251 -*-
import wx
class TreeGroup(wx.TreeCtrl):
def __init__(self, parent):
wx.TreeCtrl.__init__(self, parent, style=wx.TR_DEFAULT_STYLE|wx.TR_HIDE_ROOT|wx.TR_MULTIPLE)
root_id = self.AddRoot('root')
self.AppendItem(root_id, 'grup1')
self.AppendItem(root_id, 'grup2')
self.AppendItem(root_id, 'grup3')
self.UnselectAll()
class MultiChoiceGroup(wx.Dialog):
""" диалог выбора групп для фильтрации списка пользователей
"""
def __init__(self):
wx.Dialog.__init__(self, None, title='Выбор групп', size=(300, 400), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
# Создать панель и дерево
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(wx.StaticText(self, label='Отметьте группы по которым установить фильтр'), flag=wx.ALL, border=10)
################################################################
self.tree = TreeGroup(self)
################################################################
sizer.Add(self.tree, proportion=1, flag=wx.EXPAND|wx.ALL, border=10)
self.SetSizer(sizer)
hsizer = wx.BoxSizer(wx.HORIZONTAL)
self.but_ok = wx.Button(self, label='Ok')
self.but_cancel = wx.Button(self, label='Cancel')
hsizer.Add(self.but_ok, flag=wx.RIGHT, border=5)
hsizer.Add(self.but_cancel)
sizer.Add(hsizer, flag=wx.ALIGN_RIGHT|wx.RIGHT|wx.BOTTOM, border=10)
#
self.but_ok.Bind(wx.EVT_BUTTON, self.OnOk)
self.but_cancel.Bind(wx.EVT_BUTTON, self.OnCancel)
acceltbl = wx.AcceleratorTable([
(wx.ACCEL_NORMAL, wx.WXK_RETURN, self.but_ok.GetId()),
(wx.ACCEL_NORMAL, wx.WXK_ESCAPE, self.but_cancel.GetId()),
])
self.SetAcceleratorTable(acceltbl)
def OnOk(self, evt):
self.EndModal(wx.ID_OK)
def OnCancel(self, evt):
self.EndModal(wx.ID_CANCEL)
class App(wx.App):
def __init__(self):
wx.App.__init__(self, True, 'log.txt')
dlg = MultiChoiceGroup()
dlg.ShowModal()
dlg.Destroy()
if __name__ == "__main__":
app = App()
app.MainLoop()
скрипт почему то не принял..
import fcgi
count=0
while fcgi.isFCGI():
request = fcgi.Accept()
request.out.write("Cache-control: no-cache")
request.out.write("Content-Type: text/plain\n\n")
request.out.write("python fastcgi example\n")
request.out.write("counter: "+str(count)+"\n")
count+=1
request.Finish();
import fcgi
count=0
while fcgi.isFCGI():
request = fcgi.Accept()
print "Content-Type: text/plain\n"
print "sgsdg"
request.Finish()
def __getattribute__(self, name):
check = object.__getattribute__(self, '_Proxy__check')
check()
PyObject* PyObject_RichCompare(PyObject *o1, PyObject *o2, int opid)
class Author(models.Model):
name = models.CharField(max_length=150)
surname = models.CharField(max_length=60)
def __unicode__(self):
return u'%s %s ' % (self.name, self.surname)
class Book(models.Model):
title = models.CharField(max_length=100)
author = models.ManyToManyField(Author)
price = models.DecimalField("", max_digits=7, decimal_places=2)
def get_entry_author(self):
entry = Book.objects.get(id='self.id')
return entry.authors.all()
get_entry_author.short_description = 'Author'
def __unicode__(self):
return u'%s ' % (self.title)
class BookAdmin(admin.ModelAdmin):
fieldsets = [
('Name book',{'fields': ['title']}),
('Publisher information', {'fields': ['publisher']}),
('Publication date', {'fields': ['publication_date']}),
('Price', {'fields': ['price']}),
('Author', {'fields': ['author']}),
]
list_display = ('title', 'publisher', 'publication_date','price', 'get_entry_author',)
list_filter = ['title']
date_hierarchy = 'publication_date'
class AuthorAdmin(admin.ModelAdmin):
fieldsets=[
('Author information',{'fields':('name', 'surname')}),
]
list_display = ('name', 'surname', )
admin.site.register(Book,BookAdmin)
admin.site.register(Author, AuthorAdmin)
def get_entry_author(self):
entry = Book.objects.get(id='self.id')
return entry.authors.all()
get_entry_author.short_description = 'Author'
#-*- coding:cp1251 -*-
from Tkinter import *
tk=Tk()
class app:
def act(self,event):
self.text.set(self.ent.get())
txt='test'
self.ent.insert(END,txt) # вставили то что нужно
self.ent.icursor(len(self.ent.get())-len(txt)) # поставили курсор до вставленного
self.ent.select_range(len(self.ent.get())-len(txt),END) #выделили вставленное
def __init__(self):
self.ent=Entry(tk)
self.ent.pack()
self.text=StringVar()
self.lab=Label(tk,textvariable=self.text)
self.lab.pack()
self.ent.bind('<KeyRelease>',self.act)
s=app()
tk.mainloop()
select * from users where users.id> (select max(id) from (select id from users limit(70)) as t) limit(20)
class pc(models.Model): name = models.CharField(max_length=30, unique=True) user = models.CharField(max_length=30) location = models.CharField(max_length=30) monitor = models.CharField(max_length=255) ups = models.CharField(max_length=255) cpu = models.CharField(max_length=255) om = models.CharField(max_length=255) hdd = models.CharField(max_length=255) date_create = models.DateField()