Re: [PyQt] How to start an app in max size?

2012-01-16 Thread Nick Gaens
You're looking for QWidget::showMaximized().

Link to docs:
http://developer.qt.nokia.com/doc/qt-4.8/qwidget.html#showMaximized.

On Mon, Jan 16, 2012 at 11:43, Fabien Lafont lafont.fab...@gmail.comwrote:

 How can I run an app in fullscreen i.e in max size? I've tried
 showFullScreen() but it hides the windows bar.

 thx,

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




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

Re: [PyQt] Delaying splash screen

2011-09-08 Thread Nick Gaens
The avoidable * imports Pete mentioned involve typing

from PyQt4 import QtGui

and then do:

 class Foo(QtGui.QLabel)


or


 from PyQt4.QtGui import QLabel

and then do:

 class Foo(QLabel)


Using one of the above causes not all modules to be loaded, whereas your *
imports actually does load all a lot of unrequired modules.


On Thu, Sep 8, 2011 at 00:32, Muhammad Bashir Al-Noimi ad...@mbnoimi.netwrote:

  On 07/09/2011 11:27 م, Hans-Peter Jansen wrote:

 On Wednesday 07 September 2011, 14:04:02 ad...@mbnoimi.net wrote:

  Hi guys,

  I wrote a tiny class for delaying splash screen in C++ but when I
 tired to re-write it in python it didn't work!

  I got AttributeError TeSplashScreen object has no attribut QFrate
 although TeSplashScreen inherited from QFrame

  Could you please help me, I'm still a newbie in PyQt and Python.

  tesplashscreen.py

 from PyQt4.QtCore import *
 from PyQt4.QtGui import *

  Hmm, that * imports are easily avoided.

  Thanks a lot Pete, You mean I don't need to use both import lines?


   import sys
 class TeSplashScreen(QFrame):
 
 Splash doc
 

 app = QApplication(sys.argv)
 sPixmap = QPixmap(10,  10)
 sMessage = QString()
 messages = [nothing]
 sAlignment = 0
 sColor = QColor()

 def __init__(self,  pixmap):

  You need to call the base class c'tor here, e.g.:

 super(QFrame, self).__init__()

 Most of your code below has issues with missing self. references, which
 will result in access to undefined variables and instances, that are
 prematurely garbarge collected.

  I did as you mentioned exactly.
 I got new issue because I don't know how can I use QStringList class, I
 read in some article that it's unavailable in PyQt so I tried to use python
 lists instead but I got an exception at for loop

 TypeError object of type int has no len()

 here's the modified class:

 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 import sys
 class TeSplashScreen(QFrame):
 
 Splash doc
 

 app = QApplication(sys.argv)
 sPixmap = QPixmap(10,  10)
 sMessage = QString()
 #messages = [nothing
 ]
 sAlignment = 0
 sColor = QColor()

 def __init__(self,  pixmap):
 super(QFrame,  self).__init__()
 self.sPixmap =  pixmap
 self.setWindowFlags(Qt.FramelessWindowHint|Qt.WindowStaysOnTopHint)
 self.setAttribute(Qt.WA_TranslucentBackground)
 self.setFixedSize(self.sPixmap.size())

 def clearMessage(self):
 self.sMessage.clear()
 self.repaint()

 def showMessage(self,  theMessage, theAlignment, theColor):
 self.sMessage  = theMessage
 self.sAlignment = theAlignment
 self.sColor  = theColor
 self.repaint()

 def paintEvent(self, pe):
 aTextRect = QRect(self.rect())
 aTextRect.setRect(aTextRect.x()+5, aTextRect.y()+5, 
 aTextRect.width()-10, aTextRect.height()-10)
 aPainter = QPainter(self)
 aPainter.drawPixmap(self.rect(), self.sPixmap)
 aPainter.setPen(self.sColor)
 aPainter.drawText(aTextRect, self.sAlignment, self.sMessage)

 def showSplash(self,  delay, messages, alignment, color):
 delay = 0
 #self.messages = messages
 alignment = 0
 color = QColor(color)

 class SleeperThread(QThread):
 msecs = 0
 QThread.msleep(msecs)
 aSplashScreen = TeSplashScreen(self.sPixmap)
 aSplashScreen.show
 for i in range(len(messages)):
 aSplashScreen.showMessage(messages[i], alignment, color)
 SleeperThread.msleep(delay)




 -

 Best Regards
 Muhammad Bashir Al-Noimi
 My Blog: http://mbnoimi.net


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




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

Re: [PyQt] Delaying splash screen

2011-09-07 Thread Nick Gaens
, const QColor color)
 {
 class SleeperThread : public QThread
 {
 public:
 static void msleep(unsigned long msecs) {QThread::msleep(msecs);}
 };

 TeSplashScreen* aSplashScreen = new TeSplashScreen(sPixmap);
 aSplashScreen-show();

 for(int i=0; imessages.count();++i)
 {
 aSplashScreen-showMessage(messages[i], alignment, color);
 if(idelaies.count())
 SleeperThread::msleep(delaies[i]);
 else
 SleeperThread::msleep(defaultDelay);
 }

 delete aSplashScreen;
 }


 --
 Best Regards
 Muhammad Bashir Al-Noimi
 My Blog: http://mbnoimi.net


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




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

Re: [PyQt] Text and Image Alignment

2011-08-17 Thread Nick Gaens
Try this method:
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtoolbutton.html#setToolButtonStyle
with one of these values:
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qt.html#ToolButtonStyle-enum
.

E.g.:

yourButton = QtGui.QToolButton()
yourButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
yourButton.setText(Some text)
yourButton.setIcon(QtGui.QIcon(./images/someImage.png))
yourButton.setIconSize(QtCore.QSize(140, 140))
yourButton.clicked.connect(self.onButtonClicked)

On Wed, Aug 17, 2011 at 03:39, uahmed gleam.uah...@gmail.com wrote:

 Hi

 Thank you for the reply i search for it

 http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtoolbutton.html

 but unfortunately i didnt get any of such method .

 On Wed, Aug 17, 2011 at 3:28 AM, Josh Stratton 
 strattonbra...@gmail.comwrote:

 QToolbarButton has a value for putting text underneath, which may be
 more what you want.

 On Tue, Aug 16, 2011 at 3:20 PM, uahmed gleam.uah...@gmail.com wrote:
  HI
 
  I want to do alignment in  image and text , i want that image should be
 on
  center top and text should be at the bottom of image . I search for it
 but
  didnt get the  relevant search result . Can you please tell me how to do
  that ?
 
  Chunk of Code for Button Without Text:
 
  button = QtGui.QPushButton(widget)
  button.setIcon(QtGui.QIcon('default.gif'))
  button.setIconSize(QtCore.QSize(100,100))
  button.setGeometry(xval,yval, 130, 130)
  button.connect(button, QtCore.SIGNAL('clicked()'),
  partial(calluser, user_Handle))
 
  Chunk of Code for Button With Text:
 
  button = QtGui.QPushButton(widget)
  button.setIcon(QtGui.QIcon('default.gif'))
  button.setIconSize(QtCore.QSize(100,100))
  button[text].setText(QtCore.QString(user_Handle))
  button.setGeometry(xval,yval, 130, 130)
  button.connect(button, QtCore.SIGNAL('clicked()'),
  partial(calluser, user_Handle))
 
  Thank You
 
  Ahmed
 
  ___
  PyQt mailing listPyQt@riverbankcomputing.com
  http://www.riverbankcomputing.com/mailman/listinfo/pyqt
 



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




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

Re: [PyQt] Help with Login Dialog / QThread issues

2011-08-08 Thread Nick Gaens
I've quickly created this for you, hope it helps a bit.

Note: it's not working 100%, since the main event loop isn't terminated
after the dialog is closed.


On Mon, Aug 8, 2011 at 16:58, Baz Walter baz...@ftml.net wrote:

 On 08/08/11 14:58, Eric Frederich wrote:

 I'm just a little confused on what connections to make.
 I'm sure I could get something working but I'd be going about it the wrong
 way.

 Forget my original post.

 This is what I want.
 I want a login dialog with username, password and group.
 I want that dialog to stay up until the login is successful or user hits
 cancel.
 I have a QThread subclass for logging in.
 It emits either success or fail, and with fail it provides some
 text feedback.
 When the login thread starts a progress bar should start animating.

 This is where I am completely lost as far as connections go.
 The QDialogButtonBox has accepted, rejected.
 The QDialog has accepted, rejected.
 My login thread has success, and fail.
 There are clicked() signals as well.

 Its not complicated, but I'm new to Qt and PyQt.
 I think I need someone to spell it out for me.


 okay. in designer, open up View - Signal/Slot Editor, remove the
 buttonBox.accepted() connection, and then re-compile.

 next, in your LoginDialog class, rename your accept method to, say,
 handleAccepted, and connect it to the accepted() signal of the buttonBox:

