how to retain prompt in py.shell after clipboard operations.

I am using wx.py.shell as shell for one of py wxpanel in my
application.

When I am doing clipboard operations cut/copy/clear
after select all I am not able to do any other operation and even prompt is
not shown up till the time updo or paste is done.

I checked this with pyshell where shell module is used.
Pyshell is also behaving the same. I tried to keep self.prompt at
the end of defimition of cut/copy methods of shell script . But no use .

Can any one help me?

Thanks,

Madhubala

···

Madhubala wrote:

I am using wx.py.shell as shell for one of py wxpanel in my application.

When I am doing clipboard operations cut/copy/clear after select all I am not able to do any other operation and even prompt is not shown up till the time updo or paste is done.

I checked this with pyshell where shell module is used. Pyshell is also behaving the same. I tried to keep self.prompt at the end of defimition of cut/copy methods of shell script . But no use .

Can any one help me?

I'm not sure I understand what the problem is. Please try to explain in more detail, including the platform and version you are using and a step-by-step description of how to reproduce the problem.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Thank you for the reply.

The problem can be reproduced in PyShell.

I am using wxpython of version 2.7.1 on windows with python2.5.
In one of our GUI application I am using shell.py module of wx.py package
for having interactive window in wx.panel just like how shell.py used in
PyShell.py.

Following is the code.

class ConsolePanel(wx.Panel):
  def _init_ctrls(self,prnt,size):
    wx.Panel.__init__(self, style=wx.TAB_TRAVERSAL, name='',
parent=prnt, id=wxID_WXCONSOLEPANEL,size =prnt.GetClientSize())
    wx.EVT_SIZE(self, self.OnSize)

  def __init__(self, parent,size):
    self._init_ctrls(parent,size)
    self.shell = Shell (parent=self, introText='',pos =
parent.GetClientAreaOrigin(),
               size= size,
               locals=None,
InterpClass=None,
               startupScript=None,
               execStartupScript=True)

With the above code I am able to create interactive window.

When I right click on the interactive window, popup menu is showing up and
when I want to cut/delete of history/commands by selecting the same in the
popup menu all history is getting deleted/copied to clipboard and the editor
is becoming blank and not allowing doing anything after that. Prompt is not
shown even after pressing return key. Interactive window will become
operational only after paste/undo the above corresponding operations.

This you can see by running PyShell.py of wx.py package. In that interactive
window, in the popupmenu select all and then select selectall , after that
the editor will become blank and no the operatopn is allowed till either you
do a undo or paste.
  This I am comparing with the functionality of pythonwin.exe
interactive window.

···

-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Friday, June 15, 2007 1:48 AM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] how to retain prompt in py.shell after
clipboardoperations.

Madhubala wrote:

I am using wx.py.shell as shell for one of py wxpanel in my application.

When I am doing clipboard operations cut/copy/clear after select all I
am not able to do any other operation and even prompt is not shown up
till the time updo or paste is done.

I checked this with pyshell where shell module is used. Pyshell is also
behaving the same. I tried to keep self.prompt at the end of
defimition of cut/copy methods of shell script . But no use .

Can any one help me?

I'm not sure I understand what the problem is. Please try to explain in
more detail, including the platform and version you are using and a
step-by-step description of how to reproduce the problem.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Thank you for the reply.

The problem can be reproduced in PyShell.

I am using wxpython of version 2.7.1 on windows with python2.5.
In one of our GUI application I am using shell.py module of wx.py package
for having interactive window in wx.panel just like how shell.py used in
PyShell.py.

Following is the code.

class ConsolePanel(wx.Panel):
        def _init_ctrls(self,prnt,size):
                wx.Panel.__init__(self, style=wx.TAB_TRAVERSAL, name='',
parent=prnt, id=wxID_WXCONSOLEPANEL,size =prnt.GetClientSize())
                wx.EVT_SIZE(self, self.OnSize)

        def __init__(self, parent,size):
                self._init_ctrls(parent,size)
                self.shell = Shell (parent=self, introText='',pos =
parent.GetClientAreaOrigin(),
                                                   size= size,
                                                   locals=None,
InterpClass=None,
                                                   startupScript=None,
                                                   execStartupScript=True)

With the above code I am able to create interactive window.

When I right click on the interactive window, popup menu is showing up and
when I want to cut/delete of history/commands by selecting the same in the
popup menu all history is getting deleted/copied to clipboard and the editor
is becoming blank and not allowing doing anything after that. Prompt is not
shown even after pressing return key. Interactive window will become
operational only after paste/undo the above corresponding operations.

This you can see by running PyShell.py of wx.py package. In that interactive
window, in the popupmenu select all and then select selectall , after that
the editor will become blank and no the operatopn is allowed till either you
do a undo or paste.
        This I am comparing with the functionality of pythonwin.exe
interactive window.

I think I've recreated the problem you're talking about here, although
my symptoms don't exactly match yours. I'll rephrase:

cut & paste operations from the context menu act on the entire pyshell
buffer, which can put the input into an invalid state where you can't
type any longer.

Steps to recreate:

1. Open a pyshell and enter a few lines from a session. For example:

10+10

20

1+1

2

2. Select a line of text in the buffer, that includes a prompt. In the
example above, selecting ">>> 10+10" qualifies.

3. Note that you can't type over the selection, and that the paste &
cut commands are disabled in the edit menu.

4. Right click to open the context menu and note that you *can* cut &
paste. If you do so, you will delete the ">>>" prompt in the
backbuffer. Once you've done so, you won't be able to enter input at
the "correct" prompt until you undo the edit. There's some fine line
where you can cut & paste in the backbuffer without affecting the
operation of the shell (after the first non-prompt character in a
line, it seems), but I don't think thats important for fixing it.

2 options for fixing, I'd like feedback on what should be done:

1. I believe that pyshell is using the default context menu for
scintilla. Replacing it with a custom one (as most scintilla based
editors do anyway) would let us redirect the edit menu options through
our own machinery and make the problem go away.

2. Try to make sure that we hook the edit operations to obey the
readonly restrictions on the control.

The second option may be more difficult (I haven't looked at the
code), and I'm not sure if there's any gain. I suppose there might be
an effect with rich input keyboards, or non-keyboard inputs used by
disabled readers, or perhaps on other platforms (this is only tested
under windows, although I'd guess it applies to all platforms).

···

On 6/18/07, Madhubala <madhubalav@infotechsw.com> wrote:

Chris Mellon wrote:

1. I believe that pyshell is using the default context menu for
scintilla. Replacing it with a custom one (as most scintilla based
editors do anyway) would let us redirect the edit menu options through
our own machinery and make the problem go away.

I think this makes the most sense given the current structure of the code. Are you going to work on a patch for this?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Yes, shouldn't take long to have a work-alike of the scintilla menu.

···

On 6/18/07, Robin Dunn <robin@alldunn.com> wrote:

Chris Mellon wrote:

> 1. I believe that pyshell is using the default context menu for
> scintilla. Replacing it with a custom one (as most scintilla based
> editors do anyway) would let us redirect the edit menu options through
> our own machinery and make the problem go away.

I think this makes the most sense given the current structure of the
code. Are you going to work on a patch for this?

Attached is an updated, complete file as well as a patch against
2.8.4. I generated the patch manually, I can't use CVS here (blocked
at firewall) and the SVN test repo you'd set up has gone away.

2 changes from the default scintilla menu:

1. The delete option (like cut, but doesn't place on clipboard) was
renamed clear to be consistent with the PyFrame menu option.

2. I added the Copy Plus and Paste Plus commands as seen in the
PyFrame (copy with prompts and multiline paste & run)

shell.patch (3 KB)

shell.py (54.4 KB)

···

On 6/18/07, Chris Mellon <arkanes@gmail.com> wrote:

On 6/18/07, Robin Dunn <robin@alldunn.com> wrote:
> Chris Mellon wrote:
>
> > 1. I believe that pyshell is using the default context menu for
> > scintilla. Replacing it with a custom one (as most scintilla based
> > editors do anyway) would let us redirect the edit menu options through
> > our own machinery and make the problem go away.
>
> I think this makes the most sense given the current structure of the
> code. Are you going to work on a patch for this?
>

Yes, shouldn't take long to have a work-alike of the scintilla menu.

Chris Mellon wrote:

Attached is an updated, complete file as well as a patch against
2.8.4.

Thanks. I've checked in the change.

I generated the patch manually, I can't use CVS here (blocked
at firewall) and the SVN test repo you'd set up has gone away.

I changed the host name to svn.wxwidgets.org as I prepare to make the transition.

2 changes from the default scintilla menu:

1. The delete option (like cut, but doesn't place on clipboard) was
renamed clear to be consistent with the PyFrame menu option.

2. I added the Copy Plus and Paste Plus commands as seen in the
PyFrame (copy with prompts and multiline paste & run)

Thanks. Looks like you read my mind. :wink:

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

But I think the functionality of context menu and menu of the frame is not
behaving the way generally expected in an editor/interactive window. We can
see this difference when we compare pyshell with interactive window of
pythonwin tool.

After selecting "selectAll" in context menu , the next operation could be
not only copy/copyplus but cut/clear also should be enabled.

···

-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Tuesday, June 19, 2007 1:25 AM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] how to retain prompt in py.shell after
clipboardoperations.

Chris Mellon wrote:

Attached is an updated, complete file as well as a patch against
2.8.4.

Thanks. I've checked in the change.

I generated the patch manually, I can't use CVS here (blocked
at firewall) and the SVN test repo you'd set up has gone away.

I changed the host name to svn.wxwidgets.org as I prepare to make the
transition.

2 changes from the default scintilla menu:

1. The delete option (like cut, but doesn't place on clipboard) was
renamed clear to be consistent with the PyFrame menu option.

2. I added the Copy Plus and Paste Plus commands as seen in the
PyFrame (copy with prompts and multiline paste & run)

Thanks. Looks like you read my mind. :wink:

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

No. The history buffer is immutable, that's the whole point. There's
a separate command (in the edit menu) to clear the history if that's
what you want to do. Note that pyshell is *not* an editor - it is a
shell.

···

On 6/19/07, Madhubala <madhubalav@infotechsw.com> wrote:

But I think the functionality of context menu and menu of the frame is not
behaving the way generally expected in an editor/interactive window. We can
see this difference when we compare pyshell with interactive window of
pythonwin tool.

After selecting "selectAll" in context menu , the next operation could be
not only copy/copyplus but cut/clear also should be enabled.