Re: [PyQt] Pressing enter in QLineEdit clicks QPushButton?
Sibylle Koczian wrote: Hello, I've got a dialog with a QLineEdit and a QPushButton. The QLineEdit is connected to a method which takes its text and appends it to a QTextBrowser (that's taken from the first GUI example in the PyQt book by M. Summerfield). The clicked() signal of the QPushButton is connected to a method that just prints a message. The problem: this method, which should only be called by clicking the button, is called every time Enter is pressed in the QLineEdit. This happens even if the edit control isn't connected to any method. The button is next to the line edit in the form and in the tab order. With setAutoDefault(false) for this button and for the exit button which follows in tab order I can prevent this behavior, but that isn't really very comfortable. And it shouldn't be necessary, should it? All this on openSUSE with Python 2.6, PyQt 4.4.4. Thank you for help, Sibylle Can you supply a simple example that reproduces the behavior? Best regards, Mads ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Pressing enter in QLineEdit clicks QPushButton?
Mads Ipsen m...@comxnet.dk schrieb: Sibylle Koczian wrote: Hello, I've got a dialog with a QLineEdit and a QPushButton. The QLineEdit is connected to a method which takes its text and appends it to a QTextBrowser (that's taken from the first GUI example in the PyQt book by M. Summerfield). The clicked() signal of the QPushButton is connected to a method that just prints a message. The problem: this method, which should only be called by clicking the button, is called every time Enter is pressed in the QLineEdit. This happens even if the edit control isn't connected to any method. The button is next to the line edit in the form and in the tab order. With setAutoDefault(false) for this button and for the exit button which follows in tab order I can prevent this behavior, but that isn't really very comfortable. And it shouldn't be necessary, should it? All this on openSUSE with Python 2.6, PyQt 4.4.4. Thank you for help, Sibylle Can you supply a simple example that reproduces the behavior? Here it is. Tried with PyQt 4.4.4 (openSUSE) and PyQt 4.5.1 (Windows XP Prof.), same behavior. If the returnPressed() signal of the line edit is connected to the logText() method, then pressing Enter calls logText() (as it should) and then logPush() (as it shouldn't), pressing Tab doesn't call either of them. If editingFinished() is connected to logText() instead (commented out here), then pressing Enter calls both methods, as before, pressing Tab only calls logText(), but clicking on one of the buttons (self.pushtest or btFertig) calls first logText() and then the method the button is connected to and should call. So in both cases the application doesn't do what I want it to do: put the line edit text into the text browser if and only if enter (or tab) is pressed after entering something in that control, and calling the method connected to the button if and only if the button is pressed. What can I do, or what did I misunderstand? Regards Sibylle #!/usr/bin/env python # -*- coding: utf-8 -*- # test_lineeditenter.py import sys from PyQt4.QtCore import * from PyQt4.QtGui import * class Form(QDialog): def __init__(self, parent=None): super(Form, self).__init__(parent) self.lineedit = QLineEdit(uWrite something and press Enter) self.pushtest = QPushButton(uTest button) self.log = QTextBrowser() btFertig = QPushButton(uExit) layout = QVBoxLayout() layout.addWidget(self.lineedit) layout.addWidget(self.pushtest) layout.addWidget(self.log) layout.addWidget(btFertig) self.setLayout(layout) self.lineedit.selectAll() self.lineedit.setFocus() self.connect(self.lineedit, SIGNAL(returnPressed()), self.logText) #self.connect(self.lineedit, SIGNAL(editingFinished()), # self.logText) self.connect(self.pushtest, SIGNAL(clicked()), self.logPush) self.connect(btFertig, SIGNAL(clicked()), self, SLOT(close())) self.setWindowTitle(uLine edit problem) def logText(self): tx = self.lineedit.text() self.log.append(tx) self.lineedit.selectAll() self.lineedit.setFocus() def logPush(self): self.log.append(Button pressed) if __name__ == __main__: app = QApplication(sys.argv) mf = Form() mf.show() app.exec_() -- Dr. Sibylle Koczian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Re: connection between 2 widget
On Sun Jun 21 17:37:54 BST 2009, Massimo Di Stefano wrote: I'm tring to get a solution, i searced for similar code in the pyqt examples source code but i can't find nothig similar. is the question i proposed comprensible? It's a little difficult for me to understand, but I'll try and work through it step by step: i can reproduce my problem with an example : W-1 (spinbox + button) [ it is a main app, and has in the menu bar an action to open W-2] OK, I see this in your example. W-2 (line edit + button) Right. I see this when I select the process-run menu item. i run W-1, pressing its button it increase the spinbox value, then pressing the action from the menu - open W-2 Yes, these work as expected. A question: what happens if the user changes the value in the spin box directly? W-2 , at its start, read value from W-1 -- pressing the W-2 button process W-1 value and print it . When I click the button, I see the value from the spin box in the line edit. my problem : i need that everitime i change the W-1 value ... ... when i press button in W-2 it will process the W-1(changed value) OK, so instead of passing a value when you create W-2, you want the value to be taken from the spin box in W-1 and written to the line edit? Here are some changes I made to your code to do what I think you want. Firstly, I create the Elab widget in the init() method of your application class instead of creating it later in the elaborazione() method. This makes it possible for me to connect a signal from the ZoomSpinBox to a slot in the widget. [app.py] [...] def init(self): self.w = GuiWidget() self.Value = 0 self.query = Elab() self.connect(self.w.p1, SIGNAL(clicked()), self.inc) self.connect(self.w.actionRun, SIGNAL(triggered()), self.elaborazione) self.connect(self.w.ZoomSpinBox, SIGNAL(valueChanged(double)), self.query.setValue) self.w.show() [...] def elaborazione(self): self.query.show() I just show the Elab widget when the elaborazione() method is called. In the Elab class, we no longer need to pass an initial value, but you could make the class take a value to begin with if you want. We don't want to show the widget immediately, so I removed a call to its show() method. [elab.py] class Elab(QWidget, Ui_Form): def __init__(self): QWidget.__init__(self) self.setupUi(self) self.value = 0 self.connect(self.p2, SIGNAL(clicked()),self.elabora) def elabora(self): newvalue = str(self.value)+str('-') self.lineEdit.setText(newvalue) print newvalue def setValue(self, value): self.value = value I added the setValue() slot that we used in the app.py file. This updates the value held by this widget so that clicking the button causes an up-to-date value to be used. Is this what you had in mind? David ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] pyuic4 addItem issue
On Sat, 20 Jun 2009 15:16:24 +0200, Hans-Peter Jansen h...@urpla.net wrote: Hi Phil, attached is a ui file, generated with designer of Qt 4.5.1, that throws this exception: pyuic4 -dp configdialogbase.ui Thanks - fixed in tonight's snapshot. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Can't load UI files under Turkish locale (again)
On Tue, 16 Jun 2009 11:57:53 +0300, Gökçen Eraslan gok...@pardus.org.tr wrote: Hi, In an early version of PyQt( 4.4.4) we were having problems about loading ui files with Turkish locale like: File /usr/lib/python2.4/site-packages/PyQt4/uic/properties.py, line 220, in setProperties getattr(widget, set%s%s % (propname[0].upper(), propname[1:]))( AttributeError: seticon And this problem was fixed after this thread[1], and PyQt 4.4.4 was fine. But in PyQt 4.5, according patch in the thread (also attached) is not included. Is this intentional or just forgotten? Can you include it again in next release? Should be fixed in tonight's snapshot. It got dropped in the process of porting to Python v3. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Pressing enter in QLineEdit clicks QPushButton?
Sibylle Koczian wrote: Mads Ipsen m...@comxnet.dk schrieb: Sibylle Koczian wrote: Hello, I've got a dialog with a QLineEdit and a QPushButton. The QLineEdit is connected to a method which takes its text and appends it to a QTextBrowser (that's taken from the first GUI example in the PyQt book by M. Summerfield). The clicked() signal of the QPushButton is connected to a method that just prints a message. The problem: this method, which should only be called by clicking the button, is called every time Enter is pressed in the QLineEdit. This happens even if the edit control isn't connected to any method. The button is next to the line edit in the form and in the tab order. With setAutoDefault(false) for this button and for the exit button which follows in tab order I can prevent this behavior, but that isn't really very comfortable. And it shouldn't be necessary, should it? All this on openSUSE with Python 2.6, PyQt 4.4.4. Thank you for help, Sibylle Can you supply a simple example that reproduces the behavior? Here it is. Tried with PyQt 4.4.4 (openSUSE) and PyQt 4.5.1 (Windows XP Prof.), same behavior. If the returnPressed() signal of the line edit is connected to the logText() method, then pressing Enter calls logText() (as it should) and then logPush() (as it shouldn't), pressing Tab doesn't call either of them. If editingFinished() is connected to logText() instead (commented out here), then pressing Enter calls both methods, as before, pressing Tab only calls logText(), but clicking on one of the buttons (self.pushtest or btFertig) calls first logText() and then the method the button is connected to and should call. So in both cases the application doesn't do what I want it to do: put the line edit text into the text browser if and only if enter (or tab) is pressed after entering something in that control, and calling the method connected to the button if and only if the button is pressed. What can I do, or what did I misunderstand? Regards Sibylle #!/usr/bin/env python # -*- coding: utf-8 -*- # test_lineeditenter.py import sys from PyQt4.QtCore import * from PyQt4.QtGui import * class Form(QDialog): def __init__(self, parent=None): super(Form, self).__init__(parent) self.lineedit = QLineEdit(uWrite something and press Enter) self.pushtest = QPushButton(uTest button) self.log = QTextBrowser() btFertig = QPushButton(uExit) layout = QVBoxLayout() layout.addWidget(self.lineedit) layout.addWidget(self.pushtest) layout.addWidget(self.log) layout.addWidget(btFertig) self.setLayout(layout) self.lineedit.selectAll() self.lineedit.setFocus() self.connect(self.lineedit, SIGNAL(returnPressed()), self.logText) #self.connect(self.lineedit, SIGNAL(editingFinished()), # self.logText) self.connect(self.pushtest, SIGNAL(clicked()), self.logPush) self.connect(btFertig, SIGNAL(clicked()), self, SLOT(close())) self.setWindowTitle(uLine edit problem) def logText(self): tx = self.lineedit.text() self.log.append(tx) self.lineedit.selectAll() self.lineedit.setFocus() def logPush(self): self.log.append(Button pressed) if __name__ == __main__: app = QApplication(sys.argv) mf = Form() mf.show() app.exec_() If you change 'QDialog' to 'QWidget' the problem disappears. But I have no idea why. Anybody? Best regards, Mads -- ++ | Mads Ipsen, Ph.D, Scientific software developer| +--+-+ | QuantumWise A/S | phone: +45-29716388 | | Nørresøgade 27A | www:www.quantumwise.com | | DK-1370 Copenhagen, Denmark | email: m...@quantumwise.com | +--+-+ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Pressing enter in QLineEdit clicks QPushButton?
Mads Ipsen a écrit : If you change 'QDialog' to 'QWidget' the problem disappears. But I have no idea why. Anybody? Best regards, Mads In the first example proposed that did not work, you can see that the button has the focus even if the cursor is in the lineedit. I think that the problem comes from here. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Snow Leopard/ Python 2.6 bug
On Sun, 21 Jun 2009 17:26:30 +1200, Noah Gift wrote: Anyone able to get PyQt 4.4.1 or higher running on Snow Leopard? I used mac ports to install 4.4.1 and got the following error when running scripts that worked on Leopard: % python numbers.pyw Qt: qcolorFromCGColor: cannot convert from colorspace model: 0 I noticed a mention of this checkin for C++: http://qt.gitorious.org/~gberg/qt/qt-gberg/commit/e773b0486a4784994a900c03a 2620baf2775ac9d?diffmode=sidebyside It may be that the fix is in Qt 4.5 and so requires PyQt 4.5. Does PyQt 4.4.1 from MacPorts give you Qt 4.4 or Qt 4.5? David ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] How to dynamically add widgets to a verticle layout?
I too am hitting this roadblock. Is there a way that the layout can automatically resize with the addition of new widgets? Matt Dubins -- Adam Chrystie wrote : As I add more QLineEdits, they are drawn closer and closer together and eventually overlap each other instead of drawing spaced apart from each other. Can anyone offer any tips to doing this? -- This message was sent on behalf of matt.dub...@sympatico.ca at openSubscriber.com http://www.opensubscriber.com/message/pyqt@riverbankcomputing.com/9665274.html ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] How to dynamically add widgets to a verticle layout?
On Monday 22 June 2009 16:38:40 matt.dub...@sympatico.ca wrote: I too am hitting this roadblock. Is there a way that the layout can automatically resize with the addition of new widgets? Matt Dubins -- Adam Chrystie wrote : As I add more QLineEdits, they are drawn closer and closer together and eventually overlap each other instead of drawing spaced apart from each other. Can anyone offer any tips to doing this? -- This message was sent on behalf of matt.dub...@sympatico.ca at openSubscriber.com http://www.opensubscriber.com/message/pyqt@riverbankcomputing.com/9665274.h tml ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt Trying calling resize on the widget using the result of layout.sizeHint(). I'm not sure that it'll work and I think it depends on how the layout is setup. Matt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: Re: [PyQt] How to dynamically add widgets to a verticle layout?
I've investigated this problem some more and found a reason for the problem experienced by Adam and myself. The widget in which my horizontal layout was placed had too restrictive a vertical geometry. Once I made my widget 'taller' in setGeometry() , I could add new subwidgets without any of them looking vertically squished. Cheers, Matt Dubins -- This message was sent on behalf of matt.dub...@sympatico.ca at openSubscriber.com http://www.opensubscriber.com/message/pyqt@riverbankcomputing.com/12482603.html ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Metaclass conflict
Hi I am trying to fix the PyQwt module for Qt3 (3.18.1) but when I try to import the module (Qwt.so) I get: TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases I have been searching for this error message for a while but I didn't become any wiser. Can anyone give me a hint? Thanks Gudjon ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt