[wxpython] Is there any control like this?

I could add a row(StaticText + STC) to Autosizer in TestPanel by below method.

class TestPanel(wx.Panel):
def init(self, parent):

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

    self.Autosizer.Add(self.text,0)

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

and, I wanted to delete some added row by using sizer.Remove() method.
I am not sure whether this way is right but I tried it.

when I used self.parent.Autosizer.Remove(self.parent.stc1.GetId()) to remove a row,
there was no error but it deleted nothing.

so, I tried below:
self.parent.Autosizer.Remove(self.parent.text)
self.parent.Autosizer.Remove(self.parent.editor)

    self.parent.Layout()

but there was no error and it deleted nothing.

it is in contentmenu class.
class MyPopupMenu(wx.Menu):
def init(self, parent):
super(MyPopupMenu, self).init()

    self.parent = parent

    mmi = wx.MenuItem(self, wx.NewId(), 'Remove')
    self.AppendItem(mmi)
    self.Bind(wx.EVT_MENU, self.OnRemove, mmi)

def OnRemove(self, e):

    self.parent.Autosizer.Remove(self.parent.text)
    self.parent.Autosizer.Remove(self.parent.editor)
    self.parent.Layout()

self.parent is TestPanel in this code.
the calling structure was : TestPanel → STC(->MyPopupMenu), Autosizer

···

2011/10/19 C M cmpython@gmail.com

I did like this.

self.stc1.SetId(wx.NewId())

self.parent.Autosizer.Remove(self.parent.stc1.GetId())

self.parent.Layout()

but it didn’t work.

In order to get much better help on this list, you need to explain WHY

something didn’t work. There are various ways something doesn’t work:

  • It does nothing at all.

  • It does something other than what you wanted it to do.

  • An error is thrown.

So please let us know (and all times in the future) what the

specific problem is in this way.

One tip, though: Do you think these lines of yours should work?:

self.parent.Getparent()

self.parent.panel.Autosizer.Remove(0)

If not, why not? The point is, there is a fundamental point of Python

and programming generally that you are not seeing yet.

Che

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

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

and, I wanted to delete some added row by using sizer.Remove() method.
I am not sure whether this way is right but I tried it.
...there was no error but it deleted nothing.

Please read the API for the method you used, wx.Sizer.Remove(), and I
think it will be clear why this did nothing (particularly note the
part that says "NB", meaning "nota bene", or note well):

http://docs.wxwidgets.org/2.8/wx_wxsizer.html#wxsizerremove

Instead of this, you can just .Destroy() whichever object you want and
then call .Layout() on the parent panel and the sizer will be
intelligently updated in terms of layout.

Che

The trick is that you need to remove what you added then delete what
you created in principle if you added to self.Autosizer self.text
and self.editor then you call self.Autosizer.Remove(self.text) and
(self.editor) then delete them BUT if you look at the documentation
then you need to pass an index to the Remove function so if you wish
to remove the first line, of 2 items), from your sizer you need to
call self.Autosizer.Remove(1) then Remove(0). You also have a
problem with the delte as since you have stored them in when created
as self.text and self.edit you will only have references to the
latest ones created, to fix this you will need to either store the
edit and text items when created into one or more arrays or BEFORE
removing them from the sizer call AutoSizer.GetItem(0) and (1) to
get the actual items and AFTER removing them from the sizer delete
them.

Gadget/Steve
···

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

when I used .Destroy() method. it terminated the whole program.

and when I used self.Autosizer.Remove(0), self.Autosizer.Remove(1), it deleted the first row
but I wanted to deleted the selected row. it could be first row or third row. anything else.

Although I save the row to array, how can I know whether it is the selected row or not?

and I found some puzzle sample. it was using below method.

        self.sizer.Remove(self.panel)
        self.sizer.Remove(button)
        self.sizer.Insert(buttonIndex, self.panel)
        self.sizer.Insert(buttonIndex+3, button)

        self.sizer.Layout()

so I thought it is possible to add a row to some line or delete some row from the specific line.

Wonjun, Choi

···

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

On 19/10/2011 5:49 AM, 최원준 wrote:

2011/10/19 C M cmpython@gmail.com

I did like this.

        >

        > self.stc1.SetId(wx.NewId())

        >

        > self.parent.Autosizer.Remove(self.parent.stc1.GetId())

        > self.parent.Layout()

        >

        > but it didn't work.
      In order to get much better help on this list, you need to