self.buttonBox.accepted.**connect(self.handleAccepted)

 finally, in handleAccepted, replace the thread connection with:

self.lt.finished.connect(self.**accept)

 (obviously, i haven't tested this at all, but hopefully it will give you
 the general idea).


 __**_
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.**com/mailman/listinfo/pyqthttp://www.riverbankcomputing.com/mailman/listinfo/pyqt




-- 
Nick Gaens


LoginDialog.py
Description: Binary data


main.py
Description: Binary data
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] widget swap/widget on top

2011-07-27 Thread Nick Gaens
I think you should take a look at window modality (
http://doc.qt.nokia.com/latest/qwidget.html#windowModality-prop).

On Wed, Jul 27, 2011 at 07:46, ad3d alhaddeshpa...@gmail.com wrote:


 Hi guys,

   if i press a button on mainwindow i want another widget i.e. widget1 to
 popup, but that widget1 should be on top and the mainwindow should be
 disabled.. same should happen if i try to open a new widget i.e. widget2 by
 pressing a button on widget1 (widget 2 should be on top and other 2 widgets
 should be disabled)

  in this process i dont want to hide the disabled widgets/windows..

  Can someone plz guide me to achieve the same..

  Thanx in advance

 Regards,
 ad3d
 --
 View this message in context:
 http://old.nabble.com/widget-swap-widget-on-top-tp32145442p32145442.html
 Sent from the PyQt mailing list archive at Nabble.com.

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




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

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

2011-02-15 Thread Nick Gaens
This can be easily achieved by doing the math yourself.

Something like:

months = (now.year() - joiningDate.year()) * 12
 months += now.month() - joiningDate.month()


Wkr,


On Mon, Feb 14, 2011 at 18:46, alhad deshpande alhaddeshpa...@gmail.comwrote:

 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 listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt




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

Re: [PyQt] 'module' object has no attribute 'StackedWidget'

2011-01-24 Thread Nick Gaens
Indeed, IIRC, StackedWidget had to be renamed to QStackedWidget..

Wkr,

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

Re: [PyQt] problem in invoking event of QDateEdit embedded in QTableWidget cell

2011-01-21 Thread Nick Gaens
Something like:

dt_d = new QTimeEdit()

dt_d.timeChanged.connect(self.onTimeChanged)

myTableWidget.setCellWidget(row, col, dt_d)

...

def onTimeChanged(self, time):

print time


Btw, I assume you mean
'timeChangedhttp://doc.qt.nokia.com/4.7/qdatetimeedit.html#timeChanged'
instead of 'dateChanged' when using a QTimeEdit :-)?


On Fri, Jan 21, 2011 at 08:31, ad3d alhaddeshpa...@gmail.com wrote:


 i have added QTimeEdit in a QTableWidget cell using setCellWidget
 its name is dt_d

 Now i want to write a function on which will be triggered on dateChanged
 event

 but the problem i am facing is its not accepting dateChanged trigger as
 well
 as its not accepting itemChanged event of QTableWidget

 can some plz tell me how can i write a function which will be triggered
 when
 i change d date in QDateEdit which is embedded in a cell of a QTableWidget

 ITS A BIT URGENT
 PLZ HELP

 THANX IN ADVANCE
 --
 View this message in context:
 http://old.nabble.com/problem-in-invoking-event-of-QDateEdit-embedded-in-QTableWidget-cell-tp30726350p30726350.html
 Sent from the PyQt mailing list archive at Nabble.com.

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




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

Re: [PyQt] QMainWindow bug?

2011-01-18 Thread Nick Gaens
- Win7 64bit
- Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit
(Intel)] on win32
- Qt v4.7.0
- PyQt GPL v4.8.1 for Python v2.6

Result: no crashes, works like a charm..

On Tue, Jan 18, 2011 at 20:32, Vicent Mas uve...@gmail.com wrote:

 Hi,

 it seems there is a bug in QMainWindow.createPopupMenu. In my system
 (Windows XP, Python 2.6, PyQt 4.8.2 installed using the Windows
 installer), when I run the attached script and close the created
 QMainWindow, an error dialog appears saying that python.exe has found
 a problem and must be closed.

 Could someone confirm this behavior? Thanks.

 Vicent

 --
 Share what you know, learn what you don't.

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




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

Re: [PyQt] Load font form file

2010-12-15 Thread Nick Gaens
On Windows, you have to place these font files in C:\Windows\Fonts after
which they can automagically be used as a QFont :-).

On Wed, Dec 15, 2010 at 04:29, Mikael Modin micke.mo...@gmail.com wrote:

 Hi,

 I've downloaded a new font that I want to use in my application, how
 do I get a QFont object to use with QLabel.setFont()?

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




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

Re: [PyQt] QDoubleValidate and Locale

2010-11-25 Thread Nick Gaens
I don't understand what your question is, exactly.

You say that when using the English (en) locale, a decimal . is accepted
as input (as it should), but when using the Spanish (es) locale, the comma
is also accepted as a decimal separator.

I'm not Spanish so I cannot verify the following, but I can imagine that
this is regular behaviour IF Spanish grammar allows you to write a comma in
decimal numbers :-P.

Anyway: a simple fix for not having to worry about this could be this:

enteredValue = yourLineEdit.text().replace(',', '.').toDouble()



Wkr,


2010/11/25 Juan José Gómez Romera jjgom...@gmail.com

 Hi, im using QDoubleValidate to check the imput in a QLineEdit, work great
 with en locale, only let write number and a point for decimals, but with es
 locale the QDoubleValidate let write also ,,so i have to add other imput
 check in code to avoid that.
 Im look for in QDoubleValidate documentation any reference to milliar comma
 or similar, but i dont find nothing to solve it, is this a bug or is normal?

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




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

Re: [PyQt] Range slider

2010-11-22 Thread Nick Gaens
Did you take a look at Qxt?

They have what you're looking
forhttp://jpnurmi.kapsi.fi/docs/classQxtSpanSlider.html#_details,
so it seems.. :-)

On Mon, Nov 22, 2010 at 21:21, Held Michael michael.h...@bc.biol.ethz.chwrote:

 Hi folks,

 has anybody hints how to make a custom ranger slider widget? (a QSlider
 with two handles)

 I found a very nice example here:

 http://blog.enthought.com/enthought-tool-suite/traits/new-double-slider-editor/

 but the code does the rendering on MacOS with Qt 4.7 not correctly. One
 handle is above the groove, but one below.

 Thanks a lot for your help!
 Michael


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




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

Re: [PyQt] adjusting layouts question

2010-11-12 Thread Nick Gaens
I've got no notice of a directly manipulated (using mouse dragging) column
width concerning QLayout's.. You could however do this programmatically by
coupling some other numerical input widget (QSpinBox) to the columnWidth
setter of your QLayout.


On Fri, Nov 12, 2010 at 16:27, dizou di_...@yahoo.com wrote:


 I have a widget with a a layout and some widgets:

 class MainWidget(QWidget):
def __init__(self, parent):

QWidget.__init__(self, parent)

gridLayout = QGridLayout()
gridLayout.addLayout(treeControlLayout, 0, 0)
gridLayout.addWidget(self.tree, 1, 0)
gridLayout.addLayout(viewControlLayout, 0, 1)
gridLayout.addWidget(self.view, 1, 1)
gridLayout.addLayout(viewInfoLayout, 1, 2)
gridLayout.addLayout(viewControlLayoutBottom, 2, 1)

self.setLayout(gridLayout)

 This widget has 3 columns. How do I make it so that the user can adjust the
 width of the column?
 --
 View this message in context:
 http://old.nabble.com/adjusting-layouts-question-tp30200354p30200354.html
 Sent from the PyQt mailing list archive at Nabble.com.

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




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

Re: [PyQt] How can i capture activated signal of Tray Icon??

2010-11-10 Thread Nick Gaens
And it does

print(Tray icon single clicked)


twice?


On Wed, Nov 10, 2010 at 16:30, Jebagnana Das jebagnana...@gmail.com wrote:


 Thanks pete for your reply.

 I think you've misunderstood the core of the problem. The problem here is
 not the elif construct(Even changed the code, had no effect).

 If we double click on the tray icon, on completion of the first click this
 function gets called, and once again it's called when you finish your second
 click.. Any solutions...

 Am Tuesday 09 November 2010 15:08:29 schrieb Jebagnana Das:
  Thanks Zoltan.. It did help a lot.. But if i want to capture single
 click
  and double click events of the mouse separately i'm afraid this can't be
  used..
 
  def onTrayIconActivated(self, reason):
  if reason == QSystemTrayIcon.DoubleClick:
  print('tray icon double clicked')
 
  if reason == QSystemTrayIcon.Trigger:
  print(Tray icon single clicked)
 
  If i double click the tray icon it executes both if conditions. Any way
 of
  resolving this?. Thanks again..

 elif instead of second if perhaps?

 Pete


 --

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

 End of PyQt Digest, Vol 76, Issue 18
 



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




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

