Is there any control like this? - (2)

it seems like no more allowed to upload above 100 messages in mailing
list.
so I creates second title. please understand me.

actually I don't understand sizer's index pattern.
but as you said. the index was (0, 1), (2, 3), (4, 5)...
and can I get the index of the selected stc? it seems like there is no
function to get the index of the control in Sizer.
so I made some function to get index. I am not sure whether it is
acceptable.

panel -> stc -> popupmenu

class MyPopupMenu(wx.Menu):
    def __init__(self, parent, id):

        frmmi = wx.MenuItem(self, wx.NewId(), 'Add control')
        self.AppendItem(frmmi)
        self.Bind(wx.EVT_MENU, self.OnAddFr, frmmi)

    def OnAddFr(self, e):
        self.grandparent.GetPosInSizer(self.GetParent().GetId())

class STC(st.StyledTextCtrl):
    def __init__(self, *args, **kwargs):

    def OnRightDown(self, e):
        control = e.GetEventObject()
        self.PopupMenu(MyPopupMenu(self.GetParent(), self.GetId()))

class TestPanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)

    def GetPosInSizer(self, control):
        chil = self.Autosizer.GetChildren()
        for pos in range(len(chil)):
            szitem = chil[pos]
            if szitem.GetId() == control.GetId():
                return pos

    def OnAddFortran(self, event):
        self.text = wx.StaticText(self, label='F')
        self.editor = STC(self)

        self.Autosizer.Insert(4, self.text)
        self.Autosizer.Insert(5, self.editor, flag=wx.EXPAND)
        self.Layout()

can I pass the argument like this?

def OnAddFortran(self, controlpos, event):
    self.Autosizer.Insert(controlpos, self.text)
    self.Autosizer.Insert(controlpos+1, self.editor, flag=wx.EXPAND)
···

2011/10/25 Wonjun, Choi wonjunchoi001@gmail.com

it seems like no more allowed to upload above 100 messages in mailing

list.

so I creates second title. please understand me.

actually I don’t understand sizer’s index pattern.

but as you said. the index was (0, 1), (2, 3), (4, 5)…

and can I get the index of the selected stc? it seems like there is no

function to get the index of the control in Sizer.

so I made some function to get index. I am not sure whether it is

acceptable.

panel → stc → popupmenu

class MyPopupMenu(wx.Menu):

def __init__(self, parent, id):



    frmmi = wx.MenuItem(self, wx.NewId(), 'Add control')

    self.AppendItem(frmmi)

    self.Bind(wx.EVT_MENU, self.OnAddFr, frmmi)



def OnAddFr(self, e):

    self.grandparent.GetPosInSizer(self.GetParent().GetId())

class STC(st.StyledTextCtrl):

def __init__(self, *args, **kwargs):



def OnRightDown(self, e):

    control = e.GetEventObject()

    self.PopupMenu(MyPopupMenu(self.GetParent(), self.GetId()))

class TestPanel(wx.Panel):

def __init__(self, parent):

    wx.Panel.__init__(self, parent, -1)



def GetPosInSizer(self, control):

    chil = self.Autosizer.GetChildren()

    for pos in range(len(chil)):

        szitem = chil[pos]

        if szitem.GetId() == control.GetId():

            return pos



def OnAddFortran(self, event):

    self.text = wx.StaticText(self, label='F')

    self.editor = STC(self)



    self.Autosizer.Insert(4, self.text)

    self.Autosizer.Insert(5, self.editor, flag=wx.EXPAND)

    self.Layout()

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Of course you can, you could even do it like this:
def OnAddFortran(self, row, event):
# NB Row is numbered from 0
ed = function_to_crate_fortran_stc()
tx = function_to_crate_fortran_static_text()
self.editors.insert(row, ed) # HINT HINT HINT
self.texts.insert(row, tx) # HINT HINT HINT

   insert_at = row*2

   self.Autosizer.Insert(insert_at, ed, flag=wx.EXPAND)

   self.Autosizer.Insert(insert_at, tx) # Pushes ed to insert_at + 1
···

wxPython-users+unsubscribe@googlegroups.com
http://groups.google.com/group/wxPython-users?hl=en

I call the OnAddFortran function as self.NB.GetCurrentPage().OnAddFortran(Panel)

but if I use def OnAddFortran(self, row, event):, how can I call it? there was some error because of the argument