explain WHY

      something didn't work.  There are various ways something

doesn’t work:

      - It does nothing at all.

      - It does something other than what you wanted it to do.

      - An error is thrown.



      So please let us know (and all times in the future) what the

      *specific* problem is in this way.



      One tip, though:  Do you think these lines of yours should

work?:

      self.parent.Getparent()

      self.parent.panel.Autosizer.Remove(0)



      If not, why not? The point is, there is a fundamental point of

Python

      and programming generally that you are not seeing yet.



      Che


          --

          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)
  I could add a row(StaticText + STC) to Autosizer in TestPanel by

below method.

  class TestPanel(wx.Panel):

      def __init__(self, parent):



      def OnAdd(self, event):

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

          self.editor = STC(self)



          self.Autosizer.Add(self.text,0)

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

          self.Layout()



  and, I wanted to delete some added row by using sizer.Remove()

method.

  I am not sure whether this way is right but I tried it.



  when I used self.parent.Autosizer.Remove(self.parent.stc1.GetId())

to remove a row,

  there was no error but it deleted nothing.



  so, I tried below:

          self.parent.Autosizer.Remove(self.parent.text)

          self.parent.Autosizer.Remove(self.parent.editor)

          self.parent.Layout()



  but there was no error and it deleted nothing.



  it is in contentmenu class.

  class MyPopupMenu(wx.Menu):

      def __init__(self, parent):

          super(MyPopupMenu, self).__init__()

         

          self.parent = parent



          mmi = wx.MenuItem(self, wx.NewId(), 'Remove')

          self.AppendItem(mmi)

          self.Bind(wx.EVT_MENU, self.OnRemove, mmi)



      def OnRemove(self, e):

          self.parent.Autosizer.Remove(self.parent.text)

          self.parent.Autosizer.Remove(self.parent.editor)

          self.parent.Layout()



  self.parent is TestPanel in this code.

  the calling structure was : TestPanel -> STC(->MyPopupMenu),

Autosizer

  --

  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)
The trick is that you need to remove what you added then delete what

you created in principle if you added to self.Autosizer self.text
and self.editor then you call self.Autosizer.Remove(self.text) and
(self.editor) then delete them BUT if you look at the documentation
then you need to pass an index to the Remove function so if you wish
to remove the first line, of 2 items), from your sizer you need to
call self.Autosizer.Remove(1) then Remove(0). You also have a
problem with the delte as since you have stored them in when created
as self.text and self.edit you will only have references to the
latest ones created, to fix this you will need to either store the
edit and text items when created into one or more arrays or BEFORE
removing them from the sizer call AutoSizer.GetItem(0) and (1) to
get the actual items and AFTER removing them from the sizer delete
them.

Gadget/Steve

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

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

when I used .Destroy() method. it terminated the whole program.

It sounds like you tried calling self.Destroy(). Is that what you
did? I meant to use the .Destroy() method on the objects in a row you
want to get rid of, such as:

        textCtrl_to_destroy.Destroy()

This will destroy that textCtrl. So, if you can identify an object
you want destroyed, you write:

object.Destroy()

I have tested like this:

def OnRemove(self, e):

    self.parent.text.Destroy() <- it works well but it deletes only the last StaticText in sizer.
    self.parent.editor.Destory() <- the error occured : AttributeError: 'STC' object has no attribute 'Destory'
···

2011/10/19 C M cmpython@gmail.com

when I used .Destroy() method. it terminated the whole program.

It sounds like you tried calling self.Destroy(). Is that what you

did? I meant to use the .Destroy() method on the objects in a row you

want to get rid of, such as:

    textCtrl_to_destroy.Destroy()

This will destroy that textCtrl. So, if you can identify an object

you want destroyed, you write:

object.Destroy()

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

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

so I made some overloaded method for Destory()

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

def Destroy(self):
    self.Close()

but it also said : AttributeError: ‘STC’ object has no attribute ‘Destory’

···

2011/10/19 최원준 wonjunchoi001@gmail.com

2011/10/19 C M cmpython@gmail.com

when I used .Destroy() method. it terminated the whole program.

It sounds like you tried calling self.Destroy(). Is that what you