Re: [PyQt] simple charts with PyQT

2010-11-05 Thread Nick Gaens
You can take a look at the pygooglechart module. The generated chart is in
fact a .png-image, which can be easily loaded into a QPixMap e.g.. (Adds the
requirement of an internet connection though.)

On Fri, Nov 5, 2010 at 13:08, Vincent Vande Vyvre 
vincent.vandevy...@swing.be wrote:

  Le 05/11/10 12:46, bar tomas a écrit :

 Hi,
 I was just wondering if someone could advise me on the simplest way of
 integrating a few simple charts (pie chart, time series chart, etc)
 into my PyQT application.
 Are there any chart widget libraries accessible through PyQT? Can they
 be used through QT Designer?
 Is it easier to just paint the charts onself, are there any examples
 of this in PyQT code?
 Thanks a million for any help.

 Tomas Bar
 ___
 PyQt mailing list
 p...@riverbankcomputing.comhttp://www.riverbankcomputing.com/mailman/listinfo/pyqt

Maybe PyQwt :

 http://pyqwt.sourceforge.net/

 not tryed

 --
 Vincent V.V.
 Oqapy https://launchpad.net/oqapy

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




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

Re: [PyQt] Last update: Code Example -- Performance of QTreeView

2010-10-10 Thread Nick Gaens
)
c_a_b_action.setToolTip(Collapses all items under the selection.)
c_a_b_action.triggered.connect(self.collapse_all_below)

for action in (e_a_action, c_a_action, e_a_b_action, c_a_b_action):
self.addAction(action)

def expand_all(self):
self.expandAll()

def collapse_all(self):
self.collapseAll()

def expand_all_below(self):
def expand_all_below_recursive(parent_index):
self.expand(parent_index)
children_indexes = \
self.model.get_children_indexes(parent_index)
for child_index in children_indexes:
expand_all_below_recursive(child_index)

indexes = self.selectedIndexes()
if indexes:
index = indexes[0]
expand_all_below_recursive(index)

def collapse_all_below(self):
def collapse_all_below_recursive(parent_index):
self.collapse(parent_index)
children_indexes = \
self.model.get_children_indexes(parent_index)
for child_index in children_indexes:
collapse_all_below_recursive(child_index)

indexes = self.selectedIndexes()
if indexes:
index = indexes[0]
collapse_all_below_recursive(index)

 class TreeModel(QtCore.QAbstractItemModel):

def __init__(self, aux_root_view_item, parent):
super(TreeModel, self).__init__(parent)
self.aux_root_view_item = aux_root_view_item
self.active_columns = parent.active_columns

def rowCount(self, parent_index):
parent_view_item = self.view_item_from_index(parent_index)
if parent_view_item is None:
return 0
return len(parent_view_item.children)

def get_children_indexes(self, parent_index):
children_indexes = []
for row_no in range(self.rowCount(parent_index)):
children_indexes.append(self.index(row_no, 0, parent_index))
return children_indexes

def columnCount(self, parent):
return len(self.active_columns.columns)

def data(self, index, role):
if role == QtCore.Qt.TextAlignmentRole:
return int(QtCore.Qt.AlignTop|QtCore.Qt.AlignLeft)
if role != QtCore.Qt.DisplayRole:
return None
view_item = self.view_item_from_index(index)
try:
data = getattr(view_item.runtime_item,
   self.active_columns.columns[index.column()])
except AttributeError:
data = 
return data

def headerData(self, section, orientation, role):
if (orientation == QtCore.Qt.Horizontal and
role == QtCore.Qt.DisplayRole):
assert 0 = section = len(self.active_columns.columns)
return self.active_columns.columns[section]
return QtCore.QVariant()

def index(self, row, column, parent_index):
view_item_parent = self.view_item_from_index(parent_index)
return self.createIndex(row, column,
view_item_parent.children[row])

def parent(self, child_index):
child_view_item = self.view_item_from_index(child_index)
if child_view_item is None:
return QtCore.QModelIndex()
parent_view_item = child_view_item.parent
if parent_view_item is None:
return QtCore.QModelIndex()
grandparent_view_item = parent_view_item.parent
if grandparent_view_item is None:
return QtCore.QModelIndex()
grandparent_view_item
row = grandparent_view_item.children.index(parent_view_item)
assert row != -1
return self.createIndex(row, 0, parent_view_item)

def view_item_from_index(self, index):
return (index.internalPointer()
if index.isValid() else self.aux_root_view_item)


 if __name__ == __main__:

run_time_item = RuntimeItem(Test, test_12, Test Item)
view_factory = DummieViewItemFactory(run_time_item, max_items=5000)
active_colums = ActiveColumns([name, ident, item_type])

app = QtGui.QApplication(sys.argv)
tree_view = TreeView(view_factory.aux_root_view_item, active_colums)
app.setApplicationName(IPDM)
tree_view.show()
app.exec_()





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




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

[PyQt] Clearing and disabling a QLineEdit causes a cursor to be shown?

2010-10-09 Thread Nick Gaens
Hello everybody,

When trying to reset a form, consisting out of some QLineEdits and
QSpinBoxes, I use this small piece of code:


for field in [self.customerDataLayout.itemAtPosition(row, 1) for row in
xrange(0, self.customerDataLayout.rowCount())]:
widget = field.widget()
widget.clear()
widget.setEnabled(False)


The result is that all those QLineEdits and QSpinBoxes are in fact 'cleared'
and disabled, but the side effect is that some sort of vertical line
(cursor?) is drawn in each QLineEdit (see the attachment for a screenshot of
this problem).

Is this normal behavior? How do I disable this vertical line to be shown?


-- 
Nick Gaens
attachment: QLineEdits_gone_wrong.png___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Optimizing WebView display

2010-09-01 Thread Nick Gaens
Or, profile your application using a tool like Valgrind to find out what
parts of your code in particular should be worth looking at for optimizing
purposes. Remember the 90/10 rule: a 90 percent speed increase can be
achieved by optimizing only 10 percent of your code.

On Wed, Sep 1, 2010 at 06:02, Taylor Carrasco crackerbu...@gmail.comwrote:

 Is the code available for us to take a look at for possible optimizations

 On Tue, Aug 31, 2010 at 9:09 AM, alanm m...@alandmoore.com wrote:

 I wrote a small browser in PyQT4 using QWebView, of course.  The browser
 runs
 well and does what I need, but when I deployed it to my thin clients, it
 was
 far to slow to use.

 In fact, most modern browsers were; I had to settle on Epiphany because
 all
 the other browsers I tried were far to slow at showing or interacting with
 HTML controls (text inputs, drop-downs, etc).

 I tried disabling all QT effects in the Trolltech.conf file, and various
 graphicssystem settings on Qapplication, but it's still slow.

 Are there any other places where graphical effects can be toned down or
 optimized?  I still notice a bit of a fade-in effect on drop-downs even
 when
 all QT Gui effects are disabled, and this is rendering really badly on the
 thin clients (slow and lots of screen artifacts).
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt



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




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

Re: [PyQt] Pixel Manipulation Very Slow?

2010-08-20 Thread Nick Gaens
Hello,

First, you might want to change both range()-methods in the for-loops to *
xrange()*, since the latter is way faster.

Anyway, to recognize which calls are slowing down your calculations, try to
profile your application (using e.g. valgrind).

In an ultimate case, when in need of some serious responsiveness on
multi-megapixel-images, you can use SIP, SWIG, Cython or cTypes  to let a
C(++)-method do this job at a blazing speed: I once reached sub-second color
conversion runs on a 16Mpixel image on an average laptop CPU.. Python is ok
for this as long as it's good enough for you, but since it's quite slow by
implemenation, you might want to take a look at some alternative approaches.


On Fri, Aug 20, 2010 at 2:21 PM, zhang jian zhangm...@gmail.com wrote:

 Hello,

 This is my first post. I want to write a simply app layering several images
 each with different weighting. This problem is pixel manipulation by QImage
 appears to be quite slow. My code is:

 w = image.width()
 h = image.height()

 for j in range(h):
 for i in range(w):
  col = QtGui.QColor(image.pixel(i, j))

  col.setRed(col.red()*self.fKd)
  image.setPixel(i, j, col.rgb());



 painter.drawImage(0, 0, image)

 Just one image changed in red channel. It took about 5 seconds to redraw a
 1280 X 720 image any time I changed Kd. Far from interactive. I'd like to
 know is there any way to do stuff like that faster? Or calculating a million
 pixels in PyQt is just a bad idea? Any advice should be appreciated.

 Thanks,

 zhang

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




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

