Форум сайта python.su
#!/usr/local/bin/python
import MySQLdb
ConvDB = MySQLdb.Connect(host="1.1.1.1", user="123", passwd="123", db="somedb")
ConvDBcursor = ConvDB.cursor()
query="SELECT id from sometable WHERE somethng=63"
print query
ConvDBcursor.execute(query.decode('cp1251').encode('utf8'))
print ConvDBcursor.rowcount
ConvDBcursor.close()
ConvDB.close()
#!/usr/bin/python
# cpu.py
import wx
import math
import wx.lib.wxcairo
class CPU(wx.Panel):
def __init__(self, parent, id):
wx.Panel.__init__(self, parent, id, size=(600, 600))
self.parent = parent
self.SetBackgroundColour('#FBFF05')
self.Bind(wx.EVT_PAINT, self.OnPaint)
def OnPaint(self, event):
dc = wx.PaintDC(self)
w,h = dc.GetSizeTuple()
cr = wx.lib.wxcairo.ContextFromDC(dc)
pos = self.parent.GetParent().GetParent().sel
rect = pos
cr.set_line_width (10)
cr.set_source_rgba(1, 0, 1, 1)
cr.move_to(20, 20)
cr.line_to(380, rect)
cr.stroke()
class CPUWidget(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(800, 600))
self.sel = 0
panel = wx.Panel(self, -1)
centerPanel = wx.Panel(panel, -1)
self.cpu = CPU(centerPanel, -1)
hbox = wx.BoxSizer(wx.HORIZONTAL)
self.slider = wx.Slider(panel, -1, self.sel, 0, 400, (20, 20), (25, 500),
wx.VERTICAL | wx.SL_LABELS | wx.SL_INVERSE)
self.slider.SetFocus()
hbox.Add(centerPanel, 0, wx.LEFT | wx.TOP, 20)
hbox.Add(self.slider, 0, wx.LEFT | wx.TOP, 23)
self.Bind(wx.EVT_SCROLL, self.OnScroll)
panel.SetSizer(hbox)
self.Centre()
self.Show(True)
def OnScroll(self, event):
self.sel = event.GetInt()
self.cpu.Refresh()
app = wx.App()
CPUWidget(None, -1, 'cpu')
app.MainLoop()
MaxRequestsPerChild 1
<VirtualHost *>
DocumentRoot /home/exezed/work/code_dev
ServerName localhost
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
PythonOption django.root /code_dev
PythonDebug On
PythonPath "['/home/exezed/work/code_dev'] + sys.path"
</Location>
</VirtualHost>
#-*- coding:utf-8 -*-
from Tkinter import *
import sqlite3
import ttk
from PIL import Image, ImageTk
c = sqlite3.connect(database=r"avto.sdb")
cu = c.cursor()
root = Tk()
root.wm_title("multicolumn ListBox")
fr = ttk.Frame(root)
fr.pack()
# Определяем таблицу Treeview
tablegas = ttk.Treeview(fr, show='headings', selectmode='browse', height=10)
# Даем заголовки колонкам
tablegas["columns"]=("date","avtopart","namepart","numpart","mileage","brand","cost","sto","tools","komment")
tablegas.heading("date", text=u"Дата", anchor='w')
tablegas.heading("avtopart", text=u"Часть авто", anchor='w')
tablegas.heading("namepart", text=u"Наименование ремонта", anchor='w')
tablegas.heading("numpart", text=u"Номер детали", anchor='w')
tablegas.heading("mileage", text=u"Пробег", anchor='w')
tablegas.heading("brand", text=u"Фирма", anchor='w')
tablegas.heading("cost", text=u"Стоимость ремонта", anchor='w')
tablegas.heading("sto", text=u"Место ремонта", anchor='w')
tablegas.heading("tools", text=u"Инструмент", anchor='w')
tablegas.heading("komment", text=u"Комментарии", anchor='w')
tablegas.column("date", stretch=0, width=70)
tablegas.column("avtopart", stretch=0, width=90)
tablegas.column("namepart", stretch=0, width=90)
tablegas.column("numpart", stretch=0, width=90)
tablegas.column("mileage", stretch=0, width=80)
tablegas.column("brand", stretch=0, width=100)
tablegas.column("cost", stretch=0, width=90)
tablegas.column("sto", stretch=0, width=80)
tablegas.column("tools", stretch=0, width=100)
tablegas.column("komment", stretch=0, width=100)
sel = 'SELECT date, avtoparts, namerepair, numberparts, mileage, brand, cost, sto.place as "СТО" FROM repair, sto WHERE sto.ID = repair.sto'
cu.execute(sel)
for item in cu.fetchall():
tablegas.insert('', 'end', values=item)
scroll = ttk.Scrollbar(fr)
tablegas.config(yscrollcommand=scroll.set)
scroll.config(command=tablegas)
scroll.grid(row=0, column=1, sticky=N+S)
tablegas.grid(column=0, row=0, sticky='nsew')
Style = ttk.Style()
ttk.Style.theme_use(Style, "clam")
mainloop()
c.close()
<VirtualHost z.world.com:80>
DocumentRoot "/var/www/z
ServerName z.world.com:80
<Directory "/var/www/z">
AddDefaultCharset utf-8
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from all
SetHandler mod_python
PythonHandler util.publisher
PythonDebug on
PythonPath "sys.path + ['/var/www/z']"
PythonOption basedir "/var/www/z"
PythonOption baseurl "/"
PythonAutoReload on
PythonOption mod_python.session.session_type "FileSession"
PythonOption mod_python.file_session.database_directory "/var/www/z/run/sessions"
</Directory>
</VirtualHost>
<VirtualHost z2.world.com:80>
ServerAdmin a@b.c
DocumentRoot /var/www/z2
ServerName z2.world.com:80
ErrorLog /var/www/log/error.log
<Directory />
Options FollowSymLinks +ExecCGI
AllowOverride All
</Directory>
#<Files app.py>
# SetHandler fastcgi-script
#</Files>
<Directory />
Options FollowSymLinks +ExecCGI
AllowOverride All
SetHandler fastcgi-script
PythonHandler util.publisher
DirectoryIndex util/publisher.py
PythonDebug on
PythonPath "sys.path + ['/var/www/z2']"
PythonOption basedir "/var/www/z2"
PythonOption baseurl "/"
PythonAutoReload on
PythonOption fastcgi-script.session.session_type "FileSession"
PythonOption fastcgi-script.file_session.database_directory "/var/www/z2/run/sessions"
</Directory>
</VirtualHost>