How to assign a PanelClass as element in another PanelClass

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

How to assign a PanelClass as element in another PanelClass

ignace danneels
I created an application in which I open a sub-window (configure Rights).
That frame contains a panel that contains some 2 wxTree items and a button to open a new window Assign Rights (wxFrame), again containing a panel (wxPanel)

after reviewing the code, I found it could be better to embed the entire code of the Assign rights into the configuration window.
this is a typical example of how OOP should work.

What I want to do, is in the Configure Right Panel,  assign a variable self.pnlAssignRights = PnlAssignRights(), which contains all the buttons, the events etc which I would like to port.



class PnlAssignRights(wx.Panel):
def __init__(self, parent, rights):
self.parent = parent
super().__init__(parent, name='assignRights')
...


class PnlAccessRights(wx.Panel):
def __init__(self, parent):
...
self.pnl_assignrights = PnlAccessRights(parent)

# before I have a button in this Panel which opened a new frame containing the PnlAssignRights class.
# now I want to merge both screens into 1 Panel


class FrmConfigAccessRights(wx.Frame):
def __init__(self, parent, **kwargs):
wx.Frame.__init__(self, parent, -1, **kwargs)
iconloc = "pkg/icons/{}.png"
self.SetIcon(wx.Icon(iconloc.format("AccessKey")))

self.panel = PnlAccessRights(self)
# Setup StatusBar
self.CreateStatusBar()

width = self.GetEffectiveMinSize().GetWidth() + 500
height = self.GetEffectiveMinSize().GetHeight() + 100

self.SetMinSize((width, height))
self.SetSize(width, height)


Can a Panel have a sub-Panel?
I've been searching in books and the internet to find how to do this, but unsuccessfull this far.

I want to avoid to having to copy all the code from the PnlAssignRights into the PnlAccessRights.


# using PnlAccessRights(parent) seems to end up in an infinite loop (Pycharm runs forever until I stop it)
# using PnlAccessRights(self)


File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: How to assign a PanelClass as element in another PanelClass