Re: [PyQt] possible to change the central widget in a QMainWindow

2010-08-11 Thread Nick Gaens
You might want to set a QStackedWidget as your centralWidget and toggle the
content of that first one?


On Wed, Aug 11, 2010 at 6:51 PM, Danny Shevitz shev...@lanl.gov wrote:

 ilman/listinfo/pyqthttp://www.riverbankcomputing.com/mailman/listinfo/pyqt


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

Re: [PyQt] Clear/delete widget in a Layout

2010-08-09 Thread Nick Gaens
Take a look at QStackedWidget or QStackedLayout.


On Mon, Aug 9, 2010 at 12:59 AM, starglider develop 
starglider@gmail.com wrote:

 Hi,
 I have a layout and need to remove all the widgets in the layout
 to populate with other widget,
 but didn't find a way of doing that.
 Any ideas.

 Thanks in advance.

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




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

Re: [PyQt] Add menu at runtime

2010-07-05 Thread Nick Gaens
You could try to call menuBar.update() after having added / removed menu's
or actions to or from it..


On Sun, Jul 4, 2010 at 9:19 PM, F.A.Pinkse fapin...@gmail.com wrote:

 Hi All,

 I want to add a menu at runtime to an already exsiting menubar.

 How do I do that?


 Tnanks

 Frans.


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




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

Re: [PyQt] widgets and references in python

2010-06-29 Thread Nick Gaens
You could put those QLabels in a list e.g.:

labels = []
for i in range(3):
label = QLabel('%d' % i)
label.show()
labels.append(label) # This line prevents the garbage collection of
label after each iteration, since there's a reference to it in this list

A second option could be to add such a QLabel to a layout. This also means
the layout will store a reference to this label, preventing it from being
deleted automatically.

Nick

On Tue, Jun 29, 2010 at 11:01 AM, V. Armando Solé s...@esrf.fr wrote:

 victor wrote:

 hello list,

 i have encountered an issue that i have reduced to this sample code:

 if __name__ == '__main__':
import sys
from PyQt4.QtGui import QLabel
from PyQt4.QtCore import QTimer
from PyQt4.QtGui import QApplication
app = QApplication(sys.argv)
for i in range(3):
l = QLabel('%d' % i)
l.show()
QTimer.singleShot(5000, app.quit)
app.exec_()

 because i'm using the same variable to reference the instances, only one
 instance remains (the last one) which is not really what i expect.

 what is the way to create several widgets in a loop? thanks.

  As with any python object, you have to keep at least a reference to each
 of the generated objects in order to prevent garbage collection.

 Armando


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




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

Re: [PyQt] signal twice emit

2010-06-29 Thread Nick Gaens
Try this way of connecting:

self.btn_save.clicked.connect(self.p)


On Tue, Jun 29, 2010 at 3:06 PM, Csaba Toth csaba.t...@i3rendszerhaz.huwrote:

 Hi,

 i have a problem with recent PyQt versions, sometimes a signal (what i
 saw was with button click signal) emitted twice.

 for example i use this:

 def p(self, clicked=False):
print('emitted')
 self.connect(self.btn_save, QtCore.SIGNAL(clicked(bool)), self.p)

 and if i press the button it wrotes twice the 'emitted' to console.
 What i make wrong?

 thanks in advance,
 Csaba
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt




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

Re: [PyQt] Setting QComboBox clicked on width

2010-05-27 Thread Nick Gaens
Hello, try something like:

self.comboBox.currentIndexChanged.connect(self.onCurrentIndexChanged)


 def onCurrentIndexChanged(self, newIndex):

self.comboBox.adjustSize() # Don't know if this works automagically, but
 given the newIndex argument,

you could fetch the current
 selected string and calculate the required width yourself in the worst case



On Thu, May 27, 2010 at 12:01 PM, aaron barclay aaron.diplo...@gmail.comwrote:

 Hello,

 I am having trouble setting a QComboBox. I would like the ComboBox to be
 quite narrow, that is easy enough, but when clicked on I would like the
 combobox to expand the listed results to full width of the text. Is this
 possible? Any help appreciated.

 Regards,
 aaron.


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




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

[PyQt] QTableWidget: cannot alter text of header labels

2010-05-20 Thread Nick Gaens
Hello PyQt,

I'm wondering why I can't change the text that's displayed in the horizontal
or vertical header of my standard QTableWidget.

- Constructor and simple count specification

self.tw = QtGui.QTableWidget()

self.tw.setColumnCount(5)



- Attempt 1:


 self.tw.setHorizontalHeaderLabels((a, b, c, d, e)) # Doesn't
 work, the default 1 ... 5 are still shown

self.tw.setHorizontalHeaderItem(1, QtGui.QTableWidgetItem(b)) # Doesn't
 work, the header label isn't updated to b



- Attempt 2:

twi = QtGui.QTableWidgetItem(b)

self.tw.setHorizontalHeaderItem(1, twi)

self.tw.horizontalHeader().setVisible(True) # Nope, this doesn't work either



- Attempt 3:

twi = QtGui.QTableWidgetItem()

self.tw.setHorizontalHeaderItem(1, twi)

self.tw.horizontalHeader().setVisible(True) # Nope, this doesn't work
 either

_twi = self.tw.horizontalHeaderItem(1)

_twi.setText(b) # Nope, doesn't get updated by this either..



What am I doing wrong? How much more combinations of horizontalHeader-stuff
do I have to try in order to do this simple thing?


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

Re: [PyQt] Searching method for QTableVew

2010-05-04 Thread Nick Gaens
I would take a look at QTableWidget instead of QTableView.

For such a tableWidget:

def highlightResults(self, enteredText):
for row in xrange(0, tableWidget.rowCount()):
tableWidgetItem = tableWidget.item(row, 0) # Second argument is
column
if tableWidgetItem.text().contains(enteredText):
tableWidgetItem.setBackground(QBrush(Qt.blue))


Also, connect the lineEdit's textChanged signal to the method above like
this:

lineEdit.textChanged.connect(self.highlightResults)


On Tue, May 4, 2010 at 1:49 AM, AON LAZIO aonla...@gmail.com wrote:

 Hi,
 Suppose I want to search for some elements in QTableView when I type
 into a lineedit box. How can I locate the item in the table (The table
 direcly highlight the items searched if found)
 Which method should I use?
 Thanks in advance

 Aonlazio

 --
 Passion is my style

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




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

Re: [PyQt] QLineEdit drop event

2010-04-28 Thread Nick Gaens
Creating a small derived class and a new instance of it isn't that much of
an effort in Python, given you only need to reimplement the dropEvent
method. I don't think there are other solutions, based upon the doc's
suggestion..

Although I must say that I've came across some code here on the list some
time ago that showed how to capture click events on a QLabel without
subclassing it, so you might want to search for that snippet, since it's
basically the same combination of items (event on a QWidget)..

On Wed, Apr 28, 2010 at 2:04 PM, Sebastian Elsner 
sebastianels...@freenet.de wrote:

 Hello,

 I designed a GUI with Qt Designer. The GUI has several QLineEdits. I'd like
 to be able to drop files from the windows explorer to this line edits and
 display the path of the files. Documentation suggests that I subclass the
 line edit and reimplement  the dropEvent. Would not be a problem, but my
 Line edit widget already exists on the dialog, so how to subclass without
 creating a completely new instance? Or is there another way I don't see?

 Thank you for any suggestions

 Regards

 Sebastian




 --
 Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt




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

Re: [PyQt] QSystemTrayIcon not working with py2exe

2010-04-27 Thread Nick Gaens
Without insight to your setup.py, it's a lot of guessing ;-).

You might have forgotten to add the icon itself as a resource to setup.py?

On Tue, Apr 27, 2010 at 1:33 PM, Sebastian Elsner 
sebastianels...@freenet.de wrote:

 Hello,

 My application has a system tray icon, which gets its data from a ressource
 compiled via pyrcc. When started via double click on the .py script the icon
 shows up as expected. But when I compile with py2exe It does not. I also
 tried not using pyrcc, same result. Is this a known problem? Any ideas why
 this would happen?

 Thanks

 Sebastian


 --
 Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt




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

Re: [PyQt] Carol Newman

2010-04-20 Thread Nick Gaens
Please someone remove this address from the lists, because of spamming..

On Tue, Apr 20, 2010 at 11:13 PM, Zac Burns zac...@gmail.com wrote:

 http://www.ristorantealpirata.com/home.php

 --
 Zachary Burns
 (407)590-4814
 Aim - Zac256FL
 Production Engineer
 Zindagi Games
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt




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

Re: [PyQt] How to disable delete button on forms

2010-04-19 Thread Nick Gaens
Eum.. What close button? Are you using QtDesigner or something? Show us
what you're doing by providing some code.

