Let me explain my current situation. I am making a e-POS system for a
takeaway. I have a window, which opens another window which takes some
input from the user. Then that window closes and I want to pass the
info from the user back to the previous window which was never closed.
Both windows are a separate class.
without really looking at your code, could you not just simply Hide() the second win and then once you’ve got what you want from it, Destroy() it? Furthermore, would a wxDialog be appropriate in ShowModal() mode?
···
–
Hi, I will kill all ads in google gmail.
They will all be dead and gone for all my emails to you. HA HA bye bye ads I just massacred you!!!
There are a lot of better ways of passing the results back to the other window than using globals. As Micah suggested, it would be a good fit for a modal dialog. For example:
dlg = PickupDialog(self)
if dlg.ShowModal() == wx.ID_OK:
n, p = dlg.GetResults()
self.DoSomething(n, p)
dlg.Destroy()
Another possibility is to simply call a method in the parent window and pass the results. For example:
self.GetParent().DoSomething(n, p)
Or you could use the pubsub framework to pass a message with the results, if the parent window (or any other place in your app) has subscribed to that message topic then it will receive the message with the result values.
Let me explain my current situation. I am making a e-POS system for a
takeaway. I have a window, which opens another window which takes some
input from the user. Then that window closes and I want to pass the
info from the user back to the previous window which was never closed.
Both windows are a separate class.
OK, I tried the method using the dialogs by just by making PickupFrame
inherit from wx.Dialog instead of wx.Frame. However, unless I use
self.Maximize() on the Dialog, it does not lay it out properly. I've
called self.Layout() but it doesn't work.
···
On Apr 18, 4:51 pm, Robin Dunn <ro...@alldunn.com> wrote:
On 4/17/11 5:57 AM, leekaiwei wrote:
> Let me explain my current situation. I am making a e-POS system for a
> takeaway. I have a window, which opens another window which takes some
> input from the user. Then that window closes and I want to pass the
> info from the user back to the previous window which was never closed.
> Both windows are a separate class.
> 1st Window: The button at line 134 calls the function at line 290
> which creates an instance of the 2nd Window.
> 2nd Window: I created class Result() to pass it back but it doesn't
> like it. Saying n and p are not global.
There are a lot of better ways of passing the results back to the other
window than using globals. As Micah suggested, it would be a good fit
for a modal dialog. For example:
dlg = PickupDialog\(self\)
if dlg\.ShowModal\(\) == wx\.ID\_OK:
n, p = dlg\.GetResults\(\)
self\.DoSomething\(n, p\)
dlg\.Destroy\(\)
Another possibility is to simply call a method in the parent window and
pass the results. For example:
self\.GetParent\(\)\.DoSomething\(n, p\)
Or you could use the pubsub framework to pass a message with the
results, if the parent window (or any other place in your app) has
subscribed to that message topic then it will receive the message with
the result values.
Are you giving the dialog a fixed size or sizing it to fit the contents? Does the dialog have a sizer? Or are you depending on a child Panel to be sized to fill the dialog? If it's fixed size and all the widgets are in a panel, then calling SendSizeEvent will probably help since the default size handler is where things like that are taken care of. Otherwise, please make a runnable, small as possible, sample application that demonstrates the problem and let us know the platform and wx version. MakingSampleApps - wxPyWiki
···
On 4/24/11 9:00 AM, leekaiwei wrote:
OK, I tried the method using the dialogs by just by making PickupFrame
inherit from wx.Dialog instead of wx.Frame. However, unless I use
self.Maximize() on the Dialog, it does not lay it out properly. I've
called self.Layout() but it doesn't work.