input format or editability style question with wx.TextCtrl

HI, guys,

I am using wxpython to develop a GUI for software configuration,
launching and interaction. I want something like a CLI shell window
(like pycrust) embedded inside the GUI to interact with a long-term
running background process. I could give the input via this shell
window and print the output on this window. My current code works very
well. But there is problem of editing style, because wx.TextCtrl is
simply an editable text window. e.g., I could overwrite or remove any
previous output text characters or type new input at any location.
This is not desirable.

How can I make the wx.TextCtrl like a shell window? e.g.,

1) when input new command, the position only starts after prompt.

2) The user cannot change or replace any previous output text result.

I want to force input/output restriction, for interaction purpose.

Is there a way to fix the input prompt? If so, then my problem will be
solved, because the user will have no chance to move the curse, or is
there a way to set certain part of the text (the output and the
prompt) readonly?

Thanks a lot!

Why not just use pycrust or pyshell and be done with it?

···

On Jan 21, 2:24 am, pploo <beilus...@gmail.com> wrote:

HI, guys,

I am using wxpython to develop a GUI for software configuration,
launching and interaction. I want something like a CLI shell window
(like pycrust) embedded inside the GUI to interact with a long-term
running background process. I could give the input via this shell
window and print the output on this window. My current code works very
well. But there is problem of editing style, because wx.TextCtrl is
simply an editable text window. e.g., I could overwrite or remove any
previous output text characters or type new input at any location.
This is not desirable.

How can I make the wx.TextCtrl like a shell window? e.g.,

1) when input new command, the position only starts after prompt.

2) The user cannot change or replace any previous output text result.

I want to force input/output restriction, for interaction purpose.

Is there a way to fix the input prompt? If so, then my problem will be
solved, because the user will have no chance to move the curse, or is
there a way to set certain part of the text (the output and the
prompt) readonly?

Thanks a lot!

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

The easy way would be to have two widgets. One a read-only textctrl for displaying the output, and another just below it for entering commands. Otherwise you'll have to do a lot of stuff like PyShell does and ignore some key events when the caret is not in a zone that it is okay to make changes.

···

On 1/21/11 12:24 AM, pploo wrote:

HI, guys,

I am using wxpython to develop a GUI for software configuration,
launching and interaction. I want something like a CLI shell window
(like pycrust) embedded inside the GUI to interact with a long-term
running background process. I could give the input via this shell
window and print the output on this window. My current code works very
well. But there is problem of editing style, because wx.TextCtrl is
simply an editable text window. e.g., I could overwrite or remove any
previous output text characters or type new input at any location.
This is not desirable.

How can I make the wx.TextCtrl like a shell window? e.g.,

1) when input new command, the position only starts after prompt.

2) The user cannot change or replace any previous output text result.

I want to force input/output restriction, for interaction purpose.

Is there a way to fix the input prompt? If so, then my problem will be
solved, because the user will have no chance to move the curse, or is
there a way to set certain part of the text (the output and the
prompt) readonly?

--
Robin Dunn
Software Craftsman

I am thinking about using pyCrust or pyshell. However, as I have
already had something
working based on wx.TextCtrl, personally, I am really curious how to
extend from it.

Another problem is from what I see with the pyCrust source code, it
uses stdin/stdout, which has
buffering problem with my application, because it is required to make
spontaneous output of background process, so I have used
pexpect to do this. This implies, I have to change the interpreter (if
I remember correctly) part of
pyCrust code.

···

On Jan 21, 6:13 pm, Mike Driscoll <kyoso...@gmail.com> wrote:

On Jan 21, 2:24 am, pploo <beilus...@gmail.com> wrote:

> HI, guys,

> I am using wxpython to develop a GUI for software configuration,
> launching and interaction. I want something like a CLI shell window
> (like pycrust) embedded inside the GUI to interact with a long-term
> running background process. I could give the input via this shell
> window and print the output on this window. My current code works very
> well. But there is problem of editing style, because wx.TextCtrl is
> simply an editable text window. e.g., I could overwrite or remove any
> previous output text characters or type new input at any location.
> This is not desirable.

> How can I make the wx.TextCtrl like a shell window? e.g.,

> 1) when input new command, the position only starts after prompt.

> 2) The user cannot change or replace any previous output text result.

> I want to force input/output restriction, for interaction purpose.

> Is there a way to fix the input prompt? If so, then my problem will be
> solved, because the user will have no chance to move the curse, or is
> there a way to set certain part of the text (the output and the
> prompt) readonly?

> Thanks a lot!

Why not just use pycrust or pyshell and be done with it?

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

thank you Robin, for your suggestions.

I was thinking about a solution with separate widgets.
I make a grid of windows (a StaticTextCtrl or readonly TextCtrl for
output in the upper window; prompt ">>>" on the bottom left area;
invisible-border editable window or entry dialog on the bottom right
area for input).

one problem with above idea is I am not quite sure if I could make an
acceptable sizing appearance of the two prompt and input windows.

actually from what I see with pyCrust code, it seems pyCrust use the
same kind of approach to
separate the output window and EditWindow for input. I am not sure if
I understand the code correctly.
so any insightful comments or explanation are appreciated.

···

On Jan 21, 8:27 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 1/21/11 12:24 AM, pploo wrote:

> HI, guys,

> I am using wxpython to develop a GUI for software configuration,
> launching and interaction. I want something like a CLI shell window
> (like pycrust) embedded inside the GUI to interact with a long-term
> running background process. I could give the input via this shell
> window and print the output on this window. My current code works very
> well. But there is problem of editing style, because wx.TextCtrl is
> simply an editable text window. e.g., I could overwrite or remove any
> previous output text characters or type new input at any location.
> This is not desirable.

> How can I make the wx.TextCtrl like a shell window? e.g.,

> 1) when input new command, the position only starts after prompt.

> 2) The user cannot change or replace any previous output text result.

> I want to force input/output restriction, for interaction purpose.

> Is there a way to fix the input prompt? If so, then my problem will be
> solved, because the user will have no chance to move the curse, or is
> there a way to set certain part of the text (the output and the
> prompt) readonly?

The easy way would be to have two widgets. One a read-only textctrl for
displaying the output, and another just below it for entering commands.
Otherwise you'll have to do a lot of stuff like PyShell does and
ignore some key events when the caret is not in a zone that it is okay
to make changes.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

No, the PyShell widget uses the other approach I mentioned. It tracks the location of the insertion point and blocks changes on all lines except the one where the active prompt is at.

···

On 1/21/11 12:11 PM, pploo wrote:

thank you Robin, for your suggestions.

I was thinking about a solution with separate widgets.
I make a grid of windows (a StaticTextCtrl or readonly TextCtrl for
output in the upper window; prompt ">>>" on the bottom left area;
invisible-border editable window or entry dialog on the bottom right
area for input).

one problem with above idea is I am not quite sure if I could make an
acceptable sizing appearance of the two prompt and input windows.

actually from what I see with pyCrust code, it seems pyCrust use the
same kind of approach to
separate the output window and EditWindow for input. I am not sure if
I understand the code correctly.
so any insightful comments or explanation are appreciated.

--
Robin Dunn
Software Craftsman