Nick

On Mon, Apr 19, 2010 at 5:25 PM, Jothybasu K Selvaraj
jothyb...@gmail.comwrote:

 Sorry, I meant close button.

 Thanks,

 Jothy


 On Mon, Apr 19, 2010 at 4:24 PM, Jothybasu K Selvaraj jothyb...@gmail.com
  wrote:

 Hi all,

 How can I disable the delete button on a form?

 Any hints?

 Thanks,

 Jothy



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




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

Re: [PyQt] Drag and drop: Pixmap and lineedit/label problem

2010-04-13 Thread Nick Gaens
In PyQt4, this is often solved by placing an underscore after the method..
like QDialog.exec_() and QWidget.raise_()

Documentation:
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwidget.html#raise


On Tue, Apr 13, 2010 at 7:06 PM, Anshul Jain aj.phoenix...@gmail.comwrote:

 I just tried using raise(). but it's alredy a keyword in python!! how to
 use it?


 On Tue, Apr 13, 2010 at 9:36 PM, Anshul Jain aj.phoenix...@gmail.comwrote:

 Can you just give me an example on how to use this?
 Thanks for your reply.




 On Tue, Apr 13, 2010 at 3:46 AM, Nick Gaens m...@nickgaens.com wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Try to call raise() on the widget.

 http://doc.trolltech.com/4.6/qwidget.html#raise


 On 12/04/2010 23:33, Anshul Jain wrote:
  Hello
 
  I'm trying to implement drag and drop and also trying to display a
  label/LineEdit on my image. But the problem is that whenever i'm
 dragging
  and dropping my image and using the label.move(x,y) to move the label
 to
  appropriate position it gets hidden behind the image. :(
 
  How can i fix this up. I am also attaching the code. Please tell me
 what
  should i do.
 
 
  Regards
  Anshul
 
 
 
 
  ___
  PyQt mailing listPyQt@riverbankcomputing.com
  http://www.riverbankcomputing.com/mailman/listinfo/pyqt

 - --
 - -- Nick Gaens
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.10 (MingW32)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

 iQEcBAEBAgAGBQJLw5uyAAoJEHryXS9yfz/RoO0H/1YxvmWs/0n5tStAFLtT2EHI
 W7RF+/4gX9Yi0YG1qowTg2Cuxa5zg8wx298CgLpGMQ4m0iF09wBJxszJhWtbo74A
 pfeLVNWR/pY9Ps/G/OeS0OgxW0KiTlOy9GO7V1HG9WyhC4KsYXRD1Xqq50jYLuOO
 8XObYKSzAL2UAxAdxPK/f9H1sJtJY4ASsSe5Q5Kq6L+6gCs4dbeCU/KfMqc+uJaK
 fzUXzqsk65ahk03QbA2sAtWXi3098igOMhSizl26OpKi8LG8bpuxHGLUurB3uLhc
 a1l0Vd7MzXOuapqM0YfSCU9oN3CAtglOt+HOhWOswot+ICWMDK8OXTDgFW4lr+s=
 =Xb21
 -END PGP SIGNATURE-
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt





 --
 NSIT B.E. student (Computers)
 http://anshul.pcunified.com
 http://pcunified.com




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

Re: [PyQt] Drag and drop: Pixmap and lineedit/label problem

2010-04-12 Thread Nick Gaens
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Try to call raise() on the widget.

http://doc.trolltech.com/4.6/qwidget.html#raise


On 12/04/2010 23:33, Anshul Jain wrote:
 Hello
 
 I'm trying to implement drag and drop and also trying to display a
 label/LineEdit on my image. But the problem is that whenever i'm dragging
 and dropping my image and using the label.move(x,y) to move the label to
 appropriate position it gets hidden behind the image. :(
 
 How can i fix this up. I am also attaching the code. Please tell me what
 should i do.
 
 
 Regards
 Anshul
 
 
 
 
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

- -- 
- -- Nick Gaens
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJLw5uyAAoJEHryXS9yfz/RoO0H/1YxvmWs/0n5tStAFLtT2EHI
W7RF+/4gX9Yi0YG1qowTg2Cuxa5zg8wx298CgLpGMQ4m0iF09wBJxszJhWtbo74A
pfeLVNWR/pY9Ps/G/OeS0OgxW0KiTlOy9GO7V1HG9WyhC4KsYXRD1Xqq50jYLuOO
8XObYKSzAL2UAxAdxPK/f9H1sJtJY4ASsSe5Q5Kq6L+6gCs4dbeCU/KfMqc+uJaK
fzUXzqsk65ahk03QbA2sAtWXi3098igOMhSizl26OpKi8LG8bpuxHGLUurB3uLhc
a1l0Vd7MzXOuapqM0YfSCU9oN3CAtglOt+HOhWOswot+ICWMDK8OXTDgFW4lr+s=
=Xb21
-END PGP SIGNATURE-
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] [SOLVED]Syntax to access a blob column on sqlite

2010-03-29 Thread Nick Gaens
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Why do you copy construct blobField on the line where you bindValue()
it? I assume it's verbose and can be omitted..

On 29/03/2010 15:36, IloChab wrote:
 2010/3/28 IloChab iloc...@gmail.com:
 I tried in this way:

 blobField = QtCore.QVariant ( QtCore.QByteArray ([1,2,3,]) )
 query = QtSql.QSqlQuery()
 query.prepare(INSERT INTO blobTable (blobColumn) VALUES(?))
 query.bindValue(0,(blobField,));
 query.exec_();


 ... and I got no error, but in the DB I find an empty field: (u'')


 Which is the correct syntax to store a blob field???

 
 
 
 The right way to do it was:
 
 
 blobField = QtCore.QByteArray ([1,2,3,])
 query = QtSql.QSqlQuery()
 query.prepare(INSERT INTO blobTable (blobColumn) VALUES(?))
 query.bindValue(0,  QtCore.QByteArray(blobField,))
 query.exec_()
 
 
 I hope this can be usefull to someone else!!
 
 Thank to the list anyway!
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJLsLCkAAoJEHryXS9yfz/RJ8wH/2b9Kcilct9L1ZMocNajEBw6
AoKi4rEEfxUFjdlpg+z73GenWjWoLjbaZGENuzTbtNsqt9LS1TJM8XkhfXGERmf9
6Jo3J22YeEwy08FeGW8a47FcQ0R0Rf0ufAnN2RVNrvMXHDkAUHE+Ymth1OIJHc3y
2Jlq5sO049U7mtavCUj0Xp+NXezDYlLtUQ0ybhDnEtQr857rGbjrmIPED/xn7/Ha
On1YP8zxRAclOx+lKxCclpdlenoSg3qT0bxERbKYsq68GMEWXk9pq/38tWO8p+QQ
6t/S99uNLRd4Jk/tVq3y+fs7DhXMM6V29L890glHg15nRn9F4Uk+DGub7cHRLwY=
=b0De
-END PGP SIGNATURE-
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] stylesheet sub-controlls

2010-03-24 Thread Nick Gaens
Hello Lennart,

By subcontrols, do you mean something like:

qpushbutton { color: white; }

qpushbutton:pressed { color: black; }

?

If so, you can set the same stylesheet to a widget as in the regular Qt,
it has little to do with PyQt itself, since the stylesheet is just a string
to be parsed.


On Wed, Mar 24, 2010 at 9:22 AM, Lennart Jansen lord@gmx.net wrote:

 Hi,

 are there stylesheet sub-controlls in pyqt like in qt? For example the
 widget Qprogressbar in qt got the sub-controll chunk, but i cant find
 anything like it in pyqt.

 I wish all of you a good day!
 --
 Sicherer, schneller und einfacher. Die aktuellen Internet-Browser -
 jetzt kostenlos herunterladen! http://portal.gmx.net/de/go/chbrowser
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt




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

Re: [PyQt] Delete a Laytou

2010-03-20 Thread Nick Gaens
I think it's best if you provide a stripped piece of code of what you've
achieved so far and let the list take a look at it..


On Fri, Mar 19, 2010 at 10:17 PM, starglider develop 
starglider@gmail.com wrote:

 Hi Nick,
 I'm trying to make it work without luck, is there any python example?
 The example that is in *Rapid GUI Programming With Python and Qt* is only
 for stackedwidgets.

 Thank you.



 On 19 March 2010 10:38, Nick Gaens m...@nickgaens.com wrote:

 Take a look at a QStackedLayout.. You can add multiple widgets, each
 having their own layout, to it and set it as the central widget of your
 mainwindow. There's no need for deleting a layout and set a new one, since
 you alternate between the added widgets / layouts.

 Check out http://doc.trolltech.com/4.3/qstackedlayout.html#details to see
 a short example..

 On Thu, Mar 18, 2010 at 11:39 PM, starglider develop 
 starglider@gmail.com wrote:

 Hi,
 I have a QMainWindow with a main Vertical Layout and  3 HLayouts and
 several Widgets in every layout,
 but the program needs to remove all the layouts to create another one
 with a widget.
 How can I remove the original layouts? I was unable to find an answer in
 the internet.

 Thank you in advance for your help.

 Regards

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




 --
 Nick Gaens

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



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




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

