[wxpython-users] three intern windows in one window

FT chester_lab at fltg.net
Sun May 4 17:47:01 PDT 2008


Hi!

    Below is a small test example on communicating from one panel to
another. Like the last question on the web about tabbing between panels you
have to get a parent panel to talk to each other.
    It would appear that you want 3 panels on the screen where one has
message boxes and another that has buttons and such.
    My example that runs as is and if you do not have the pyTTS engine, then
delete it and it will still work.

    You will note that the right panel must be placed in such a way to be
able to communicate to. It just has an example of a text box but that is
what you wanted on the right side. Messages and such.

    You just have to get one panel the parent to all panels as children.
This should be a good simple sample.

    The 2 buttons are clicked on and each do a process based on what is
given in the bind subroutine and such.

    The sizer places each panel as you so desire. It can also be placed as a
grid, what way you desire. The sizer is tied to the panel in
control...panel.SetSizer(name4box)

    I hope this helps. Just add another panel to run videos and such and it
should work.

        Bruce

On Sun, May 4, 2008 at 7:33 PM, Abdessamad EL GON-NOUNI
<abdessamadg at gmail.com> wrote:
> hello,
>     I'm making a graphic interface with wxpython and I want to have three
> internal windows, one will display an image which changes every time, the
> second will contain other wibdows which have buttons and text fields and
the
> third one is for showing some messages. I'm struggling with too many
> tutorials and I found that flixBoxSizer is the best one for me but I
didn't
> understand very well how it works. I would like to have some help from you
> please.

Do you mean BoxSizer or FlexGridSizer?  In any case, maybe what might
be good is to look at the sizers tutorial on the wiki, and then ask specific
questions to the list about what you don't understand.  That tutorial and
the
examples in it is found here:
http://wiki.wxpython.org/UsingSizers
_______________________________________________
wxpython-users mailing list
wxpython-users at lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users



Description="""
Widgets communicate
It is important to know, how widgets can communicate in application. Follow
the example."""
#!/usr/bin/python
# communicate.py
#HOW TO COMMUNICATE INSIDE A FRAME PANELS!
import wx
import pyTTS
tts = pyTTS.Create()
class LeftPanel(wx.Panel):
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, id, style=wx.BORDER_SUNKEN)
        self.text = parent.GetParent().rightPanel.text
        button1 = wx.Button(self, -1, '+', (10, 10))
        button2 = wx.Button(self, -1, '-', (10, 60))
        self.Bind(wx.EVT_BUTTON, self.OnPlus, id=button1.GetId())
        self.Bind(wx.EVT_BUTTON, self.OnMinus, id=button2.GetId())
    def OnPlus(self, event):
        value = int(self.text.GetLabel())
        value = value + 1
        tts.Speak(value)
        self.text.SetLabel(str(value))
    def OnMinus(self, event):
        value = int(self.text.GetLabel())
        value = value - 1
        tts.Speak(value)
        self.text.SetLabel(str(value))
class RightPanel(wx.Panel):
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, id, style=wx.BORDER_SUNKEN)
        self.text = wx.StaticText(self, -1, '0', (40, 60))
class Communicate(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(280, 200))
        panel = wx.Panel(self, -1)
        self.rightPanel = RightPanel(panel, -1)
        leftPanel = LeftPanel(panel, -1)
        hbox = wx.BoxSizer()
        hbox.Add(leftPanel, 1, wx.EXPAND | wx.ALL, 5)
        hbox.Add(self.rightPanel, 1, wx.EXPAND | wx.ALL, 5)
        panel.SetSizer(hbox)
        self.Centre()
        self.Show(True)
app = wx.App()
Communicate(None, -1, 'widgets communicate')
app.MainLoop()



More information about the wxpython-users mailing list