did? I meant to use the .Destroy() method on the objects in a row you

want to get rid of, such as:

    textCtrl_to_destroy.Destroy()

This will destroy that textCtrl. So, if you can identify an object

you want destroyed, you write:

object.Destroy()

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

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

I have tested like this:

def OnRemove(self, e):

    self.parent.text.Destroy() <- it works well but it deletes only the last StaticText in sizer.
    self.parent.editor.Destory() <- the error occured : AttributeError: 'STC' object has no attribute 'Destory'

2011년 10월 19일 오후 3:13, 최원준 wonjunchoi001@gmail.com님의 말:

when I used .Destroy() method. it terminated the whole program.

It sounds like you tried calling self.Destroy(). Is that what you

did? I meant to use the .Destroy() method on the objects in a row you

want to get rid of, such as:

    textCtrl_to_destroy.Destroy()

This will destroy that textCtrl. So, if you can identify an object

you want destroyed, you write:

object.Destroy()

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

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

I have tested like this:

def OnRemove(self, e):

    self.parent.text.Destroy() <- it works well but it deletes only the last StaticText in sizer.
    self.parent.editor.Destory() <- the error occured : AttributeError: 'STC' object has no attribute 'Destory'

so I made some overloaded method for Destory()

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

def Destroy(self):
    self.Close()

but it also said : AttributeError: ‘STC’ object has no attribute ‘Destory’

when I coded like this:

    self.parent.Autosizer.Remove(self.parent.Autosizer.GetItem(0))
    self.parent.Autosizer.Remove(self.parent.Autosizer.GetItem(1))
    self.parent.Layout()

it said : TypeError: wx.Window, wx.Sizer or int (position) expected for item

···

2011/10/19 최원준 wonjunchoi001@gmail.com

2011/10/19 C M cmpython@gmail.com

The error message tells you what is going wrong. If, for example,
you wish to remove row 3 use:

    Row = 3-1 # since rows are actually numbered from 0

    TextToDistroy = self.Autosizer.GetItem(Row*2) # Get the item

given there are 2 items per row

    EditToDistroy = self.Autosizer.GetItem(Row*2+1) # Get the other

item on the row

    self.Autosizer.Remove(Row*2+1) # Need to remove last first

    self.Autosizer.Remove(Row*2)

    del TextToDistroy # or TextToDistroy.Destroy()

    del EditToDistroy # or EditToDistroy.Destroy()

Please do things one line at a time - it makes things much clearer. 

If you are using more than one set of parenthesis, i.e f(g()) or
f().g(), on a line then use a temporary variable and split things
into multiple statements.

Gadget/Steve
···

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

2011년 10월 19일 오후 4:11, Gadget/Steve GadgetSteve@live.co.uk님의 말:

2011년 10월 19일 오후 3:13, 최원준 wonjunchoi001@gmail.com
의 말:

                        > when I used .Destroy() method. it

terminated the whole program.

                      It sounds like you tried calling

self.Destroy(). Is that what you

                      did?  I meant to use the .Destroy() method on

the objects in a row you

                      want to get rid of, such as:



                             textCtrl_to_destroy.Destroy()



                      This will destroy that textCtrl.  So, if you

can identify an object

                      you want destroyed, you write:



                      object.Destroy()


                          --

                          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)

I have tested like this:

                  def OnRemove(self, e):

                      self.parent.text.Destroy() <- it works well

but it deletes only the last StaticText in sizer.

                      self.parent.editor.Destory() <- the error

occured : AttributeError: ‘STC’ object has no
attribute ‘Destory’

so I made some overloaded method for Destory()

      class STC(st.StyledTextCtrl):

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



          def Destroy(self):

              self.Close()



      but it also said : AttributeError: 'STC' object has no

attribute ‘Destory’

  when I coded like this:

self.parent.Autosizer.Remove(self.parent.Autosizer.GetItem(0))

self.parent.Autosizer.Remove(self.parent.Autosizer.GetItem(1))

          self.parent.Layout()



  it said : TypeError: wx.Window, wx.Sizer or int (position)

expected for item

  --

  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)
The error message tells you what is going wrong.  If, for example,

you wish to remove row 3 use:

    Row = 3-1 # since rows are actually numbered from 0

    TextToDistroy = self.Autosizer.GetItem(Row*2) # Get the item