Re: [PyQt] Delete a Laytou

2010-03-19 Thread Nick Gaens
Take a look at a QStackedLayout.. You can add multiple widgets, each having
their own layout, to it and set it as the central widget of your mainwindow.
There's no need for deleting a layout and set a new one, since you alternate
between the added widgets / layouts.

Check out http://doc.trolltech.com/4.3/qstackedlayout.html#details to see a
short example..

On Thu, Mar 18, 2010 at 11:39 PM, starglider develop 
starglider@gmail.com wrote:

 Hi,
 I have a QMainWindow with a main Vertical Layout and  3 HLayouts and
 several Widgets in every layout,
 but the program needs to remove all the layouts to create another one with
 a widget.
 How can I remove the original layouts? I was unable to find an answer in
 the internet.

 Thank you in advance for your help.

 Regards

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




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

Re: [PyQt] Writing user defined function in the existing application

2010-03-11 Thread Nick Gaens
Yes, take a look at the resizeEvent(event) method:
http://doc.trolltech.com/4.6/qwidget.html#resizeEvent

http://doc.trolltech.com/4.6/qwidget.html#resizeEvent:-)

Nick

On Thu, Mar 11, 2010 at 8:19 AM, sindhuja venkat
sindhujaven...@gmail.comwrote:

 Hello all,

 We can modify the close event and add some alerts or dialogs in the
 application using  def closeEvent()  function. Likewise Is there any way
 to modify the minimize event.

 Thanks in advance...

 --
 sindhu

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




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

Re: [PyQt] Style sheet properties..

2010-03-10 Thread Nick Gaens
You might take a look at so called Selector types (
http://qt.nokia.com/doc/4.3/stylesheet-syntax.html#selector-types). Given a
QDialog and its children (e.g. QPushButtons), this can prevent this
cascading behaviour of styles, although I've never had any problems with
that without using this way of selecting matching objects..

Can you show a small piece of code (small stylesheet and the way you apply
it) please?

On Tue, Mar 9, 2010 at 9:05 PM, Jebagnana Das jebagnana...@gmail.comwrote:

 Hello all,

 If i apply a property to a parent widget it is automatically applied for
 child widgets too.. Is there any way of preventing this??

 For example if i set background color as white in a dialog then any
 button,combo boxes and scroll bars(within the dialog) looks white and it
 lacks it's native look(have to say it's unpleasant to the eyes(esp. in unix)
  ugly).. Is there any way that i can apply the stylesheets only to a parent
 widget not to it's children? can i exclude specifically some child widgets
 from not inheriting parent SS properties??

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




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

Re: [PyQt] Style sheet properties..

2010-03-10 Thread Nick Gaens
??
 
  ___
  PyQt mailing listPyQt@riverbankcomputing.com
  http://www.riverbankcomputing.com/mailman/listinfo/pyqt
 




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

Re: [PyQt] How to minimize the QMainwindow to the system Tray

2010-03-08 Thread Nick Gaens
Where is the systray-part in that example?

On Mon, Mar 8, 2010 at 7:32 PM, Russell Valentine r...@coldstonelabs.orgwrote:

 Reimplement changeEvent in QMainWindow, something like below:

def changeEvent(self, e):
if(e.type() == QtCore.QEvent.WindowStateChange and
 self.isMinimized()):
self.hide()
e.accept()
return
else:
super(Window, self).changeEvent(e)

 sindhuja venkat wrote:

 Hi..I am doing an application in PyQt4.
 Do anyone know how to reduce the application to the system Tray?
 When I click the minimize button, the application should go to the tray.
 If anybody knows, your help is most welcome.


 

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


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




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

Re: [PyQt] Problem displaying images in QLabel (Newbie)

2010-03-01 Thread Nick Gaens
Well, you can print the output of this method:
http://doc.trolltech.com/4.6/qfile.html#exists, after feeding it the path
you're using at the moment..

 http://doc.trolltech.com/4.6/qfile.html#exists

On Sun, Feb 28, 2010 at 9:27 PM, bar tomas barto...@gmail.com wrote:

 Many thanks for trying to help me.
 I think the image file can be found because I can preview the form ok
 from QtDesigner.
 Do I need to do any steps to convert the image to a resource? (i dont
 really understand the difference between an image and a resource in
 Qt).
 Many thanks again for your patience.

 On Thu, Feb 25, 2010 at 3:00 PM, Nick Gaens m...@nickgaens.com wrote:
  I'm guessing it has to do with the .png file not being found, but without
  some example code, only supernatural powered humans can help you :-).
 
  On Wed, Feb 24, 2010 at 4:11 PM, bar tomas barto...@gmail.com wrote:
 
  Hi,
  I'm programming in PyQt using the Eric4 IDE and QtDesigner.
  I've created a QLabel containing a png image that displays fine when
  previewing the form in QtDesigner, but when I execute  my python
  program from Eric, the image is not visible.
  Do you know what I'm doing wrong?
  Many thanks.
  ___
  PyQt mailing listPyQt@riverbankcomputing.com
  http://www.riverbankcomputing.com/mailman/listinfo/pyqt
 
 
 
  --
  Nick Gaens
 
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt




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

Re: [PyQt] Problem displaying images in QLabel (Newbie)

2010-02-25 Thread Nick Gaens
I'm guessing it has to do with the .png file not being found, but without
some example code, only supernatural powered humans can help you :-).

On Wed, Feb 24, 2010 at 4:11 PM, bar tomas barto...@gmail.com wrote:

 Hi,
 I'm programming in PyQt using the Eric4 IDE and QtDesigner.
 I've created a QLabel containing a png image that displays fine when
 previewing the form in QtDesigner, but when I execute  my python
 program from Eric, the image is not visible.
 Do you know what I'm doing wrong?
 Many thanks.
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt




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

Re: [PyQt] help with Qdate

2010-02-16 Thread Nick Gaens
What do you mean by a date edit widget?

Futhermore, you could check out the QDate
documentationhttp://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qdate.html.
Take a look at the method getDate() in particular..


On Tue, Feb 16, 2010 at 2:40 PM, NISA BALAKRISHNAN 
snisa.balakrish...@gmail.com wrote:

 hi,

 can anyone tel me how to get date entered  to date edit widget in a string
 format so that i can save it in a excel sheet.


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




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

Re: [PyQt] QGraphicsPixmapItem not showing set pixmap

2010-01-29 Thread Nick Gaens
It doesn't make that much sense to me.

 I did print QFile.exists('/.../.../pic1.png'); it outputs True.

Ok, great, so there is a file there, named pic1.png. What exactly is the
meaning of three dots for a folders name? I am asking this, because you say
in the next sentence:

 I am doing pic = QPixmap('/../../pic1.png')

As you can see, only two dots here, which would make more sense to me
(that's why I suggested ../../pic1.png, since this is a more common
construction).
Can you elaborate why there are three dots in your path to the image?

Secondly, did you take a look at the documents to use a resources-file?

Nick

On Thu, Jan 28, 2010 at 9:14 PM, dizou di_...@yahoo.com wrote:


 Can someone give me some more help about this?

 dizou wrote:
 
  I did print QFile.exists('/.../.../pic1.png'); it outputs True.
  I am doing pic = QPixmap('/../../pic1.png') not
  pic = QPixmap('../../pic1.png')
 
 
  nickgaens wrote:
 
  Did you try QFile.exists('/.../.../pic1.png') ?
 
  I'm guessing you are trying to do:
 
  pic = QPixmap('../../pic1.png') - note the change in the path to the
  image file.
 
 
  Nick
 
 
 
 

 --
 View this message in context:
 http://old.nabble.com/QGraphicsPixmapItem-not-showing-set-pixmap-tp27229352p27358788.html
 Sent from the PyQt mailing list archive at Nabble.com.

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




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

Re: [PyQt] QGraphicsPixmapItem not showing set pixmap

2010-01-21 Thread Nick Gaens

Did you try QFile.exists('/.../.../pic1.png') ?

I'm guessing you are trying to do:

pic = QPixmap('../../pic1.png') - note the change in the path to the 
image file.



Nick

On 20/01/2010 22:21, dizou wrote:

The PNG does exist. I did DisplayItem.ensureVisible(10, 10, 10, 10) and
DisplayItem.ensureVisible() and neither function did anything. There were no
errors though.

Jason H-3 wrote:
   

