Pycrust enhancements

Hello,

in the thread: "Preferred Editor for wxPython", Robin Dunn wrote:

"""
3. It would be nice to have a key binding (such as Ctrl-Space) that
would popup the auto complete box on demand. That way if it is turned
off on the options menu it can still be used when needed, or if you
accidentally close the autocomp you can open it again without
backspacing and typing the '.' again. When popping it up on demand then
you should probably backtrack to the last '.' and use that for the
context to find the namespace to display, and then use whatever is
between the '.' and the current caret position to preselect an item in
the list (using AutoCompSelect.)

4. It would also be nice to have a key binding (such as
Ctrl-Shift-Space) that will show the CallTip for the item that the caret
is located within.
"""

I have patched "shell.py" to realize these 2 points.
I think, all this should work.

http://mitglied.lycos.de/drpython/shell.zip

CallTips and Autcomplete "manually"
work, even when they are switched off.

Additionally:
wx.Frame(<ctrl-shift-space> ... here it inserts the calltiop
wx.Frame(blablactrl-shift-space> ... here it does not insert the
calltiop

I hope, I encourage other people to improve PyCrust :slight_smile:

···

--
Franz Steinhaeusler

It is a very useful change and works like a charm. Conguratulations...

I want to suggest a small improvement though. There should be a screen clear feature for the shell. It would be very useful when the screen gets clobbered with too much history.

Thanks for the change again.

Regards,

Murat Ozsoyler

Franz � wrote:

···

Hello,

in the thread: "Preferred Editor for wxPython", Robin Dunn wrote:

"""
3. It would be nice to have a key binding (such as Ctrl-Space) that would popup the auto complete box on demand. That way if it is turned off on the options menu it can still be used when needed, or if you accidentally close the autocomp you can open it again without backspacing and typing the '.' again. When popping it up on demand then
you should probably backtrack to the last '.' and use that for the context to find the namespace to display, and then use whatever is between the '.' and the current caret position to preselect an item in the list (using AutoCompSelect.)

4. It would also be nice to have a key binding (such as Ctrl-Shift-Space) that will show the CallTip for the item that the caret
is located within.
"""

I have patched "shell.py" to realize these 2 points.
I think, all this should work.

http://mitglied.lycos.de/drpython/shell.zip

CallTips and Autcomplete "manually"
work, even when they are switched off.

Additionally:
wx.Frame(<ctrl-shift-space> ... here it inserts the calltiop
wx.Frame(blablactrl-shift-space> ... here it does not insert the
calltiop

I hope, I encourage other people to improve PyCrust :slight_smile:

--
Franz Steinhaeusler

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

It is a very useful change and works like a charm. Conguratulations...

Hello Murat,

thank you very much!

I want to suggest a small improvement though. There should be a screen
clear feature for the shell. It would be very useful when the screen
gets clobbered with too much history.

Yes, good Idea, would you like to contribute? :wink:

Thanks for the change again.

Regards,

Murat Ozsoyler

[...]

because of the few thing, one find about PyCrust (also in google), I
suspect, this great program is a little underrated.

I could imagine an option dialog, to set all the default values off or
on:
- wrap lines, show magic attributes, ... (or save them automatically on
program exit, as mentioned below).

- Menu Shortcuts for all options (example wrap lines ctrl-w or so).

- help is only available, if you type shell.help(), which is not
exactly intuitive.
I would prefer in Help => key bindings and this should call help.

- startup script (every time, I start Pycrust, the first command is
import wx)

- get command history shown in a listbox and select one item.

- delete command history

- open/save command history file.

(because of completeness, Robin Dunn wrote also):

"""
Almost perfect. :wink: If anybody has some time to dig into the Py code I
would love to have a patch for the following additions:

1. Save some things about the Py apps in a wx.Config when shutting down
and then restore them on startup. Things like the position and size of
the frame, sash positions in PyCrust, the status of the items on the
Options menu, etc. This probably only makes sense to be done
automatically from the Apps, and not when embedding, so maybe the
varioius Frame classes can take additional parameters (config object and
the path to read entries from) that default to None. Be careful when
saving the size and position of the frame, if it is iconized then the
values will probably be garbage, so you will probably want to catch the
iconize event and remember the size/position then in case the user
closes the app while it is iconized.

2. When the Crust window is resized it would be nice if the size of the
bottom remained constant and the top is the one that stretched. The
main part of the demo shows one way to do this, although it uses a fixed
size and can be a little jumpy at times.
"""

- option: save settings (from the options) automatically or not.

- save window layout (I think, this is better than always automatically
save the last layout;
it saves it, if you don't want that; or option: don't save (and here you
can manually save it), save automatically.

- get default window layout

I would prefer write this settings in a config file rather than to the
registry.
(I hate entries in the registry and to control/correct/edit, it is much
more better to have an config
file, preferrable in the directory of pycrust itself; my opinion)

...

not to exxagerate :slight_smile:

I would also recommend to try out DrPython. It has also Code
completition/ Call Tips in the prompt
and some additional interesting features.

regards

···

On Tue, 12 Jul 2005 22:40:19 +0300, MURADI OZSOYLER <murat.ozsoyler@isnet.net.tr> wrote:
--
Franz Steinhaeusler

I want to suggest a small improvement though. There should be a screen
clear feature for the shell. It would be very useful when the screen
gets clobbered with too much history.

I have updated shell.py again with Clear Screen Alt-C:

http://mitglied.lycos.de/drpython/shell.zip

for showing the new keybindings call:

···

On Tue, 12 Jul 2005 22:40:19 +0300, MURADI OZSOYLER <murat.ozsoyler@isnet.net.tr> wrote:

shell.help()

--
Franz Steinhaeusler

New update:

Some remarks:
I saved the settings in homedir\.pycrust\pycrustsettings.dat as simple
numeric file.

Saved are: autocomplete settings, calltips and wrap lines
Position and Size of Pycrust frame
the two sash positions (shell and notebook, Namespace (treecontrol and
filling)
To enable save and restore the values, there must be (any) additional
commandline parameter like -s for example.

mag keine registry einträge
ini file noch besser
  (schöner und übersichtlicher, editieren auch)
The reason for saving them manually:
  I find it better than always save them automatic at program exit.
  No bad settings are saved unmeant.
  Setting preferences, one changes not so often normally

To get the default layout again: choose clear settings file and restart
pycrust.

Alt-C clears the shell screen.

Ctrl-Space opens Autocomplete window manually.
  example wx.Fra<ctrl-space> preselects wx.Frame (because this is found
at nearest); if
    something is choosed, also the 'Fra' is replaces

Ctrl-Shift-Space opens Autocomplete window manually. if the cursor is on
'(', it inserts
  the call tips on the cursor positions.

Calltips and Autocomplete work, even when they are switched off in the
options menu.

The upper sashwindow (the shell) will grow/shrink , as Robin suggested.
  
Autocomplete window stayed open, when you switch to another Application.
I added wx.EVT_ACTIVATE_APP, and when pycrust loses the focus,
autocomplete window is removed.
Workaround for PyDeadObjectError, if Pycrust is closed (except
wx.PyDeadObjectError:).

There was also a little bug in the filling sash window. SetSashPosition
only works with
wx.CallAfter.

Two new menu entries: Save Settings and delete Settings file.

Download at:
http://mitglied.lycos.de/drpython/pycrustpatch071905.zip
  
I have added my name in the code, to make better visible, what I have
changed.
This can be removed again afterwards.
  
I'm sure, there could be a better program style, and if you find any
bugs
  related to these changes, please don't hesitate to report them.
  
I hope, someone will find the changes useful :wink:

···

On Wed, 13 Jul 2005 12:43:35 +0200, Franz Steinhäusler <franz.steinhaeusler@gmx.at> wrote:

On Tue, 12 Jul 2005 22:40:19 +0300, MURADI OZSOYLER ><murat.ozsoyler@isnet.net.tr> wrote:

--
Franz Steinhaeusler

Hello Adi,

ich bin auf der Leitung gestanden.

I see.
If the app is started from pycrust (with the
App), only then the settings are loaded.

Here one can set a variable (for example frame),
which sets embedded False.

Then in the frame, if embedded is True,
the four menu identifiers are disabled.
Revert to default, AutoSave Setting, Save Settings, Edit Startup file.

in CrustFrame, also
    def OnClose(self, event):
        """Event handler for closing."""
==> if not frame.embedded:
           self.SaveSettings()

otherwise there is a traceback:
  File "C:\Python24\lib\site-packages\wx-2.661-msw-ansi\wx\py\frame.py",
line 449

Settings
AttributeError: 'CrustFrame' object has no attribute 'autoSaveSettings'

448: def SaveSettings(self):
        if self.autoSaveSettings:
            self._saveSettings()

Alt-C is now used three times.
Clear
Clear Screen
and in Shell for Copy
        # Copy to the clipboard, including prefixed prompts.
        elif altDown and not controlDown \
            and key in (ord('C'), ord('c'), wx.WXK_INSERT):
            self.CopyWithPromptsPrefixed()

···

--
Franz Steinhaeusler

Hi Franz, hi all !
Sorry for the attachment (only 11K)

I have been thinking about improvements on PyShell for a long time. My emails
with Robin and/or Patrick O' Brian are in the archives.

Please find attached my version of shell.py. It contains 3 or 4
"improvements" I got to like a lot. I would be very happy if they would be
incorporated into the official version:
a) Drag and drop of files pastes the files pathname (It uses r' ... ' syntax
to allow the backlash in windows)

b) Ctrl-F allows to search for text (todo: search parameters, like "whole
word", "regexp") backwards
c) Ctrl-G search again
d) This one is fancy !! If you select many lines and press CTRL-H it "hides"
the whole section into one (the first) lines (folding) and puts a marker on
the side. If the current line already has a marker it "unhides"
(I learned a lot about Scintilla/STC while playing with this :wink:

e) F12: (this one is special !) It toggles the cursor into "red/
non-blinking"-mode and allows to edit all text in the shell window. I use
this a lot to clean up error messages that resulted from typos (or other
junk-lines that would be just hurting my eyes). The F12-edit-mode allows to
have a clean sequence of lines when you want to show your session to someone
else - also it allows to put comment-lines (maybe just '*********'-rows) into
your session to clearly separate session-"chapters". (todo: fix problem when
editing last/current line)

f) todo: did someone notice that the "save" menu-command doesn't work ? I have
my own command (saveSession() ) for this - but didn't put it into the menu
yet.

I hope to get some comments on this ...

Thanks,
Sebastian Haase
UCSF

shell.py.gz (10.5 KB)

···

On Tuesday 12 July 2005 04:08, Franz Steinhäusler wrote:

Hello,

in the thread: "Preferred Editor for wxPython", Robin Dunn wrote:

"""
3. It would be nice to have a key binding (such as Ctrl-Space) that
would popup the auto complete box on demand. That way if it is turned
off on the options menu it can still be used when needed, or if you
accidentally close the autocomp you can open it again without
backspacing and typing the '.' again. When popping it up on demand then
you should probably backtrack to the last '.' and use that for the
context to find the namespace to display, and then use whatever is
between the '.' and the current caret position to preselect an item in
the list (using AutoCompSelect.)

4. It would also be nice to have a key binding (such as
Ctrl-Shift-Space) that will show the CallTip for the item that the caret
is located within.
"""

I have patched "shell.py" to realize these 2 points.
I think, all this should work.

http://mitglied.lycos.de/drpython/shell.zip

CallTips and Autcomplete "manually"
work, even when they are switched off.

Additionally:
wx.Frame(<ctrl-shift-space> ... here it inserts the calltiop
wx.Frame(blablactrl-shift-space> ... here it does not insert the
calltiop

I hope, I encourage other people to improve PyCrust :slight_smile:

--
Franz Steinhaeusler

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

Hello Adi,

did you take as base the last patch, I delivered.
http://mitglied.lycos.de/drpython/pycrustpatch072105-2.zip

I have problems (some last changes are not taken over).

···

On Tue, 26 Jul 2005 09:26:42 +0200, "Adi J. Sieker" <ml@adsworth.info> wrote:

--
Franz Steinhaeusler

ups, sorry I'll be more careful next time.

adi

···

Am Tue, 26 Jul 2005 11:39:46 +0200 schrieb Franz Steinhäusler <franz.steinhaeusler@gmx.at>:

I try to merge it again.

I think, you have used your
www.adsworth.info/files/wxpython/pycrust-2005-07-21.zip
as Base.

Franz Steinhäusler wrote:

last changes:
- Calltip inserts the suggested text only, if the current cursor
position is on '(', and the '(' is at the end of line.

I've also found it useful to be able to put the cursor on the left paren and, with a context menu (or keyboard shortcut) choice, ask for the help text again.

Don Dwiggins
Advanced Publishing Technology

Bug,
I just noticed that wx2.6 wants
   self.obj.AppendText(txt)
instead of
   n= len(txt)
   self.obj.AppendText(n, txt)

This is about the 4th last line in class FileDropTarget(wx.FileDropTarget)
(my file drag-and-drop patch)

Please fix this before people complain ... :wink:
Thanks,
Sebastian

···

On Tuesday 26 July 2005 10:33, Sebastian Haase wrote:

On Tuesday 26 July 2005 00:32, Adi J. Sieker wrote:
> Hi Sebastian,
>
> Am Mon, 25 Jul 2005 21:07:07 +0200 schrieb Sebastian Haase > > > > <haase@msg.ucsf.edu>:
> > Hi Franz, hi all !
> > Sorry for the attachment (only 11K)
> >
> > I have been thinking about improvements on PyShell for a long time. My
> > emails
> > with Robin and/or Patrick O' Brian are in the archives.
>
> I'll see wether I can find the mails and I'll have a look for interesting
> additions. :slight_smile:

I was thinking of the email of
2003-11-20 10:02 ("PyCrust - mail to wxPython list ?")
Patrick K. O'Brien <pobrien@orbtech.com> said he was to busy to do any
PyCrust stuff at the time (I suppose he has moved on and is still busy :wink:

> > Please find attached my version of shell.py. It contains 3 or 4
> > "improvements" I got to like a lot. I would be very happy if they would
> > be
> > incorporated into the official version:
>
> [snipped additions a-e]
>
> I'll integrate your changes into what I have here.
>
> > f) todo: did someone notice that the "save" menu-command doesn't work ?
> > I have
> > my own command (saveSession() ) for this - but didn't put it into the
> > menu
> > yet.
>
> Is the saveSession() in the your shell.py ?
> If not please let me have it, I'll have File/Save call it

Here it comes... (It's somewhat specific to my personal needs, a menu
-triggered version could be simpler... but I still like the idea of a
default filename)
<code>
try:
  _saveSessionDefaultPrefix
except:
  _saveSessionDefaultPrefix = "_pySession-"
def saveSession(fn=None):
  """saves all text from PyShell into a file w/ file name 'fn'
  if fn is None it calls smart 'FN()' for you
  """

  import sys
  if hasattr(sys, "app"): # PyShell, PyCrust, ...
    shell = sys.app.frame.shell
  elif hasattr(sys, "shell"): # embedded
    import __main__
    shell = __main__.shell
    #shell = sys.shell
  else:
    raise "sorry, can't find shell"

  if fn is None:
    import time
    # global _saveSessionDefaultPrefix
    fn = _saveSessionDefaultPrefix + time.strftime("%Y%m%d-%H%M.py")
    fn = wx.FileSelector("Please select file",
               "",fn,"","")

  f = open(fn, "w")
  f.write(shell.GetText())
  f.close()
  print "# '%s' saved." %( fn, )
</code>

> > I hope to get some comments on this ...

Anybody who likes the Ctrl-H folding ?? I was thinking of going into the
direction of a Mathematica-like notbock style with this - todo: would be to
allow nested folds. This is a part of the above cited email (from 2003!)
"""
3) My last point is an Idea :
   How hard would it be to use scintilla's folding-feature in the
interactive PyCrust windows ?
  I read the scintilla documentation for that twice - but did not really
understand it enough.
  We I print e.g. the value of an array variable I sometimes goes on for
hundreds on lines.
  So I was thinking of Mathematica's folding - I has multiple levels: each
input and output build the lowest level "cell" (so the '>>>' prompt should
be just the right separator). Then I thought one could define "special
comments" like " ##== some text" to allow a few higher levels !!

On Scintilla and SciTE To Do I just read "SciTE To Do:
<snip> Retain folding state when changing buffers."
Does this mean we have to wait ?? I think it should still work:
Scintilla Future Features ->"<snip> It has been pointed out
that folding does not stay when you change buffers in SciTE. This is
because folding is stored in the view rather than the document to allow
multiple views of one document to have different folding. "
"""
Apparently after digesting this I realized that what I was looking for is
STC's "hiding"-feature not folding - or: at least I could get "hiding to
work" :wink:

My big wish for the idea above would be to have bigger fonts for "chapter
headings" - but I think Scintilla just doesn't allow that - or ?

Thanks for picking up on PyShell !
Sebastian Haase

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