I think inserting the controls individually is not efficient.
how about this?

controlpos is global variable = 0

class MyPopupMenu(wx.Menu):

def __init__(self, parent, id):
    super(MyPopupMenu, self).__init__()

    frmmi = wx.MenuItem(self, wx.NewId(), 'Add control')
    self.AppendItem(frmmi)

    self.Bind(wx.EVT_MENU, self.OnAddFr, frmmi)

def OnAddFr(self, e):

// self.GetParent().GetId() method is not working.
controlpos = self.grandparent.GetPosInSizer(self.GetParent().GetId())

    wx.CallAfter(self.grandparent.OnAddFortran, self)

def OnAddFortran(self, event):
    text = wx.StaticText(self, label='F')
    editor = STC(self)

    if controlpos != 0:

        self.Autosizer.Insert(controlpos, text)
        self.Autosizer.Insert(controlpos + 1, editor)
    else:
    self.Autosizer.Add(text, 0)

    self.Autosizer.Add(editor, 1, wx.EXPAND)
    self.Layout()

// Is this function right?
def GetPosInSizer(self, control):
chil = self.Autosizer.GetChildren()
for pos in range(len(chil)):

        szitem = chil[pos]
        if szitem.GetId() == control:
            return pos
···

2011/10/25 Gadget/Steve GadgetSteve@live.co.uk

On 25/10/2011 8:25 AM, 최원준 wrote:

2011/10/25 Wonjun, Choi wonjunchoi001@gmail.com

      it seems like no more allowed to upload above 100 messages in

mailing

      list.

      so I creates second title. please understand me.



      actually I don't understand sizer's index pattern.

      but as you said. the index was (0, 1), (2, 3), (4, 5)...

      and can I get the index of the selected stc? it seems like

there is no

      function to get the index of the control in Sizer.

      so I made some function to get index. I am not sure whether it

is

      acceptable.



      panel -> stc -> popupmenu





      class MyPopupMenu(wx.Menu):

         def __init__(self, parent, id):



             frmmi = wx.MenuItem(self, wx.NewId(), 'Add control')

             self.AppendItem(frmmi)

             self.Bind(wx.EVT_MENU, self.OnAddFr, frmmi)



         def OnAddFr(self, e):

self.grandparent.GetPosInSizer(self.GetParent().GetId())

      class STC(st.StyledTextCtrl):

         def __init__(self, *args, **kwargs):



         def OnRightDown(self, e):

             control = e.GetEventObject()

             self.PopupMenu(MyPopupMenu(self.GetParent(),

self.GetId()))

      class TestPanel(wx.Panel):

         def __init__(self, parent):

             wx.Panel.__init__(self, parent, -1)



         def GetPosInSizer(self, control):

             chil = self.Autosizer.GetChildren()

             for pos in range(len(chil)):

                 szitem = chil[pos]

                 if szitem.GetId() == control.GetId():

                     return pos



         def OnAddFortran(self, event):

             self.text = wx.StaticText(self, label='F')

             self.editor = STC(self)



             self.Autosizer.Insert(4, self.text)

             self.Autosizer.Insert(5, self.editor, flag=wx.EXPAND)

             self.Layout()



        --

        To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

        or visit [http://groups.google.com/group/wxPython-users?hl=en](http://groups.google.com/group/wxPython-users?hl=en)
  can I pass the argument like this?



      def OnAddFortran(self, controlpos, event):

          self.Autosizer.Insert(controlpos, self.text)

          self.Autosizer.Insert(controlpos+1, self.editor,

flag=wx.EXPAND)

  --

  To unsubscribe, send email to

wxPython-users+unsubscribe@googlegroups.com

  or visit [http://groups.google.com/group/wxPython-users?hl=en](http://groups.google.com/group/wxPython-users?hl=en)

Of course you can, you could even do it like this:
def OnAddFortran(self, row, event):
# NB Row is numbered from 0
ed = function_to_crate_fortran_stc()
tx = function_to_crate_fortran_static_text()
self.editors.insert(row, ed) # HINT HINT HINT
self.texts.insert(row, tx) # HINT HINT HINT

   insert_at = row*2

   self.Autosizer.Insert(insert_at, ed, flag=wx.EXPAND)

   self.Autosizer.Insert(insert_at, tx) # Pushes ed to insert_at + 1

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en