Simply, your PNG does not exist. Try print
QFile.exists('/.../.../pic1.png)
Or
You aren't looking at it. Try using ensureVisible() on it in case its
off-screen.




- Original Message 
From: dizoudi_...@yahoo.com
To: pyqt@riverbankcomputing.com
Sent: Tue, January 19, 2010 12:23:19 PM
Subject: [PyQt]  QGraphicsPixmapItem not showing set pixmap


I have:

class DisplayItem(QGraphicsPixmapItem):
 def __init__(self, parent, graphView=None):
 QGraphicsPixmapItem.__init__(self)

 pic = QPixmap(/.../.../pic1.png)
 self.setPixmap(pic)

and then when I do QGraphicsScene.addItem(DisplayItem), nothing shows up.
I can use the paint() function to draw my DisplayItem as my different
shapes
and stuff, so I have my QGraphicsScene and QGraphicsView setup correctly.
--
View this message in context:
http://old.nabble.com/QGraphicsPixmapItem-not-showing-set-pixmap-tp27229352p27229352.html
Sent from the PyQt mailing list archive at Nabble.com.

___
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 mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Downloading PyQt for Python 2.6

2010-01-21 Thread Nick Gaens

On the page you link to, there is this link:

http://riverbankcomputing.com/static/Downloads/PyQt4/PyQt-Py2.6-gpl-4.7-1.exe

Isn't this what you are looking for?

On 21/01/2010 1:04, Chris Bergstresser wrote:

On Wed, Jan 20, 2010 at 5:57 PM, Demetrius Cassidy
dcassid...@mass.rr.com  wrote:
   

Er, you could compile it from source. But afaik, 2.6.4 is the current python
version, yes? PyQt4 should also be already compiled for Python 2.6
 

I have never compiled anything from source in my life.  I don't
have a compiler installed on this machine, nor do I really feel like
finding, installing, and debugging one just to install this package.
The download page at
http://riverbankcomputing.com/software/pyqt/download has links for
Python 2.5-compatible PyQt 4.4.3, but that's all.

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

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


Re: [PyQt] QGraphicsGridLayout

2009-12-09 Thread Nick Gaens

Aron Bierbaum wrote:

I have been trying to use the QGraphicsGridLayout but I am running
into problems when I try to have a QGraphicsWidget span multiple
columns. The basic problem is that if I try to span a large widget in
the second row under four smaller widgets in the top row, the widgets
in the top row are not layed out correctly.

Does anyone have any idea what I might be doing wrong?

-Aron
  



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

Not providing us with a proper piece of example code? :-)

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

Re: [PyQt] TextEdit background color

2009-12-08 Thread Nick Gaens

Take a look at style sheets.

On 8-dec-2009, at 09:44, Nadav Chernin nadavcher...@gmail.com wrote:


Hi, i'm new for PyQt

I use TextEdit widget, and i want that it's background color will  
black (for example)


I tried to use TextEdit.setTextBackgroundColor but only background  
of text painted by black color.


How can i color all TextEdit area by any color?

Thanks, Nadav
___
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] Corrupted data in QDataStream

2009-12-02 Thread Nick Gaens
Hello everyone,

I'm trying to send a python-string via a QTcpSocket. I am using this
structure:


block = QtCore.QByteArray()
stream = QtCore.QTextStream(block, QtCore.QIODevice.WriteOnly)
stream  myPythonString

if myTcpSocket.isWritable():
myTcpSocket.write(block)
-

However, it now seems that there are some corrupted characters at the
beginning of the bytearray (or textstream) :-S..

A solution for this can be to call stream.flush() just before I stream
myPythonString to it..
In code:


block = QtCore.QByteArray()
stream = QtCore.QTextStream(block, QtCore.QIODevice.WriteOnly)
stream.flush() # removes the ascii dump successfully
stream  myPythonString

if myTcpSocket.isWritable():
print writing data to , str(socket.peerAddress().toString())
myTcpSocket.write(block) # crashes here
-

But at this point, the program crashes at the last line when actually
writing to the socket.. How come? I found out that this crash can be
reproduced anywhere when calling stream.string() just after streaming
myPythonString to the textstream..
In code:


block = QtCore.QByteArray()
stream = QtCore.QTextStream(block, QtCore.QIODevice.WriteOnly)
stream.flush() # removes the ascii dump
stream  myPythonString
print str(stream.string()) # crashes here already..

if myTcpSocket.isWritable():
print writing data to , str(socket.peerAddress().toString())
myTcpSocket.write(block)
-

How on earth can this be?

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

Re: [PyQt] Having a problem with QTcpSocket

2009-11-23 Thread Nick Gaens




Nick Gaens schreef:

  
  
Phil Thompson schreef:
  
On Sat, 21 Nov 2009 17:19:00 +0100, Nick Gaens nickga...@gmail.com wrote:
  

  Hello all,

I'm trying to get two clients to speak to each other, using an instance


of
  

  QtNetwork.QTcpSocket for each client.
The clients are on different computers with IP's: 192.168.1.100 and .102

On the first client, I run the code below:

--
def __init__(self):
self.socket = QtNetwork.QTcpSocket(self)
self.socket.setLocalAddress(QtNetwork.QHostAddress("192.168.1.100"))
self.socket.setLocalPort(5)
self.socket.readyRead.connect(self.receiveData)

def connectToOtherClient(self, ip):
self.socket.connectToHost(QtNetwork.QHostAddress(ip), 5)
if self.socket.waitForConnected(1):
print "Connected!"
else:
print self.socket.state() # Prints '0' (zero), meaning
UnconnectedState

--

So I create a QTcpSocket, I tell it the IP I want to use and after having
the user asking for the remote IP address, connectToOtherClient() is
invoked.

On the second client, I just create an instance of this class, using
"192.168.1.102" as IP there in __init__(). No invocation of
connectToOtherClient() there, ofcourse..

The problem is: it doesn't connect at all.. The socket state remains
"UnconnectedState"..

What am I doing wrong here?



Clients talk to servers, not other clients. Have a look at QTcpServer.

Phil
  
  
I've now instantiated a QTcpServer, which "creates" a socket for an
incoming connection (QTcpServer.nextPendingConnection(), that is).
Both clients have such a server instance, since they both should be
able to connect to each other. But still, the
QTcpSocket.connectToHost() invocation doesn't do a thing.
I'm starting to think this is some bug / error in PyQt4 itself instead
of in my code. The C++-Qt4 Fortune Server + Client example runs
flawlessly between the two machines, so there are no network blocks or
something like that. Also, the C++-code has the same logical flow as my
code below.
  

def __init__(self):
    self.server = QtNetwork.QTcpServer(self)
    self.server.serverPort = 5
    self.server.newConnection.connect(self.clientConnecting)
    self.server.listen() # defaults to QHostAddress.Any
  
def clientConnecting(self): # used by the "server"
    if self.server.hasPendingConnections():
    connectingClient = self.server.nextPendingConnection()
    connectingClient.readyRead.connect(self.receiveData)
  
def connectToClient(self, ip):  # used by the "client"
    socket = QtNetwork.QTcpSocket()
    socket.readyRead.connect(self.receiveData)
    socket.connectToHost(QtNetwork.QHostAddress(ip), 5) # ip of
server
    if socket.waitForConnected(5000):
    print "Connected!"

  
I *really* do not understand why this is *not* working..
  
Nick

Anyone? :-( I've tried various things, but none of them helped.. I've
found out that both NIC's actually send / receive some bytes (proven by
the suddenly increasing number of sent / received bytes on both
computers), but it doesn't actually connect them..

Nick


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

Re: [PyQt] Having a problem with QTcpSocket

2009-11-23 Thread Nick Gaens




Hans-Peter Jansen schreef:

  On Monday 23 November 2009, 13:27:52 Nick Gaens wrote:
  
  
 Nick Gaens schreef:
 Phil Thompson schreef:
On Sat, 21 Nov 2009 17:19:00 +0100, Nick Gaens nickga...@gmail.com
wrote:

Hello all,

I'm trying to get two clients to speak to each other, using an instance

of

QtNetwork.QTcpSocket for each client.
The clients are on different computers with IP's: 192.168.1.100 and .102

On the first client, I run the code below:

--
def __init__(self):
self.socket = QtNetwork.QTcpSocket(self)
self.socket.setLocalAddress(QtNetwork.QHostAddress("192.168.1.100"))
self.socket.setLocalPort(5)
self.socket.readyRead.connect(self.receiveData)

def connectToOtherClient(self, ip):
self.socket.connectToHost(QtNetwork.QHostAddress(ip), 5)
if self.socket.waitForConnected(1):
print "Connected!"
else:
print self.socket.state() # Prints '0' (zero), meaning
UnconnectedState

--

So I create a QTcpSocket, I tell it the IP I want to use and after having
the user asking for the remote IP address, connectToOtherClient() is
invoked.