given there are 2 items per row

    EditToDistroy = self.Autosizer.GetItem(Row*2+1) # Get the other

item on the row

    self.Autosizer.Remove(Row*2+1) # Need to remove last first

    self.Autosizer.Remove(Row*2)

    del TextToDistroy # or TextToDistroy.Destroy()

    del EditToDistroy # or EditToDistroy.Destroy()



Please do things one line at a time - it makes things much clearer. 

If you are using more than one set of parenthesis, i.e f(g()) or
f().g(), on a line then use a temporary variable and split things
into multiple statements.

Gadget/Steve

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

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

what Row*2 means? i don’t understand exactly.

and I tried like this:

def OnRemove(self, e):
    Row = 0
    TextToDistroy = self.parent.Autosizer.GetItem(Row)
    EditToDistroy = self.parent.Autosizer.GetItem(Row+1)
    self.parent.Autosizer.Remove(Row+1)

    self.parent.Autosizer.Remove(Row)
    del TextToDistroy
    del EditToDistroy
    self.parent.Layout()

in order to delete row 0 in Autosizer, I set Row = 0
it deleted textctrl from row 0 but StaticText

I don’t know why

···

On 19/10/2011 7:41 AM, 최원준 wrote:

2011/10/19 최원준 wonjunchoi001@gmail.com

2011/10/19 C M cmpython@gmail.com

2011년 10월 19일 오후 4:45, 최원준 wonjunchoi001@gmail.com님의 말:

2011년 10월 19일 오후 4:11, Gadget/Steve GadgetSteve@live.co.uk님의 말:

2011년 10월 19일 오후 3:13, 최원준 wonjunchoi001@gmail.com
의 말:

                        > when I used .Destroy() method. it

terminated the whole program.

                      It sounds like you tried calling

self.Destroy(). Is that what you

                      did?  I meant to use the .Destroy() method on

the objects in a row you

                      want to get rid of, such as:



                             textCtrl_to_destroy.Destroy()



                      This will destroy that textCtrl.  So, if you

can identify an object

                      you want destroyed, you write:



                      object.Destroy()


                          --

                          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)

I have tested like this:

                  def OnRemove(self, e):

                      self.parent.text.Destroy() <- it works well

but it deletes only the last StaticText in sizer.

                      self.parent.editor.Destory() <- the error

occured : AttributeError: ‘STC’ object has no
attribute ‘Destory’

so I made some overloaded method for Destory()

      class STC(st.StyledTextCtrl):

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



          def Destroy(self):

              self.Close()



      but it also said : AttributeError: 'STC' object has no

attribute ‘Destory’

  when I coded like this:

self.parent.Autosizer.Remove(self.parent.Autosizer.GetItem(0))

self.parent.Autosizer.Remove(self.parent.Autosizer.GetItem(1))

          self.parent.Layout()



  it said : TypeError: wx.Window, wx.Sizer or int (position)

expected for item

  --

  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)
The error message tells you what is going wrong.  If, for example,

you wish to remove row 3 use:

    Row = 3-1 # since rows are actually numbered from 0

    TextToDistroy = self.Autosizer.GetItem(Row*2) # Get the item

given there are 2 items per row

    EditToDistroy = self.Autosizer.GetItem(Row*2+1) # Get the other

item on the row

    self.Autosizer.Remove(Row*2+1) # Need to remove last first

    self.Autosizer.Remove(Row*2)

    del TextToDistroy # or TextToDistroy.Destroy()

    del EditToDistroy # or EditToDistroy.Destroy()



Please do things one line at a time - it makes things much clearer. 

If you are using more than one set of parenthesis, i.e f(g()) or
f().g(), on a line then use a temporary variable and split things
into multiple statements.

Gadget/Steve

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

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

what Row*2 means? i don’t understand exactly.

and I tried like this:

def OnRemove(self, e):
    Row = 0
    TextToDistroy = self.parent.Autosizer.GetItem(Row)
    EditToDistroy = self.parent.Autosizer.GetItem(Row+1)
    self.parent.Autosizer.Remove(Row+1)


    self.parent.Autosizer.Remove(Row)
    del TextToDistroy
    del EditToDistroy
    self.parent.Layout()

in order to delete row 0 in Autosizer, I set Row = 0
it deleted textctrl from row 0 but StaticText

I don’t know why

