473,702 Members | 2,552 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3067
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(sel f.tr("&OK"), self)
self.connect(ok Button, SIGNAL("clicked ()"), self.sendText)
layout = QVBoxLayout(sel f)
layout.addWidge t(self.textEdit )
layout.addWidge t(okButton)

def sendText(self):

self.emit(PYSIG NAL("textEntere d(QString)"), (self.textEdit. text(),))
def fn(text):

print text

if __name__ == "__main__":

app = QApplication(sy s.argv)
window = Window()
window.connect( window, PYSIGNAL("textE ntered(QString) "), fn)
window.show()
app.setMainWidg et(window)
sys.exit(app.ex ec_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.or g.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(sel f.tr("&OK"), self)
self.connect(ok Button, SIGNAL("clicked ()"), self.sendText)
layout = QVBoxLayout(sel f)
layout.addWidge t(self.textEdit )
layout.addWidge t(okButton)

def sendText(self):

self.emit(PYSIG NAL("textEntere d(QString)"), (self.textEdit. text(),))

def fn(text):

print text

if __name__ == "__main__":

app = QApplication(sy s.argv)
window = Window()
window.connect( window, PYSIGNAL("textE ntered(QString) "), fn)
window.show()
app.setMainWidg et(window)
sys.exit(app.ex ec_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.or g.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(sel f.tr("&OK"), self)
self.connect(ok Button, SIGNAL("clicked ()"), self.sendText)
layout = QVBoxLayout(sel f)
layout.addWidge t(self.textEdit )
layout.addWidge t(okButton)

def sendText(self):

self.emit(PYSIG NAL("textEntere d(QString)"), (self.textEdit. text(),))

def fn(text):

print text

if __name__ == "__main__":

app = QApplication(sy s.argv)
window = Window()
window.connect( window, PYSIGNAL("textE ntered(QString) "), fn)
window.show()
app.setMainWidg et(window)
sys.exit(app.ex ec_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
3367
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 Thanks, Dennis
4
5016
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 PYQT. But memory use still big. But but but when I minimize the windows to taskbar, a fantasy something happened. memory use very very low when windows minimize.
35
7753
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 GUI toolkit that is cross-platform for Python, and am leaning toward PyQt (PyGTK is kind of dull looking in comparison). Unfortunately, although TrollTech says Qt is cross-platform, its license strategy has me a bit confused. So here is to...
8
4850
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 wxWindows, but am confused with all the Windows licensing issues. For the moment this is just for my own tinkering and utility apps, but
3
2069
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 these, I would like to hear from his experiences. This app should be cross-platform, so, given qt licensing policies, I would buy a commercial PyQt license and a commercial Qt license. Could I license the application under the GPL for Gnu/Linux...
16
2131
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 day today trying to make from import qt * execute...........................I have the basic python core. I went through the sites like riverbankcomputing and trolltech and few online pages and books which talk about PyQT but never say about...
10
2161
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 go with it eventually!) I'm currently using PyQt 3.12 that comes with the BlackAdder demo, it seems to work fine with Python 2.3.5 except that it doesn't support the WinXP look'n'feel, the QStyle "WindowsXP" isn't included, and using a...
4
2210
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. PyQt is a comprehensive set of Qt bindings for the Python programming language and supports the same platforms as Qt. Like Qt, PyQt is available under the GPL (for UNIX, Linux and MacOS/X), a commercial license (for Windows, UNIX, Linux and...
3
2070
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 programming language and supports the same platforms as Qt (Windows, Linux and MacOS/X). Like Qt, PyQt is available under the GPL and a commercial license. PyQt v4 supports Qt v4 (http://www.trolltech.com/products/qt/index.html). PyQt v3 is still...
0
8738
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8652
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9234
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9086
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7829
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5907
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4412
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3104
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2036
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.