On the second client, I just create an instance of this class, using
"192.168.1.102" as IP there in __init__(). No invocation of
connectToOtherClient() there, ofcourse..

The problem is: it doesn't connect at all.. The socket state remains
"UnconnectedState"..

What am I doing wrong here?


Clients talk to servers, not other clients. Have a look at QTcpServer.

Phil

 I've now instantiated a QTcpServer, which "creates" a socket for an
incoming connection (QTcpServer.nextPendingConnection(), that is). Both
clients have such a server instance, since they both should be able to
connect to each other. But still, the QTcpSocket.connectToHost()
invocation doesn't do a thing. I'm starting to think this is some bug /
error in PyQt4 itself instead of in my code. The C++-Qt4 Fortune Server +
Client example runs flawlessly between the two machines, so there are no
network blocks or something like that. Also, the C++-code has the same
logical flow as my code below.

 
 def __init__(self):
     self.server = QtNetwork.QTcpServer(self)
     self.server.serverPort = 5
     self.server.newConnection.connect(self.clientConnecting)
     self.server.listen() # defaults to QHostAddress.Any

 def clientConnecting(self): # used by the "server"
     if self.server.hasPendingConnections():
     connectingClient = self.server.nextPendingConnection()
     connectingClient.readyRead.connect(self.receiveData)

 def connectToClient(self, ip):  # used by the "client"
     socket = QtNetwork.QTcpSocket()
     socket.readyRead.connect(self.receiveData)
     socket.connectToHost(QtNetwork.QHostAddress(ip), 5) # ip of
server if socket.waitForConnected(5000):
     print "Connected!"
 

 I *really* do not understand why this is *not* working..

 Nick

 Anyone? :-( I've tried various things, but none of them helped.. I've
found out that both NIC's actually send / receive some bytes (proven by
the suddenly increasing number of sent / received bytes on both
computers), but it doesn't actually connect them..

  
  
The usual "please provide a minimum self containing example" applies.

Pete

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

How odd that I receive this mail *the moment* my code started working
:-P.

I found that the serverPort may not be overwritten.

I removed this assignment: 
self.server.serverPort = 5

and the clients now can connect to the server w/o any problem..
Downside is that the port is random..

Nick


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

Re: [PyQt] Having a problem with QTcpSocket

2009-11-23 Thread Nick Gaens




Hans-Peter Jansen schreef:

  On Monday 23 November 2009, 15:19:06 Nick Gaens wrote:
  
  
 Hans-Peter Jansen schreef:

  
  [...]
  
  
 
 def __init__(self):
     self.server = QtNetwork.QTcpServer(self)
     self.server.serverPort = 5
     self.server.newConnection.connect(self.clientConnecting)
     self.server.listen() # defaults to QHostAddress.Any

 def clientConnecting(self): # used by the "server"
     if self.server.hasPendingConnections():
     connectingClient = self.server.nextPendingConnection()
     connectingClient.readyRead.connect(self.receiveData)

 def connectToClient(self, ip):  # used by the "client"
     socket = QtNetwork.QTcpSocket()
     socket.readyRead.connect(self.receiveData)
     socket.connectToHost(QtNetwork.QHostAddress(ip), 5) # ip of
server if socket.waitForConnected(5000):
     print "Connected!"
 

  
  [...]
  
  
 How odd that I receive this mail *the moment* my code started working
:-P.

 I found that the serverPort may not be overwritten.

 I removed this assignment:

self.server.serverPort = 5

  
  
Assigning properties this way usually won't work in PyQt (although Phil 
tackles this already). 

try this:
  self.server.listen(QtNetwork.QHostAddress.Any, 5)


  
  
 and the clients now can connect to the server w/o any problem.. Downside
is that the port is random..

  
  
Pete



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

Hmm.. That doesn't seem to work :-S..

self.server.listen(QtNetwork.QHostAddress.Any, 5):
  TypeError: argument 1 of QTcpServer.listen() has an invalid type

How can this be? I've got PyQt4.6.2 on WinXP, Python 2.6.4


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

Re: [PyQt] Problem with class inheriting QDialog

2009-11-23 Thread Nick Gaens




dizou schreef:

  What does that mean?

One thing I thought I could do is have my TreeWidget have a GetSelectedItem
function. Then in my Main Window, when I click the button, it calls a
function that will call the GetSelectedItem function, then emit a signal
with the return value as a parameter. Is that possible?

With the new way of connecting signals and slots, would I then have
something like this:

self.editTreeItemButton.clicked.connect(self.EditTreeItemButtonClicked())

Thanks.
  


Almost :-)
self.editTreeItemButton.clicked.connect(self.EditTreeItemButtonClicked)


Nick




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

Re: [PyQt] Having a problem with QTcpSocket

2009-11-22 Thread Nick Gaens




Phil Thompson schreef:

  On Sat, 21 Nov 2009 17:19:00 +0100, Nick Gaens nickga...@gmail.com wrote:
  
  
Hello all,

I'm trying to get two clients to speak to each other, using an instance

  
  of
  
  
QtNetwork.QTcpSocket for each client.
The clients are on different computers with IP's: 192.168.1.100 and .102

On the first client, I run the code below:

--
def __init__(self):
self.socket = QtNetwork.QTcpSocket(self)
self.socket.setLocalAddress(QtNetwork.QHostAddress("192.168.1.100"))
self.socket.setLocalPort(5)
self.socket.readyRead.connect(self.receiveData)

def connectToOtherClient(self, ip):
self.socket.connectToHost(QtNetwork.QHostAddress(ip), 5)
if self.socket.waitForConnected(1):
print "Connected!"
else:
print self.socket.state() # Prints '0' (zero), meaning
UnconnectedState

--

So I create a QTcpSocket, I tell it the IP I want to use and after having
the user asking for the remote IP address, connectToOtherClient() is
invoked.

On the second client, I just create an instance of this class, using
"192.168.1.102" as IP there in __init__(). No invocation of
connectToOtherClient() there, ofcourse..

The problem is: it doesn't connect at all.. The socket state remains
"UnconnectedState"..

What am I doing wrong here?

  
  
Clients talk to servers, not other clients. Have a look at QTcpServer.

Phil
  

I've now instantiated a QTcpServer, which "creates" a socket for an
incoming connection (QTcpServer.nextPendingConnection(), that is).
Both clients have such a server instance, since they both should be
able to connect to each other. But still, the
QTcpSocket.connectToHost() invocation doesn't do a thing.
I'm starting to think this is some bug / error in PyQt4 itself instead
of in my code. The C++-Qt4 Fortune Server + Client example runs
flawlessly between the two machines, so there are no network blocks or
something like that. Also, the C++-code has the same logical flow as my
code below.


def __init__(self):
    self.server = QtNetwork.QTcpServer(self)
    self.server.serverPort = 5
    self.server.newConnection.connect(self.clientConnecting)
    self.server.listen() # defaults to QHostAddress.Any

def clientConnecting(self): # used by the "server"
    if self.server.hasPendingConnections():
    connectingClient = self.server.nextPendingConnection()
    connectingClient.readyRead.connect(self.receiveData)

def connectToClient(self, ip):  # used by the "client"
    socket = QtNetwork.QTcpSocket()
    socket.readyRead.connect(self.receiveData)
    socket.connectToHost(QtNetwork.QHostAddress(ip), 5) # ip of
server
    if socket.waitForConnected(5000):
    print "Connected!"


I *really* do not understand why this is *not* working..

Nick


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

[PyQt] Having a problem with QTcpSocket

2009-11-21 Thread Nick Gaens

Hello all,

I'm trying to get two clients to speak to each other, using an instance of 
QtNetwork.QTcpSocket for each client.
The clients are on different computers with IP's: 192.168.1.100 and .102

On the first client, I run the code below:

--
def __init__(self):
   self.socket = QtNetwork.QTcpSocket(self)
   self.socket.setLocalAddress(QtNetwork.QHostAddress(192.168.1.100))
   self.socket.setLocalPort(5)
   self.socket.readyRead.connect(self.receiveData)

def connectToOtherClient(self, ip):
   self.socket.connectToHost(QtNetwork.QHostAddress(ip), 5)
   if self.socket.waitForConnected(1):
   print Connected!
   else:
   print self.socket.state() # Prints '0' (zero), meaning UnconnectedState

--

So I create a QTcpSocket, I tell it the IP I want to use and after having the 
user asking for the remote IP address, connectToOtherClient() is invoked.

On the second client, I just create an instance of this class, using 
192.168.1.102 as IP there in __init__(). No invocation of 
connectToOtherClient() there, ofcourse..

The problem is: it doesn't connect at all.. The socket state remains 
UnconnectedState..

What am I doing wrong here?

Wkr,

Nick Gaens


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