How to display text from two dialog on a third dialog?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to display text from two dialog on a third dialog?

Umar Yusuf
Hello house,

I kindly need a solution to this: http://stackoverflow.com/questions/42316495/wxpython-display-text-from-two-dialogs-printed-on-a-third-dialog

Basic calculations are carried out on the Box1 and Box2, how do I display the sum of the calculation the third dialog, that is on Box3?

How do I get to display a text result fromĀ Box1 and Box2 on Box3?

I have also attached the code here.


Thanks in advance for your time.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

three_dialogs.py (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to display text from two dialog on a third dialog?

Vlastimil Brom
2017-02-18 15:41 GMT+01:00 Umar Yusuf <[hidden email]>:

> Hello house,
>
> I kindly need a solution to this:
> http://stackoverflow.com/questions/42316495/wxpython-display-text-from-two-dialogs-printed-on-a-third-dialog
>
> Basic calculations are carried out on the Box1 and Box2, how do I display
> the sum of the calculation the third dialog, that is on Box3?
>
> How do I get to display a text result from Box1 and Box2 on Box3?
>
> I have also attached the code here.
>
>
> Thanks in advance for your time.
>
> --
> You received this message because you are subscribed to the Google Groups
> "wxPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

Hi,
probably the most straightforward way to make you code work somehow
could adding a global - toplevel list,

e.g. just below "import wx"

price_items_lst = []

than you can use
price_items_lst.append(price)
or
price_items_lst.append(add_price)

instead of your current print statements,
and finaly use
self.totalText1.SetLabel(str(sum(price_items_lst)))

I recognise, that this is somawhat hackish solution, at least it
doesn't follow the encapsulation, you are probably attempting by using
the different dialog classes. etc.
I'd probably prefer another form of the GUI (e.g. one frame/panel with
all the needed widgets at once - instead of isolated dialogs). In any
case you need some methods for passing the values for your input (and
output) data. - You can use a global variable/container like in this
trivial case, another possibility are class/instance attributes,
function calls with parameters or specialised mechanisms like pubsub.
(cf. https://www.blog.pythonlibrary.org/2010/06/27/wxpython-and-pubsub-a-simple-tutorial/
)
In any case, I believe, you will get more competent suggestions on this list.

hth,
   vbr

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.