473,394 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

PYQT 3 communication with 2 windows

Hi, I'm introducing to program in python + pyqt.
I have a main window that call a second window (to introduce a info
with textedit)
when press the second window button I need to return to the main
window the info
introduced in the second window.
I've seek in the pyqt doc examples but i don't find it.
Have you any example?

Apr 19 '07 #1
3 3056
On Thursday 19 April 2007 22:38, Marcpp wrote:
Hi, I'm introducing to program in python + pyqt.
I have a main window that call a second window (to introduce a info
with textedit)
when press the second window button I need to return to the main
window the info
introduced in the second window.
I've seek in the pyqt doc examples but i don't find it.
Have you any example?
You could connect the button to a slot in the second window that sends
the text back to the first window.

Here's an example that sends the text to a function. You could substitute a
class for the function to get what you want.
import sys
from qt import *

class Window(QWidget):

def __init__(self, parent = None):

QWidget.__init__(self, parent)

self.textEdit = QTextEdit(self)
okButton = QPushButton(self.tr("&OK"), self)
self.connect(okButton, SIGNAL("clicked()"), self.sendText)
layout = QVBoxLayout(self)
layout.addWidget(self.textEdit)
layout.addWidget(okButton)

def sendText(self):

self.emit(PYSIGNAL("textEntered(QString)"), (self.textEdit.text(),))
def fn(text):

print text

if __name__ == "__main__":

app = QApplication(sys.argv)
window = Window()
window.connect(window, PYSIGNAL("textEntered(QString)"), fn)
window.show()
app.setMainWidget(window)
sys.exit(app.exec_loop())
Note the use of PYSIGNAL() instead of SIGNAL(). With PyQt4 you would be able
to use SIGNAL() and write the emit() call in a simpler form.

David
Apr 21 '07 #2
On 21 abr, 02:43, David Boddie <d...@boddie.org.ukwrote:
On Thursday 19 April 2007 22:38, Marcpp wrote:
Hi, I'm introducing to program in python + pyqt.
I have a main window that call a second window (to introduce a info
with textedit)
when press the second window button I need to return to the main
window the info
introduced in the second window.
I've seek in the pyqt doc examples but i don't find it.
Have you any example?

You could connect the button to a slot in the second window that sends
the text back to the first window.

Here's an example that sends the text to a function. You could substitute a
class for the function to get what you want.

import sys
from qt import *

class Window(QWidget):

def __init__(self, parent = None):

QWidget.__init__(self, parent)

self.textEdit = QTextEdit(self)
okButton = QPushButton(self.tr("&OK"), self)
self.connect(okButton, SIGNAL("clicked()"), self.sendText)
layout = QVBoxLayout(self)
layout.addWidget(self.textEdit)
layout.addWidget(okButton)

def sendText(self):

self.emit(PYSIGNAL("textEntered(QString)"), (self.textEdit.text(),))

def fn(text):

print text

if __name__ == "__main__":

app = QApplication(sys.argv)
window = Window()
window.connect(window, PYSIGNAL("textEntered(QString)"), fn)
window.show()
app.setMainWidget(window)
sys.exit(app.exec_loop())

Note the use of PYSIGNAL() instead of SIGNAL(). With PyQt4 you would be able
to use SIGNAL() and write the emit() call in a simpler form.

David

Thankyou!!!
This is that I want.

Apr 24 '07 #3
On 21 abr, 02:43, David Boddie <d...@boddie.org.ukwrote:
On Thursday 19 April 2007 22:38, Marcpp wrote:
Hi, I'm introducing to program in python + pyqt.
I have a main window that call a second window (to introduce a info
with textedit)
when press the second window button I need to return to the main
window the info
introduced in the second window.
I've seek in the pyqt doc examples but i don't find it.
Have you any example?

You could connect the button to a slot in the second window that sends
the text back to the first window.

Here's an example that sends the text to a function. You could substitute a
class for the function to get what you want.

import sys
from qt import *

class Window(QWidget):

def __init__(self, parent = None):

QWidget.__init__(self, parent)

self.textEdit = QTextEdit(self)
okButton = QPushButton(self.tr("&OK"), self)
self.connect(okButton, SIGNAL("clicked()"), self.sendText)
layout = QVBoxLayout(self)
layout.addWidget(self.textEdit)
layout.addWidget(okButton)

def sendText(self):

self.emit(PYSIGNAL("textEntered(QString)"), (self.textEdit.text(),))

def fn(text):

print text

if __name__ == "__main__":

app = QApplication(sys.argv)
window = Window()
window.connect(window, PYSIGNAL("textEntered(QString)"), fn)
window.show()
app.setMainWidget(window)
sys.exit(app.exec_loop())

Note the use of PYSIGNAL() instead of SIGNAL(). With PyQt4 you would be able
to use SIGNAL() and write the emit() call in a simpler form.

David

Thankyou!!!
This is that I want.

Apr 24 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dennis Sylvester | last post by:
Interested in any opinions, studies, etc., concerning the GUI tool(s) to use for Python. Specifically, which would you recommend (and why) for building GUI apps in Python: TKinter BOA PyQT ...
4
by: ulysses | last post by:
hi, I'm working in python 5 months. I think it's very cool language. I do a p2p python program GUI. First I make a software by wxpython. But I find wxpython use many many memory. Second I use...
35
by: Vamsi Mudrageda | last post by:
I am kind of new to Python, and after trying and using wxPython, I found it kind of lacking in easy-to-read documentation, speed at loading, and GUI response-time. So I am looking for an another...
8
by: simo | last post by:
OK, so I'm at the stage where I want to make a choice between wxPython and PyQt. Currently I'm using wxPython mainly due to the fact that it has GPL Linux and Windows versions. I prefer Qt to...
3
by: Fabio | last post by:
Hi all, I'm about to write an application, and I'd like to use PyQt, but before choosing this toolkit I would like to clarify some particular licensing issues; if some user has already touched...
16
by: Nanoscalesoft | last post by:
hello all, I am planning to start coding a nanoscale design software in python with QT interface.I have to do this in windows or linux.Intially windows would be fine. I have struggled almost full...
10
by: Simon John | last post by:
After quite a while of wxPython I'm getting back into PyQt, mainly due to the announcement by Trolltech that they will make a GPL version of Qt4 for Windows (and Phil-T said he will make a PyQt to...
4
by: Phil Thompson | last post by:
Riverbank Computing is pleased to announce the release of PyQt v3.14 available from http://www.riverbankcomputing.co.uk/. Changes since the last release include support for QScintilla v1.5. ...
3
by: Phil Thompson | last post by:
Riverbank Computing is pleased to announce the release of PyQt v4.0beta1 available from http://www.riverbankcomputing.co.uk/pyqt/. PyQt is a comprehensive set of Qt bindings for the Python...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.