[PyQt] Fwd: cx_freezing with python3.1 and pyqwt

2011-09-14 Thread KONTRA, Gergely
Hi!

Forgive me trying my luck here, but this problem of mine seems to be
pyqt-pyqwt related, so I hope there are some wise people to help me
out

thanks
Gergo
-- Forwarded message --
From: KONTRA, Gergely pihent...@gmail.com
Date: Tue, Aug 30, 2011 at 20:35
Subject: cx_freezing with python3.1 and pyqwt
To: cx-freeze-users cx-freeze-us...@lists.sourceforge.net


Hi all!

I am trying to freeze my project with cx_freeze.

Project is here:
http://biqazo.googlecode.com

I am under win32, python3.1.3, using designer with QwtPlot inside the
GUI (I have hand-written the xml)

after freezing, when I start the exe, the following is printed:
D:\tmp\biq\distbiQazo.exe
Traceback (most recent call last):
 File C:\programs\Python31\lib\site-packages\cx_Freeze\initscripts\Console3.py
, line 27, in module
   exec(code, m.__dict__)
 File biQazo.py, line 62, in module
 File C:\programs\Python31\lib\site-packages\PyQt4\uic\__init__.py, line 203,
 in loadUiType
   exec(code_string.getvalue(), ui_globals)
 File string, line 700, in module
ImportError: No module named qwtplot

What I have figured out for freezing is:
D:\tmp\biqc:\programs\Python31\Scripts\cxfreeze.bat biQazo.py
--include-modules=PyQt4.QtSvg,numpy.lib.format,serial.win32,resources_rc
--exclude-modules=tcl,tkinter

Note that after checkout, I started the program once to get
resources_rc.py generated

Any hints would be welcome
+-[ Gergely Kontra pihent...@gmail.com ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- Olyan lángész vagyok, hogy poroltóval kellene járnom! -+
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] licensing

2011-06-23 Thread KONTRA, Gergely
On Thu, Jun 23, 2011 at 10:33, Phil Thompson
p...@riverbankcomputing.com wrote:
 On Wed, 22 Jun 2011 10:35:40 +0200, KONTRA, Gergely
 pihent...@gmail.com
 wrote:
 Hi all!

 Maybe a bit offtopic and theoretical question:

 Suppose I'd like to write an app in python and Qt. I evaluate the
 possibilities, and see, that pyqt is more stable now, so I decide to
 begin coding with it (with the free version). When I make this
 decision, I already think to wait for a more complete/stable PySide
 binding and distribute my code which uses PySide (with a less
 restrictive license). Or I first release it with PyQt, but later on I
 find PySide, which has a less restrictive license.
 Is any of the above cases the violation of the License Terms? So is it
 legal? Is it fair?

 And consider another case: I begin to write my app with Pyside, and
 later release a version with pyqt at some point. Can I later release a
 newer PySide based version with license compatible with PySide (which
 is not compatible with pyqt's license)?

 Yet another case: I do a prototype with PyQt, and than hand-convert it
 to Qt/C++.

 You haven't said what license you want to use for your code. If you use
 the GPL version of PyQt then your license must be compatible with the GPL.

 Phil

This question is a question, as long as somebody would like to release
the PySide version, which conforms to the PySide license, but not
compatible with PyQt's license.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] licensing

2011-06-22 Thread KONTRA, Gergely
Hi all!

Maybe a bit offtopic and theoretical question:

Suppose I'd like to write an app in python and Qt. I evaluate the
possibilities, and see, that pyqt is more stable now, so I decide to
begin coding with it (with the free version). When I make this
decision, I already think to wait for a more complete/stable PySide
binding and distribute my code which uses PySide (with a less
restrictive license). Or I first release it with PyQt, but later on I
find PySide, which has a less restrictive license.
Is any of the above cases the violation of the License Terms? So is it
legal? Is it fair?

And consider another case: I begin to write my app with Pyside, and
later release a version with pyqt at some point. Can I later release a
newer PySide based version with license compatible with PySide (which
is not compatible with pyqt's license)?

Yet another case: I do a prototype with PyQt, and than hand-convert it
to Qt/C++.

Thanks
Gergo



+-[ Gergely Kontra pihent...@gmail.com ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- Olyan lángész vagyok, hogy poroltóval kellene járnom! -+
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Fwd: How to convert days to year,month days

2011-02-21 Thread KONTRA, Gergely
Why not use datetime.timedelta?

[interactive console]
 import datetime
 a = datetime.datetime.now()
 b = datetime.datetime.now()
 b-a
datetime.timedelta(0, 5, 156000)


+-[ Gergely Kontra pihent...@gmail.com ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- Olyan lángész vagyok, hogy poroltóval kellene járnom! -+



On Mon, Feb 14, 2011 at 18:46, alhad deshpande alhaddeshpa...@gmail.com wrote:
 i have a date of joining of an employee and i want to know till current date
 how many MONTHS he/she has worked in the company..

 Can someone plz guide me how can i convert days to MONTHS for above
 requirement..

 Thanx
 ad3d
 ___
 PyQt mailing list    PyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] QGrahics / textItemSize

2011-02-09 Thread KONTRA, Gergely
Maybe because you set the font size in POINTs.

See: 
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qfont.html#QFont-2

and also

http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qfont.html#setPixelSize
+-[ Gergely Kontra pihent...@gmail.com ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- Olyan lángész vagyok, hogy poroltóval kellene járnom! -+



On Sun, Feb 6, 2011 at 16:54, Philippe Crave philippe.cr...@gmail.com wrote:
 Thanks for testing !

 I attach a new code with Arial (maybe you're under windows) and a new png.
 this time, I also draw a rectangle. 200x40px, red.

 you can check that the scene produced my the pyqt code gives a rectangle
 like the one in the png. I did it in inkscape. a 200x40px red rect.

 but for the font, hello 1 is too big. hello 2 seems to be of similar
 size. but it was scale.
 I attach the .svg too.
 in the svg (and the png), i wrote hello in arial/40

 why should I scale the text (with a ratio of .75) to get a correct size ?

 2011/2/6 KONTRA, Gergely pihent...@gmail.com

 For me the 2 texts are sized equal if I remove the line, which scales the
 text.

 But I guess I do not have the font Norasi (rendered as some
 sans-serirf font on my PC).

 Gergo
 +-[ Gergely Kontra pihent...@gmail.com ]--+
 |   |
 | Mobile:(+36 20)356 9656   |
 |   |
 +- Olyan lángész vagyok, hogy poroltóval kellene járnom! -+



 On Sat, Feb 5, 2011 at 11:14, Philippe Crave philippe.cr...@gmail.com
 wrote:
  Hello,
 
  When I add to the Scene some rectangles and texts, rectangles are
  perfect,
  but text are too big.
 
  If I add a QGraphicsSimpleTextItem with a font_size of 40, it will
  display
  bigger than the same text/font/size if I draw it in inkscape (or
  anywhere
  else).
  Seems that I have to scale with a ratio of 0.75 to get a correct size.
 
  What am I doing wrong ?
 
  here is my sample (I also attach a png with a text in Norasi with a size
  of
  40):
 
  from PyQt4 import QtGui
 
  import sys
 
  app = QtGui.QApplication(sys.argv)
 
  scene = QtGui.QGraphicsScene(0, 0, 400, 400)
 
  scene.addSimpleText('HELLO 1', QtGui.QFont('Norasi', 40))
 
  t = scene.addSimpleText('HELLO 2', QtGui.QFont('Norasi', 40))
 
  t.setY(100)
 
  t.scale(.75, .75)
 
  view = QtGui.QGraphicsView(scene)
 
  view.setRenderHint(QtGui.QPainter.Antialiasing)
 
 
  view.setViewportUpdateMode(QtGui.QGraphicsView.BoundingRectViewportUpdate)
 
  view.show()
 
  sys.exit(app.exec_())
 
 
 
  ___
  PyQt mailing list    PyQt@riverbankcomputing.com
  http://www.riverbankcomputing.com/mailman/listinfo/pyqt
 


 ___
 PyQt mailing list    PyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] explanatory label in a not uniformly scaled QGraphicsView

2011-02-09 Thread KONTRA, Gergely
Hi all!

Is there a way to place a text on a QGraphicsView, which always looks
the same size (say 10px) on screen, regardless of the scaling applied
to the View?

thanks
Gergo
+-[ Gergely Kontra pihent...@gmail.com ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- Olyan lángész vagyok, hogy poroltóval kellene járnom! -+
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] PyQWT for python3.1

2011-01-25 Thread KONTRA, Gergely
Hi!

Is there a binary pyqwt installer for python3.1 for win32? I cannot
find on the DL page. Is it just me, who does not see it?

I already have a half-complete app with python3.1, and I'd like to use PyQWT.

thanks
Gergo
+-[ Gergely Kontra pihent...@gmail.com ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- Olyan lángész vagyok, hogy poroltóval kellene járnom! -+
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Fwd: creating QWidgets outside the GUI thread

2010-12-17 Thread KONTRA, Gergely
-- Forwarded message --
From: KONTRA, Gergely pihent...@gmail.com
Date: Fri, Dec 17, 2010 at 13:03
Subject: Re: [PyQt] creating QWidgets outside the GUI thread
To: erik.janss...@conceptive.be


AFAIK you shouldn't create or manipulate QWidgets just from the main
thread. If you'd like to initiate some GUI change from a worker
thread, you should use the signals  slots mechanism to delegate
widget creation to the main thread.
+-[ Gergely Kontra pihent...@gmail.com ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- Olyan lángész vagyok, hogy poroltóval kellene járnom! -+



On Fri, Dec 17, 2010 at 10:29, Erik Janssens
erik.janss...@conceptive.be wrote:
 Hi,

 has anybody experience with creating QWidgets outside the GUI
 thread ?

 I'd like to know if it's possible to construct QWidgets in some kind
 of worker thread, and when they are needed, reparent them and
 move them to the GUI thread before displaying them.

 Regards,

 Erik
 ___
 PyQt mailing list    p...@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] bug: Python 2 exception in PyQt-Py3.1-gpl-4.8.1-1

2010-12-04 Thread KONTRA, Gergely
It worked for me with 3.1, I just have to delete the python2 pyqt bindings
from the site-packages...


+-[ Gergely Kontra pihent...@gmail.com ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- Olyan lángész vagyok, hogy poroltóval kellene járnom! -+


On Sat, Dec 4, 2010 at 02:16, Daniel Goertzen 
d...@networkintegritysystems.com wrote:

 Ah, sounds like a cx_freeze problem them.  Other than that issue, cx_freeze
 appeared to work fine.

 The pyInstaller homepage says that it only supports up to python 2.7.
  Since I'm using 3.1, I didn't even try it.

 Thanks,
 Dan.



 On Fri, Dec 3, 2010 at 4:21 PM, Hans-Peter Jansen h...@urpla.net wrote:

 On Friday 03 December 2010, 21:47:06 Daniel Goertzen wrote:
  While running cx_freeze with an installation of
  PyQt-Py3.1-gpl-4.8.1-1, I got the following error:
 
 
File
  C:\Python31\lib\site-packages\PyQt4\uic\port_v2\load_plugin.py,
   ^^^
  line 17
  except Exception, e:
  ^
  SyntaxError: invalid syntax
  make: *** [freeze] Error 1
 
 
 
  Changing the line to a Python 3 style exception fixed it:
 
except Exception as e:

 but it should have picked up port_v3, if things would had gone right.
 For some reason, cx_freeze picked the wrong interpreter.

 You may also try using PyInstaller, which has explicit PyQt4 support.

 Pete
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt




 --
 Daniel Goertzen
 -
 d...@networkintegritysystems.com (work)
 daniel.goert...@gmail.com (home)
 -
 1 204 272 6149 (home/office)
 1 204 470 8360 (mobile)
 -




 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] QSqlTableModel.rowCount bug? (and still need infor for beforeInsert)

2010-12-03 Thread KONTRA, Gergely
Hi all!

I suspect QSqlTableModel.rowCount cannot return numbers above 256.

For this finding could somebody please write me a mini-example of the
QSqlTableModel.beforeInsert?

Look, this outputs 256 for me (python 3.1.2, pyqt 4.8.1, XP SP3)

And can somebody tell me why this code is this painfully slooow?

import sys
from PyQt4.QtCore import *
from PyQt4.QtSql import *
from PyQt4.QtGui import *

app = QApplication(sys.argv)
db = QSqlDatabase.addDatabase(QSQLITE)
db.setDatabaseName('test.db')
db.open()

query = QSqlQuery('CREATE TABLE preferences (id  INTEGER PRIMARY
KEY  AUTOINCREMENT  NOT NULL, value varchar)')

model = QSqlTableModel(db=db)
model.setTable('preferences')
model.select()

for i in range(300):
   record = model.record()
   record.setValue('value', str(i))
   res = model.insertRecord(-1, record)
model.submitAll()
print(model.rowCount())

del model, db

thanks
Gergo

+-[ Gergely Kontra pihent...@gmail.com ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- Olyan lángész vagyok, hogy poroltóval kellene járnom! -+
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] QSqlTableModel.beforeInsert signal (new style signal/slot)

2010-12-03 Thread KONTRA, Gergely
Hi!

I am trying to connect the beforeInsert signal of a QSqlTableModel,
and having some problems.

I've found this similar thread:
http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg20117.html

However, I am using pyqt with py3k, so I prefer the new style signal
and slots, but I appreciate any working solution...

So my attempt based on the thread:
class BatteryMain(base_class, form_class):
   # ...
   def cycle_started(self, record):
   print(Inserting {!r}.format(record))

   def battery_load(self, filename):
   self.cycles_model = QSqlTableModel(db=self.battery_db)
   self.connect(self.cycles_model,
SIGNAL(beforeInsert(QSqlRecord
)), self.cycle_started)

RESULT:
QObject::connect: Cannot queue arguments of type 'QSqlRecord'
(Make sure 'QSqlRecord' is registered using qRegisterMetaType().)

Another attempt with new style signals and slots:

class BatteryMain(base_class, form_class):
   # ...
   @pyqtSlot('QSqlRecord ')
   def cycle_started(self, record):
   print(Inserting {!r}.format(record))

   def battery_load(self, filename):
   self.cycles_model = QSqlTableModel(db=self.battery_db)
   self.cycles_model.beforeInsert.connect(self.cycle_started)

RESULT:
 File D:\prg\biQazo\biQazo.py, line 145, in battery_load
   self.cycles_model.beforeInsert.connect(self.cycle_started)
TypeError: connect() failed between beforeInsert(QSqlRecord) and unislot()

Could anybody tell me the correct syntax, please?

thanks
Gergo
+-[ Gergely Kontra pihent...@gmail.com ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- Olyan lángész vagyok, hogy poroltóval kellene járnom! -+
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] QSqlTableModel without view

2010-12-03 Thread KONTRA, Gergely
[sorry for the posting more messages, but I figured out now, that my
subscription address was wrong, and I got no error message from the list,
that my messages will not appear :(]

Hi!

I am a novice pyqt developer.
I will develop a pyqt program, which will periodically will get
measurement data, and display it visually. That's why I have chosen to
store it in sqlite database. Measurements have some metadata, so I
thought they should also go to the same db, in an ini like table
(table name preferences, key and value are strings).

I have written 2 classes for that, but that does not seems like a
straighforward solution...  I hope there is a cleaner and more
efficient way...

class BatteryDb(QSqlDatabase):
   @classmethod
   def addSqlDb(cls, filename=None):
   db = QSqlDatabase.addDatabase(QSQLITE, 'battery')
   # if filename is None FIXME
   db.setDatabaseName(filename)
   db.open()
   return db

   @classmethod
   def removeSqlDb(cls, db):
   print(battery db delete)
   db.close()
   QSqlDatabase.removeDatabase('battery')

class IniTable:
   def __init__(self, db, table, parent=None):
   self.model = QSqlTableModel(parent, db)
   self.model.setTable(table)
   self.model.setEditStrategy(QSqlTableModel.OnManualSubmit)
   self.db = db
   self.model.select()
   self.build_indices()

   def build_indices(self):
   self.indices = {}
   for i in range(self.model.rowCount()):
   self.indices[self.model.record(i).value('key')] = i

   def __getitem__(self, attr):
   return self.model.record(self.indices[attr]).value('value')

   def __setitem__(self, attr, value):
   if attr in self.indices:
   idx = self.indices[attr]
   record = self.model.record(idx)
   record.setValue('value', value)
   self.model.setRecord(idx, record)
   # idx = self.model.createIndex(self.indices[attr],
self.model.fieldIndex('value'))
   #self.model.setData(idx, value)
   else:
   record = self.model.record()
   record.setValue('key', attr)
   record.setValue('value', value)
   res = self.model.insertRecord(-1, record)
   #self.build_indices()
   print('.')

   def submitAll(self):
   self.model.submitAll()

+-[ Gergely Kontra pihent...@gmail.com ]--+
|   |
| Mobile:(+36 20)356 9656   |
|   |
+- Olyan lángész vagyok, hogy poroltóval kellene járnom! -+
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] QSqlTableModel.rowCount bug? (and still need infor for beforeInsert)

2010-12-03 Thread KONTRA, Gergely
On Fri, Dec 3, 2010 at 15:56, Wolfgang Rohdewald wolfg...@rohdewald.dewrote:

 On Freitag 03 Dezember 2010, KONTRA, Gergely wrote:
  Hi all!
 
  I suspect QSqlTableModel.rowCount cannot return numbers above
  256.

 rowCount is not the number of rows in the table but in the model,
 AFAIK. Use fetchMore() to load more.


Thats not logical.
http://doc.trolltech.com/4.7/qsqltablemodel.html#rowCountdoesn't
mention what is exactly rowCount, and one should expect the number
of rows based on the name...

fetchMore will then fetch all rows. I don't want that, just would like to
know the number of rows, or just load the last record.

 And can somebody tell me why this code is this painfully
slooow?

 you execute 300 transactions. If you use db.transaction()
 after db.open() and db.commit() after model.submitAll(), this
 is only one transaction and much faster.

Sounds reasonable, thanks.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] QSqlTableModel.beforeInsert signal (new style signal/slot)

2010-12-03 Thread KONTRA, Gergely
On Fri, Dec 3, 2010 at 16:06, Phil Thompson p...@riverbankcomputing.comwrote:

 On Fri, 3 Dec 2010 15:46:55 +0100, KONTRA, Gergely pihent...@gmail.com
 wrote:
  Hi!
 
  I am trying to connect the beforeInsert signal of a QSqlTableModel,
  and having some problems.
 
  I've found this similar thread:
  http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg20117.html
 
  However, I am using pyqt with py3k, so I prefer the new style signal
  and slots, but I appreciate any working solution...
 
  So my attempt based on the thread:
  class BatteryMain(base_class, form_class):
 # ...
 def cycle_started(self, record):
 print(Inserting {!r}.format(record))
 
 def battery_load(self, filename):
 self.cycles_model = QSqlTableModel(db=self.battery_db)
 self.connect(self.cycles_model,
  SIGNAL(beforeInsert(QSqlRecord
  )), self.cycle_started)
 
  RESULT:
  QObject::connect: Cannot queue arguments of type 'QSqlRecord'
  (Make sure 'QSqlRecord' is registered using qRegisterMetaType().)
 
  Another attempt with new style signals and slots:
 
  class BatteryMain(base_class, form_class):
 # ...
 @pyqtSlot('QSqlRecord ')
 def cycle_started(self, record):
 print(Inserting {!r}.format(record))
 
 def battery_load(self, filename):
 self.cycles_model = QSqlTableModel(db=self.battery_db)
 
 self.cycles_model.beforeInsert.connect(self.cycle_started)
 
  RESULT:
   File D:\prg\biQazo\biQazo.py, line 145, in battery_load
 self.cycles_model.beforeInsert.connect(self.cycle_started)
  TypeError: connect() failed between beforeInsert(QSqlRecord) and
 unislot()
 
  Could anybody tell me the correct syntax, please?

 It's not a syntax problem.

 Are you using threads?


Yes, I am using threads. Is it valid to insert into a QSqlTableModel a new
row in a QThread?
I have a worker thread, which collects data, and inserts it into the
QSqlTableModel, and I'd like to get notified with this beforeInsert signal
in the GUI thread.


 I would guess that you can't use signals that take a QSqlRecord across
 threads, probably because they are not passed as const (to allow them to be
 updated by a connected slot).

That sounds sad. I thought this signal will make it easy to communicate
between threads.
Then what is the solution to communicate between the worker thread, and the
main GUI thread? Cutsom signal?

thanks
Gergo
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt