[PyQt] Passing text from MainWindow to popup Dialog

Hans-Peter Jansen hpj at urpla.net
Tue Mar 22 21:57:01 GMT 2011


On Tuesday 22 March 2011, 22:39:12 James Polk wrote:
> I have a scenario where my MainWindow needs to call and display
> a popup Window...and while the window is open, processing continues
> in the main application, and during processing needs to send a string
> or two of text to the popup dialog.
>
> I know how to call and display the popup window/dialog,..and I know
> how to send the popup a line of text *before* it pops up....and I
> know how to get text *back* when it closes...but I can't figure out
> how to intermittently send the popup text for it to display.
>
> I have two files....let's call them main.py and popup.py
> In main.py, I do a
>
> import popup as dialog
>
> This works:
>                 dialog = popAdd.AddNewRecordDialog(stuff,None)
>                 dialog.exec_()
>
> What I'd like to do inside of main.py is call..
>
>                 dialog.DoIt("Whatever will be, will be")
>
> popup.py has a plainTextEdit box,...and inside a function named
> "DoIt" which is currently looking like this:  (though I've tried
> other permutations)
>
>     def DoIt(message,self):
>         QDialog.plainTextBox.setPlainText(message)
>
> I've also tried from inside main.py:
>
>      dialog.plainEditText.setText(message)
>
> but that doesn't work either,...

This all sounds strange, and your way of addressing the widgets looks a 
bit funny, too. Probably, your messages gets garbarge collected 
immediately...

> Anybody got any ideas how to make this work?...
> Or, if you have another suggestions, I'm all ears...

Your best bet is to get yourself to create a minimum runnable example, 
that demonstrates the issue.

Pete


More information about the PyQt mailing list