I made some summary. please review this screenshot.

···

On 19/10/2011 7:41 AM, 최원준 wrote:

2011/10/19 최원준 wonjunchoi001@gmail.com

2011/10/19 C M cmpython@gmail.com

REMOVE FIRST THEN DELETE!!!

···

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

2011년 10월 19일 오후 5:54, Gadget/Steve GadgetSteve@live.co.uk님의 말:

2011년 10월 19일 오후 4:45, 최원준 wonjunchoi001@gmail.com
의 말:

2011년 10월 19일 오후 4:11, Gadget/Steve GadgetSteve@live.co.uk
의 말:

                    2011년 10월 19일 오후 3:13,

최원준 wonjunchoi001@gmail.com
의 말:

                                2011/10/19

최원준 wonjunchoi001@gmail.com

                                        2011/10/19

C M cmpython@gmail.com

                                            > when I used

.Destroy() method. it
terminated the whole
program.

                                          It sounds like you tried

calling self.Destroy().
Is that what you

                                          did?  I meant to use the

.Destroy() method on the
objects in a row you

                                          want to get rid of, such

as:

textCtrl_to_destroy.Destroy()

                                          This will destroy that

textCtrl. So, if you can
identify an object

                                          you want destroyed, you

write:

                                          object.Destroy()


                                              --

                                              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)

I have tested like this:

                                      def OnRemove(self, e):

                                          self.parent.text.Destroy()

← it works well but it deletes
only the last StaticText in sizer.

self.parent.editor.Destory() ←
the error occured :
AttributeError: ‘STC’ object has
no attribute ‘Destory’

                          so I made some overloaded method for

Destory()

                          class STC(st.StyledTextCtrl):

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



                              def Destroy(self):

                                  self.Close()



                          but it also said : AttributeError: 'STC'

object has no attribute ‘Destory’

                      when I coded like this:

self.parent.Autosizer.Remove(self.parent.Autosizer.GetItem(0))

self.parent.Autosizer.Remove(self.parent.Autosizer.GetItem(1))

                              self.parent.Layout()



                      it said : TypeError: wx.Window, wx.Sizer or

int (position) expected for item

                      --

                      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)
                The error message tells you what is going wrong. 

If, for example, you wish to remove row 3 use:

                    Row = 3-1 # since rows are actually numbered

from 0

                    TextToDistroy = self.Autosizer.GetItem(Row*2) #

Get the item given there are 2 items per row

                    EditToDistroy = self.Autosizer.GetItem(Row*2+1)

Get the other item on the row

                    self.Autosizer.Remove(Row*2+1) # Need to remove

last first

                    self.Autosizer.Remove(Row*2)

                    del TextToDistroy # or TextToDistroy.Destroy()

                    del EditToDistroy # or EditToDistroy.Destroy()



                Please do things one line at a time - it makes

things much clearer. If you are using more than one
set of parenthesis, i.e f(g()) or f().g(), on a line
then use a temporary variable and split things into
multiple statements.

                  Gadget/Steve

                  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)
      what Row*2 means? i don't understand exactly.



      and I tried like this:



          def OnRemove(self, e):

              Row = 0

              TextToDistroy = self.parent.Autosizer.GetItem(Row)

              EditToDistroy = self.parent.Autosizer.GetItem(Row+1)

              self.parent.Autosizer.Remove(Row+1)

              self.parent.Autosizer.Remove(Row)

              del TextToDistroy

              del EditToDistroy

              self.parent.Layout()



      in order to delete row 0 in Autosizer, I set Row = 0

      it deleted textctrl from row 0 but StaticText

      I don't know why
  I made some summary. please review this screenshot.





  --

  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)

REMOVE FIRST THEN DELETE!!!

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

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

I did like that even though the screenshot is wrong :

def OnRemove(self, e):
    Row = 0
    TextToDistroy = self.parent.Autosizer.GetItem(Row)

EditToDistroy = self.parent.Autosizer.GetItem(Row+1)
self.parent.Autosizer.Remove(Row+1)

    self.parent.Autosizer.Remove(Row)
    del TextToDistroy
    del EditToDistroy
    self.parent.Layout()
···

On 19/10/2011 9:26 AM, 최원준 wrote:

                On 19/10/2011 > > > > 7:41 AM, 최원준 wrote:

I have tested like this:

                              def OnRemove(self, e):

                                  self.parent.text.Destroy() <-

it works well but it deletes only the last
StaticText in sizer.

                                  self.parent.editor.Destory() <-

the error occured : AttributeError: ‘STC’
object has no attribute ‘Destory’

Destory?! you want Destroy for the editor line - also watch out for

lower/upper case problems when you get a message like this.when I
coded like this:

...

self.parent.Autosizer.Remove(self.parent.Autosizer.GetItem(0))

self.parent.Autosizer.Remove(self.parent.Autosizer.GetItem(1))

                      self.parent.Layout()



              it said : TypeError: wx.Window, wx.Sizer or int

(position) expected for item

What about using the window instead of the index:

E.g.:

self.parent.Autosizer.Remove(self.parent.Autosizer.GetItem(self.parent.text))

Werner
···

On 10/19/2011 09:45 AM, 占쌍울옙占쏙옙 wrote:

AttributeError: 'STC' object has no attribute 'Destory'

Destory?! you want Destroy for the editor line - also watch out for
lower/upper case problems when you get a message like this.when I coded like
this:

Yes, you have used all these so far:

.Destroy() (That's an actual wxPython method)
.Destory() (Your own word...not an English word or wxPython method)
.Distory() (Your own word...not an English word or wxPython method)

When the error tells you that 'STC' object has no attribute 'Destory'
that means you are using a word it does not know. That's a basic
thing you should already know.

So, it's pretty clear you need to drill on Python and programming
basics, and wxPython basics, otherwise all this is going to be moving
from one confusion to (with luck) the next, in an unpleasant way for
you. Have you looked at any good tutorials about Python programming?
Or do you have the wxPython in Action book?

There is also a very good Python Tutor list that you can subscribe to
by Googling that term.

Che

AttributeError: ‘STC’ object has no attribute ‘Destory’

Destory?! you want Destroy for the editor line - also watch out for

lower/upper case problems when you get a message like this.when I coded like

this:

Yes, you have used all these so far:

.Destroy() (That’s an actual wxPython method)

.Destory() (Your own word…not an English word or wxPython method)

.Distory() (Your own word…not an English word or wxPython method)

When the error tells you that ‘STC’ object has no attribute ‘Destory’

that means you are using a word it does not know. That’s a basic

thing you should already know.

So, it’s pretty clear you need to drill on Python and programming

basics, and wxPython basics, otherwise all this is going to be moving

from one confusion to (with luck) the next, in an unpleasant way for

you. Have you looked at any good tutorials about Python programming?

Or do you have the wxPython in Action book?

There is also a very good Python Tutor list that you can subscribe to

by Googling that term.

Che

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

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

···

2011/10/20 C M cmpython@gmail.com

Sorry, I don’t understand what this means :
watch out for
lower/upper case problems when you get a message like this.when I
coded like this:

I tried this code but some error occured => TypeError: wx.Window, wx.Sizer or int (position) expected for item
self.parent.Autosizer.Remove(self.parent.Autosizer.GetItem(self.parent.text))


and below code worked fine. it was my mistake. sorry.
but if the sizer has one row, it teminates whole window.

and also it only deletes the latest row.

    self.parent.text.Destroy()
    self.parent.editor.Destroy()

my references are wxPython in Action and wxPython2.8 Application Development Cookbook and google, etc…



btw, I wonder how can I get the index of stc in sizer when I click the context menu?

···

2011/10/20 최원준 wonjunchoi001@gmail.com

2011/10/20 C M cmpython@gmail.com

AttributeError: ‘STC’ object has no attribute ‘Destory’

Destory?! you want Destroy for the editor line - also watch out for

lower/upper case problems when you get a message like this.when I coded like

this:

Yes, you have used all these so far:

.Destroy() (That’s an actual wxPython method)

.Destory() (Your own word…not an English word or wxPython method)

.Distory() (Your own word…not an English word or wxPython method)

When the error tells you that ‘STC’ object has no attribute ‘Destory’

that means you are using a word it does not know. That’s a basic

thing you should already know.

So, it’s pretty clear you need to drill on Python and programming

basics, and wxPython basics, otherwise all this is going to be moving

from one confusion to (with luck) the next, in an unpleasant way for

you. Have you looked at any good tutorials about Python programming?

Or do you have the wxPython in Action book?

There is also a very good Python Tutor list that you can subscribe to

by Googling that term.

Che

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

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


Sorry, I don’t understand what this means :

watch out for

lower/upper case problems when you get a message like this.when I
coded like this:

I tried this code but some error occured => TypeError: wx.Window, wx.Sizer or int (position) expected for item
self.parent.Autosizer.Remove(self.parent.Autosizer.GetItem(self.parent.text))


and below code worked fine. it was my mistake. sorry.
but if the sizer has one row, it teminates whole window.

and also it only deletes the latest row.

    self.parent.text.Destroy()
    self.parent.editor.Destroy()

my references are wxPython in Action and wxPython2.8 Application Development Cookbook and google, etc…



2011년 10월 20일 오전 11:43, 최원준 wonjunchoi001@gmail.com님의 말:

AttributeError: ‘STC’ object has no attribute ‘Destory’

Destory?! you want Destroy for the editor line - also watch out for

lower/upper case problems when you get a message like this.when I coded like

this:

Yes, you have used all these so far:

.Destroy() (That’s an actual wxPython method)

.Destory() (Your own word…not an English word or wxPython method)

.Distory() (Your own word…not an English word or wxPython method)

When the error tells you that ‘STC’ object has no attribute ‘Destory’

that means you are using a word it does not know. That’s a basic

thing you should already know.

So, it’s pretty clear you need to drill on Python and programming

basics, and wxPython basics, otherwise all this is going to be moving

from one confusion to (with luck) the next, in an unpleasant way for

you. Have you looked at any good tutorials about Python programming?

Or do you have the wxPython in Action book?

There is also a very good Python Tutor list that you can subscribe to

by Googling that term.

Che

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

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


Sorry, I don’t understand what this means :

watch out for

lower/upper case problems when you get a message like this.when I
coded like this:

I tried this code but some error occured => TypeError: wx.Window, wx.Sizer or int (position) expected for item
self.parent.Autosizer.Remove(self.parent.Autosizer.GetItem(self.parent.text))


and below code worked fine. it was my mistake. sorry.
but if the sizer has one row, it teminates whole window.

and also it only deletes the latest row.

    self.parent.text.Destroy()
    self.parent.editor.Destroy()

my references are wxPython in Action and wxPython2.8 Application Development Cookbook and google, etc…



btw, I wonder how can I get the index of stc in sizer when I click the context menu?

I tested this :

class MyPopupMenu(wx.Menu):

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

    mmi = wx.MenuItem(self, wx.NewId(), 'Remove')

    self.AppendItem(mmi)
    self.Bind(wx.EVT_MENU, self.OnRemove, mmi)

def OnRemove(self, e):
    print self.GetParent().GetCurrentPos()

self.GetParent() object is STC. and there was an error : AttributeError: ‘NoneType’ object has no attribute ‘GetCurrentPos’

why I get the position of STC from Autosizer is list.

I will declare pos=; and use len(pos); del pos(0); pos.insert[0,[self.text, self.editor]]
so in order to delete the control, I need the index of STC in Autosizer.

do you think that my idea is right?

···

2011/10/20 최원준 wonjunchoi001@gmail.com

2011/10/20 C M cmpython@gmail.com

sizer.GetItemIndex(theStc)

Also, depending on what you want to do with the index you may be able to do it with just the stc reference instead. For example, you can pass a widget, a child sizer, or an item position to Detach() and it will do the right thing with it.

···

On 10/19/11 7:43 PM, 최원준 wrote:

btw, I wonder how can I get the index of stc in sizer when I click the
context menu?

--
Robin Dunn
Software Craftsman

A menu's parent is not the window, it is the parent menu if the menu is
a submenu.

···

On 10/19/11 7:51 PM, 占쌍울옙占쏙옙 wrote:

I tested this :

class MyPopupMenu(wx.Menu):

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

self.parent = parent

mmi = wx.MenuItem(self, wx.NewId(), 'Remove')
self.AppendItem(mmi)
self.Bind(wx.EVT_MENU, self.OnRemove, mmi)

def OnRemove(self, e):
print self.GetParent().GetCurrentPos()

self.GetParent() object is STC. and there was an error : AttributeError:
'NoneType' object has no attribute 'GetCurrentPos'

--
Robin Dunn
Software Craftsman