Форум сайта python.su
import win32file #модуль из pywin32
mailslot = win32file.CreateMailslot(r"\\.\mailslot\sample", 0, -1, None)
win32file.WriteFile(mailslot, "text", None)
mailslot.Close()
from ctypes import *
# ...
class NewtonBody(Structure):
def __init__(self, pointer = 0):
self.pointer = pointer
# ...
class Newton:
def __init__(self):
self._cdll = CDLL('newton.dll')
self.world = NewtonWorld()
# ...
# NewtonBodySetForceAndTorqueCallback
def bodySetForceAndTorqueCallback(self, body):
CALLBACK = CFUNCTYPE(c_int, POINTER(NewtonBody), c_float, c_int)
def callback(a, b, c):
print '1'
return 0
self._cdll.NewtonBodySetForceAndTorqueCallback(body.pointer, CALLBACK(callback))
return None
Traceback (most recent call last):
File "Newton.py", line 119, in <module>
newton.update(10.5)
File "Newton.py", line 42, in update
self._cdll.NewtonUpdate(self.world.pointer, c_float(timestep))
WindowsError: exception: access violation reading 0x3C888899
typedef void (*NewtonApplyForceAndTorque) (const NewtonBody* body, dFloat timestep, int threadIndex);
// ...
NEWTON_API void NewtonBodySetForceAndTorqueCallback (const NewtonBody* body, NewtonApplyForceAndTorque callback);
def open_base(self):Собственно метод взят отсюда.
PATH=self.ui.bd_text.text()
accessdb = msaccess.AccessDb()
connAccess = accessdb.connect(PATH, None, None, None)
rs = accessdb.getRecordset(connAccess, SQL_statement)
fields = rs.getFields()
print fields
for item in rs:
print item
connAccess.Close()
Traceback (most recent call last):Ну и сразу второй вопрос, только смеяться над чайником не надо )
File “C:\Documents and Settings\STeReO\workspace\mailticker\src\mailticket-gui.py”, line 710, in open_base
connAccess = accessdb.connect(PATH, None, None, None)
File “E:\Programs\Py\msaccess.py”, line 18, in connect
connAccess.Open(DSN)
File “<COMObject ADODB.Connection>”, line 3, in Open
File “E:\Programs\Py\lib\site-packages\win32com\client\dynamic.py”, line 272, in _ApplyTypes_
result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args)
pywintypes.com_error: (-2147352567, ‘\xce\xf8\xe8\xe1\xea\xe0.’, (0, u'Microsoft JET Database Engine', u'\u041d\u0435 \u0443\u0434\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0421\u0438\u0441\u0442\u0435\u043c\u043d\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0438\u043b\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0430 \u0441 \u043c\u043e\u043d\u043e\u043f\u043e\u043b\u044c\u043d\u044b\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c.', None, 5003028, -2147217843), None)
bytes = QByteArray()
buffer = QBuffer( bytes )
photo = QPixmap()
photo.load( filename )
buffer.open( QIODevice.WriteOnly )
photo.save( buffer, "PNG" )
self.formsModel.record( row ).setValue( "pict", QVariant( bytes ) )
bytes = QByteArray()
buffer = QBuffer( bytes )
photo = QPixmap()
photo.load( filename )
buffer.open( QIODevice.WriteOnly )
photo.save( buffer, "PNG" )
query = QSqlQuery()
query.prepare( "UPDATE forms SET Pict = :p WHERE Id = :fid" )
query.bindValue( ":p", QVariant( bytes ) )
query.bindValue( ":p", QVariant( formId ) )
query.exec_()
class UserPhoneOther(models.Model):
user = models.ForeignKey(User, unique=False)
phone = models.CharField(u'Телефон доп.', max_length=30)
def __unicode__(self):
return u'%s' % self.phone
id user_id phone
1 1 123456
2 1 567890
UserPhoneOtherFormSet = modelformset_factory(UserPhoneOther, exclude=('user',), extra=0)
fuserphoneother = UserPhoneOtherFormSet(queryset=UserPhoneOther.objects.filter(user=curuser))
{{ fuserphoneother.as_table }}
class Subject(models.Model):
name = models.CharField(max_length=200)
class Referat(models.Model):
subject = models.ForeignKey(Subject)
name = models.CharField(max_length=600)
filename = models.FileField(upload_to='tmp', max_length=200)
dowloaded_times = models.IntegerField()
from PyQt4.QtGui import *
from PyQt4.QtCore import *
if __name__ == '__main__':
poly = QPolygonF()
poly.append(QPointF(1,1))
poly.append(QPointF(1,1))
poly.append(QPointF(1,1))
for point in poly:
point.setX(5)
for i in range(len(poly)):
poly[i].setX(5)