ignace danneels
I attached a sample of the problem.
Based on the information from wxPython_2.8_application_development_cookbook (page 12)
"
 top-level-window (frame
 General Containers (panels)
 controls

The Top-Level Window is at the top of the hierarchy and it can contain any kind of window
except another Top-Level Window. General Containers come next, and they can arbitrarily
hold any other General Container or Control"

I have a panel (Quitbutton) that contains a button and the corresponding event.
The PnlQuitter is a panel that contains 2 instances of QuitButton.
Then I have the TestApp, with contains the PnlQuitter.

I'm expecting to see the 2 panels, each with their button, but I only see one panel.
What's wrong with this code?

On Monday, August 13, 2018 at 10:40:07 PM UTC+2, Blue Flash wrote:
I created an application in which I open a sub-window (configure Rights).
That frame contains a panel that contains some 2 wxTree items and a button to open a new window Assign Rights (wxFrame), again containing a panel (wxPanel)

after reviewing the code, I found it could be better to embed the entire code of the Assign rights into the configuration window.
this is a typical example of how OOP should work.

What I want to do, is in the Configure Right Panel,  assign a variable self.pnlAssignRights = PnlAssignRights(), which contains all the buttons, the events etc which I would like to port.



class PnlAssignRights(wx.Panel):
def __init__(self, parent, rights):
self.parent = parent
super().__init__(parent, name='assignRights')
...


class PnlAccessRights(wx.Panel):
def __init__(self, parent):
...
self.pnl_assignrights = PnlAccessRights(parent)

# before I have a button in this Panel which opened a new frame containing the PnlAssignRights class.
# now I want to merge both screens into 1 Panel


class FrmConfigAccessRights(wx.Frame):
def __init__(self, parent, **kwargs):
wx.Frame.__init__(self, parent, -1, **kwargs)
iconloc = "pkg/icons/{}.png"
self.SetIcon(wx.Icon(iconloc.format("AccessKey")))

self.panel = PnlAccessRights(self)
# Setup StatusBar
self.CreateStatusBar()

width = self.GetEffectiveMinSize().GetWidth() + 500
height = self.GetEffectiveMinSize().GetHeight() + 100

self.SetMinSize((width, height))
self.SetSize(width, height)


Can a Panel have a sub-Panel?
I've been searching in books and the internet to find how to do this, but unsuccessfull this far.

I want to avoid to having to copy all the code from the PnlAssignRights into the PnlAccessRights.


# using PnlAccessRights(parent) seems to end up in an infinite loop (Pycharm runs forever until I stop it)
# using PnlAccessRights(self)


File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__

--
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.

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

Re: How to assign a PanelClass as element in another PanelClass

Chris Barker - NOAA Federal
a little confused about what yu are doign with all those frames, but in this example:

class Quitter2(wx.Frame):                          # subclass our GUI
    def __init__(self, **kwargs):           # constructor method
        super().__init__(**kwargs)
        pnl1= PnlQuitter(self)
        pnl2= PnlQuitter(self)


yu have put two panels in the frame, but you haven't told the frame how to arrange them. I suspect that you are gettin gone right on top of the other.

You want to use Sizers for that.

-CHB







On Tue, Aug 21, 2018 at 9:37 AM, Blue Flash <[hidden email]> wrote:
I attached a sample of the problem.
Based on the information from wxPython_2.8_application_development_cookbook (page 12)
"
 top-level-window (frame
 General Containers (panels)
 controls

The Top-Level Window is at the top of the hierarchy and it can contain any kind of window
except another Top-Level Window. General Containers come next, and they can arbitrarily
hold any other General Container or Control"

I have a panel (Quitbutton) that contains a button and the corresponding event.
The PnlQuitter is a panel that contains 2 instances of QuitButton.
Then I have the TestApp, with contains the PnlQuitter.

I'm expecting to see the 2 panels, each with their button, but I only see one panel.
What's wrong with this code?

On Monday, August 13, 2018 at 10:40:07 PM UTC+2, Blue Flash wrote:
I created an application in which I open a sub-window (configure Rights).
That frame contains a panel that contains some 2 wxTree items and a button to open a new window Assign Rights (wxFrame), again containing a panel (wxPanel)

after reviewing the code, I found it could be better to embed the entire code of the Assign rights into the configuration window.
this is a typical example of how OOP should work.

What I want to do, is in the Configure Right Panel,  assign a variable self.pnlAssignRights = PnlAssignRights(), which contains all the buttons, the events etc which I would like to port.



class PnlAssignRights(wx.Panel):
def __init__(self, parent, rights):
self.parent = parent
super().__init__(parent, name='assignRights')
...


class PnlAccessRights(wx.Panel):
def __init__(self, parent):
...
self.pnl_assignrights = PnlAccessRights(parent)

# before I have a button in this Panel which opened a new frame containing the PnlAssignRights class.
# now I want to merge both screens into 1 Panel


class FrmConfigAccessRights(wx.Frame):
def __init__(self, parent, **kwargs):
wx.Frame.__init__(self, parent, -1, **kwargs)
iconloc = "pkg/icons/{}.png"
self.SetIcon(wx.Icon(iconloc.format("AccessKey")))

self.panel = PnlAccessRights(self)
# Setup StatusBar
self.CreateStatusBar()

width = self.GetEffectiveMinSize().GetWidth() + 500
height = self.GetEffectiveMinSize().GetHeight() + 100

self.SetMinSize((width, height))
self.SetSize(width, height)


Can a Panel have a sub-Panel?
I've been searching in books and the internet to find how to do this, but unsuccessfull this far.

I want to avoid to having to copy all the code from the PnlAssignRights into the PnlAccessRights.


# using PnlAccessRights(parent) seems to end up in an infinite loop (Pycharm runs forever until I stop it)
# using PnlAccessRights(self)


File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__
self.pnl_assignrights = PnlAccessRights(self)
File "D:\werkblad\SubVersion\sact\pkg\layout\configRights.py", line 112, in __init__

--
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.



--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[hidden email]

--
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.