PyAlaMode (was Re: [wxGlade] Re: Re: wxGlade 0.2.2)

"Greg Brunet" <gbrunet@sempersoft.com> writes:

"Patrick K. O'Brien" <pobrien@orbtech.com>
wrote in message
> SourceForge sometimes has errors on their servers. I would simply
> try it again.
>
> --
> Patrick K. O'Brien
> Orbtech http://www.orbtech.com/web/pobrien

BTW: I meant to ask how things were going on the PyAlaMode project.
Coming from VB, I really miss the auto-complete capabilities of the IDE
when writing code, and you seem to have come up with the closest
solution to that from what I've seen among the various IDE's out there
for Python. I know that you got bombarded with recommendations in the
"PyAlaMode Debugger wants" thread in the wxPython mailing list. I
haven't seen anything about it on your web page, and didn't know if you
had a list of things that you might need help on. I'm only a beginner
at Python, but would be interested in helping out if there's a way to
contribute. Best wishes,

We're getting off-topic for the wxGlade list, so I'm copying the
wxPython-users list. Replies to this message should not include the
wxGlade list, since PyAlaMode has nothing to do with wxGlade.

PyAlaMode exists and works in a basic form. The foundation is pretty
good, and the namespace updating and autocompletion are very solid,
though more limited than the amount of introspection you can get in
PyCrust/PyShell. Also, the WingIDE folks have a screenshot that
appears to indicate that they've got some autocompletion tricks up
their sleeves that I haven't figured out yet.

But PyAlaMode is missing many features that it needs to be a decent
editor. So I keep going back to Emacs. I'd love to have help with
PyAlaMode. Creating an editor that can really compete with Emacs is a
big job and I have a limited amount of free time.

All my wxPython projects have recently moved to the wxPython CVS
repository, so I'll be shutting down the PyCrust project on
SourceForge. Everything is now part of the new "Py" collection. I'm
working on documentation, which is available here:

http://www.orbtech.com/www/PyManual.html

So you could check out wxPython from CVS, or wait for the next
release. Or, since it works pretty well with the current release of
wxPython, you could just check out the py package from here:

http://cvs.wxwindows.org/viewcvs.cgi/wxPython/wxPython/py/?only_with_tag=WX_2_4_BRANCH

I take that back. I just changed all the Py code to use the new
prefix-less "wx" package:

    import wx

So you'd need to install that as well. (BTW, it only took maybe two
hours to convert the entire "py" package to the new syntax.)

Then, just let me know how you would like to contribute. Thanks.

···

--
Patrick K. O'Brien
Orbtech http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------

Hi all,

I am trying to use a listbox. I only want a single selection, not multiple
selections. It is not proving to be as straightforward as I expected.

My understanding of a listbox is that it presents the user with a list of
available choices. The user can use the arrow keys to scroll up and down,
which will cause the current item to be highlighted. The user can then make
a selection either by pressing "enter" on the highlighted item, or by
clicking any item with the mouse.

The problems that I had included the following.

Pressing "enter" does not generate a LISTBOX_SELECTED event. I overcame this
by trapping a KEY_DOWN event.

Simply moving the cursor up and down does generate an event. I "overcame"
this by ignoring the event.

Clicking with a mouse does generate an event, but as I ignore the event (see
previous point), I had to trap the mouse event separately. This half worked,
but as the listbox event has not yet been generated, GetSelection() returns
the previous value. I therefore had to set a variable from the mouse event,
which I test for in the listbox event, which tells it that the event was
generated by a mouse click rather than by a cursor movement, and must
therefore be actioned.

My first question is, I am missing the point here? This seems to be much
harder work than it should be.

My second question relates to the fact that all the above works on Windows
2000, using Python 2.2.2 and wxPython 2.4.0.2u, but if I run exactly the
same code on Linux (RedHat 8, Python 2.2.2, wxPython 2.4.0.2), trapping the
mouse event works as expected, but the keyboard does not. I get no response
from EVT_KEY_DOWN at all. The highlighted cursor does not move in response
to the up and down arrows. Some form of "skeleton" cursor does move up and
down, but it does not seem to serve any purpose.

Any advice will be much appreciated.

Frank Millman

Hi all,

I have got to the point where I am thinking about how to "package" my
application.

Thus far, I have a number of programs which I run stand-alone from the
command line. They are all started in the standard way, as follows.

def run():
    app = MyApp(0) # Create an instance of the application class
    app.MainLoop() # Tell it to start processing events

if __name__ == '__main__':
    run()

MyApp is also standard - they all start something like this -

class MyApp(wxPySimpleApp):

    # wxWindows calls this method to initialize the application
    def OnInit(self):

        # Create an instance of our customized Frame class
        frame = MyFrame(NULL, -1, "Test")

Now I want to hook them all together so that they can be called from a
top-level menu. I use a listbox to present the choices, and when an item is
selected, I import the program file and invoke its run() method.

This works, but I suspect it is not the correct way to do it. It has the
benefit (which I like) that once a program has been invoked, it can be
minimised, which reveals the menu again. The user can then invoke another
program while the first one is still running. This works well. However,
under Windows it takes a long time to close the top level program at the
end, which suggests that something is amiss. Under Linux, I get a string of
"[Debug] Adding duplicate image handler for ..." messages when I invoke a
second program, and when I close the top level program I get a segmentation
fault.

Please could someone advise on the correct method of achieving what I am
trying to do.

Thanks.

Frank Millman

What does the 0 do? I don't see any args in the wxApp docs to the C++
constructor...

···

On Monday 05 May 2003 04:29 am, Frank Millman wrote:

def run():
    app = MyApp(0) # Create an instance of the application class
    app.MainLoop() # Tell it to start processing events

--
Chuck
http://ChuckEsterbrook.com

Frank Millman wrote:

Now I want to hook them all together so that they can be called from a
top-level menu. I use a listbox to present the choices, and when an item is
selected, I import the program file and invoke its run() method.

This works, but I suspect it is not the correct way to do it. It has the
benefit (which I like) that once a program has been invoked, it can be
minimised, which reveals the menu again. The user can then invoke another
program while the first one is still running. This works well. However,
under Windows it takes a long time to close the top level program at the
end, which suggests that something is amiss. Under Linux, I get a string of
"[Debug] Adding duplicate image handler for ..." messages when I invoke a
second program, and when I close the top level program I get a segmentation
fault.

The way you are doing it now you are running all of them in the same process, (IOW, there is only 1 program with mutliple frames this way.) This is okay but if you do that you should not create more than one wxApp object. Instead you should just import the module and create an instance of the main frame object.

OTOH, if you want separate processess for each program then you should use wxExecute or one of the various Python functions to start a new process with the desired command-line.

···

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

Frank Millman wrote:

Hi all,

I am trying to use a listbox. I only want a single selection, not multiple
selections. It is not proving to be as straightforward as I expected.

What is wrong with the wxLB_SINGLE style?

My understanding of a listbox is that it presents the user with a list of
available choices. The user can use the arrow keys to scroll up and down,
which will cause the current item to be highlighted. The user can then make
a selection either by pressing "enter" on the highlighted item, or by
clicking any item with the mouse.

The problems that I had included the following.

Pressing "enter" does not generate a LISTBOX_SELECTED event. I overcame this
by trapping a KEY_DOWN event.

Enter can be stolen by the panel to use for navigation (activating a default button, if any.)

Simply moving the cursor up and down does generate an event. I "overcame"
this by ignoring the event.

Think about it. You are moving the selection so by sending the event it is doing the right thing.

Clicking with a mouse does generate an event, but as I ignore the event (see
previous point), I had to trap the mouse event separately. This half worked,
but as the listbox event has not yet been generated, GetSelection() returns
the previous value. I therefore had to set a variable from the mouse event,
which I test for in the listbox event, which tells it that the event was
generated by a mouse click rather than by a cursor movement, and must
therefore be actioned.

My first question is, I am missing the point here? This seems to be much
harder work than it should be.

Yes. Just use wxLB_SINGLE.

My second question relates to the fact that all the above works on Windows
2000, using Python 2.2.2 and wxPython 2.4.0.2u, but if I run exactly the
same code on Linux (RedHat 8, Python 2.2.2, wxPython 2.4.0.2), trapping the
mouse event works as expected, but the keyboard does not. I get no response
from EVT_KEY_DOWN at all.

You are not guaranteed to get all (any) defined events from native controls. We can not control what they send us.

The highlighted cursor does not move in response
to the up and down arrows. Some form of "skeleton" cursor does move up and
down, but it does not seem to serve any purpose.

It does. GTK sepearates the concepts of selected items and focused items. What you are seeing is the focused item. Just use the spacebar to select it.

···

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

Chuck Esterbrook wrote:

···

On Monday 05 May 2003 04:29 am, Frank Millman wrote:

def run():
   app = MyApp(0) # Create an instance of the application class
   app.MainLoop() # Tell it to start processing events

What does the 0 do? I don't see any args in the wxApp docs to the C++ constructor...

It sets the redirect flag, which determines where stdout/stderr goes to. On Linux the default is to not redirect, but on MSW and Mac it redirects to a window that pops up as needed. wxApp is implemented in Python, for more details you can see it in wx.py.

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

Frank Millman wrote:
> Now I want to hook them all together so that they can be called from a
> top-level menu. I use a listbox to present the choices, and when an item

is

> selected, I import the program file and invoke its run() method.
>

Robin Dunn wrote:

The way you are doing it now you are running all of them in the same
process, (IOW, there is only 1 program with mutliple frames this way.)
This is okay but if you do that you should not create more than one
wxApp object. Instead you should just import the module and create an
instance of the main frame object.

OTOH, if you want separate processess for each program then you should
use wxExecute or one of the various Python functions to start a new
process with the desired command-line.

This is just what I needed to know, Robin. Thanks for giving both
approaches. At the moment, running from one process is what I want, but I
may well change my mind later.

One thing kept me guessing for a while. I can import the module if I know
its name, but if I am reading it from a menu, it is in the form of a string,
which "import" does not accept. After reading up on "__import__" in the
Python manual I eventually figured out how to do it, and it works very
smoothly now.

Thanks for the superb service, as usual.

Frank Millman

Frank Millman wrote:
> Hi all,
>
> I am trying to use a listbox. I only want a single selection, not

multiple

> selections. It is not proving to be as straightforward as I expected.

I have snipped all of Robin's excellent reply, as the answer was actually
quite simple. I did not understand how a listbox works. I could not
understand why moving the cursor up and down generated a LISTBOX_SELECTED
event. Well, that is what a listbox does. Once I understood that, I realised
that a listbox was the wrong tool for my purpose - I needed something that
acts more like a menu.

After a couple of false starts, I settled on using a wxGrid. I have a single
column, no labels, no grid lines, and a simple border, and I make the whole
grid non-editable. It works well and actually looks quite nice.

Thanks for your patience, Robin :slight_smile:

Frank Millman

Frank Millman wrote:

I needed something that
acts more like a menu.

After a couple of false starts, I settled on using a wxGrid. I have a single
column, no labels, no grid lines, and a simple border, and I make the whole
grid non-editable. It works well and actually looks quite nice.

Why not a wxMenu or a wxChoice? (it seems like a wxChoice may be just
what you want.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                        
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Frank Millman wrote:
> I needed something that
> acts more like a menu.
>
> After a couple of false starts, I settled on using a wxGrid. I have a

single

> column, no labels, no grid lines, and a simple border, and I make the

whole

> grid non-editable. It works well and actually looks quite nice.

Chris Barker wrote:

Why not a wxMenu or a wxChoice? (it seems like a wxChoice may be just
what you want.

-Chris

Thanks for the input, Chris. I had already looked at these two, but I wanted
somethng a bit different. A picture is worth a thousand words, so I wanted
to attach a screenshot to show my idea, but I do not know the correct way to
do this (any advice will be appreciated) so I attach some code which runs a
skeleton of my menu system. I am sure I will make many more changes before
it has settled down, but it gives the general idea.

My code is pretty kludgy at this stage, but there is one particularly
bizarre aspect which needs some explanation. I mentioned earlier that wxGrid
worked well. I then found a problem under Linux - if I have overlapping
grids, the borders in the overlapped area disappear, so I get this zig-zag
border around the combination of grids, but lose the visual clue of the
difference between them - not acceptable. So I tried using a wxListCtrl. I
got it working nicely under Linux, but then found it would not work properly
with WIndows - also a problem to do with overlapping. So my horrible
solution is to use a wxGrid if the platform is WIndows and a wxListCtrl if
it is Linux - it seems to work.

I have also noticed that Windows seems to have a problem with trapping a
mouse event with overlapping grids - it gets confused as to which grid
generated the event. Linux does not have this problem. I will do some more
experimenting before I report this as an error.

Any suggestions for improvements, or even an entirely different approach,
will be much appreciated.

Frank Millman

testmenu.py (5.71 KB)

Hi all

This problem may have nothing to do with wxWindows/wxPython, but if anyone
has any information I would be very grateful.

I want to deploy my wxPython application as a multi-user system with Linux
as the server. I want to use low-cost network terminals as workstations, and
I had planned to use vnc. I have done some simple testing using a version of
vnc installed on a Windows 2000 machine, and it seems to work fine.

Now I have noticed that shift-tab is interpreted as tab - definitely not
user-friendly. If I display the keycodes, the shift and the tab are both
detected correctly, but the application still tabs forwards, not backwards.

Does anyone have any ideas on this? Alternatively, are there any other
recommendations for a low-cost terminal.

Many thanks

Frank Millman

Frank Millman wrote:

Frank Millman wrote:

I needed something that
acts more like a menu.

After a couple of false starts, I settled on using a wxGrid. I have a

single

column, no labels, no grid lines, and a simple border, and I make the

whole

grid non-editable. It works well and actually looks quite nice.

Chris Barker wrote:

Why not a wxMenu or a wxChoice? (it seems like a wxChoice may be just
what you want.

-Chris

Thanks for the input, Chris. I had already looked at these two, but I wanted
somethng a bit different. A picture is worth a thousand words, so I wanted
to attach a screenshot to show my idea, but I do not know the correct way to
do this (any advice will be appreciated) so I attach some code which runs a
skeleton of my menu system. I am sure I will make many more changes before
it has settled down, but it gives the general idea.

My code is pretty kludgy at this stage, but there is one particularly
bizarre aspect which needs some explanation. I mentioned earlier that wxGrid
worked well. I then found a problem under Linux - if I have overlapping
grids, the borders in the overlapped area disappear, so I get this zig-zag
border around the combination of grids, but lose the visual clue of the
difference between them - not acceptable. So I tried using a wxListCtrl. I
got it working nicely under Linux, but then found it would not work properly
with WIndows - also a problem to do with overlapping. So my horrible
solution is to use a wxGrid if the platform is WIndows and a wxListCtrl if
it is Linux - it seems to work.

I have also noticed that Windows seems to have a problem with trapping a
mouse event with overlapping grids - it gets confused as to which grid
generated the event. Linux does not have this problem. I will do some more
experimenting before I report this as an error.

Overlapping windows are generally a bad idea. From trying your example, I assume you only have overlapping grids once the user selects from the top level window? In that case, I would look at wxPopupWindow. See the demo for an example.

I've used VNC as a remote administration solution, and the Tab v.
Shift-Tab issue seems to affect more than just wxWindows applications.
If you aren't tied to using Win32 on the desktop, the Linux Terminal
Server Project is well documented with an active user base. Another
alternative would be to run remote X sessions. There are quite a few X
servers for Win32, including Cygwin (http://www.cygwin.org) which is
free.

Hope this helps.

Nathan

···

On Thu, 2003-05-08 at 07:04, Frank Millman wrote:

Hi all

This problem may have nothing to do with wxWindows/wxPython, but if anyone
has any information I would be very grateful.

I want to deploy my wxPython application as a multi-user system with Linux
as the server. I want to use low-cost network terminals as workstations, and
I had planned to use vnc. I have done some simple testing using a version of
vnc installed on a Windows 2000 machine, and it seems to work fine.

Now I have noticed that shift-tab is interpreted as tab - definitely not
user-friendly. If I display the keycodes, the shift and the tab are both
detected correctly, but the application still tabs forwards, not backwards.

Does anyone have any ideas on this? Alternatively, are there any other
recommendations for a low-cost terminal.

Many thanks

Frank Millman

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

--
Nathan R. Yergler
http://yergler.net/~nathan

Does anyone have any ideas on this? Alternatively, are there any other
recommendations for a low-cost terminal.

Why not use low cost Linux boxes? Something like Morphix (live Linux CD) could
be easily hacked into a nice terminal thingy on cheap boxes (without
harddrives). Or even on Windows 2000 boxes of course :slight_smile: Just boot from the
CD.

bye,
Kasper

Frank Millman wrote:

Thanks for the input, Chris. I had already looked at these two, but I wanted
somethng a bit different. A picture is worth a thousand words, so I wanted
to attach a screenshot to show my idea, but I do not know the correct way to
do this (any advice will be appreciated) so I attach some code which runs a
skeleton of my menu system. I am sure I will make many more changes before
it has settled down, but it gives the general idea.

My code is pretty kludgy at this stage, but there is one particularly
bizarre aspect which needs some explanation. I mentioned earlier that wxGrid
worked well. I then found a problem under Linux - if I have overlapping
grids, the borders in the overlapped area disappear, so I get this zig-zag
border around the combination of grids, but lose the visual clue of the
difference between them - not acceptable. So I tried using a wxListCtrl. I
got it working nicely under Linux, but then found it would not work properly
with WIndows - also a problem to do with overlapping. So my horrible
solution is to use a wxGrid if the platform is WIndows and a wxListCtrl if
it is Linux - it seems to work.

Except for wxStaticBox overlapping of sibling controls is not supported.

Perhaps instead of trying to use wxGrid or wxListCtrl in ways they were not intended you should ceate your own custom control that does what you want. You'll have lots less portability issues then, and probably lots less complexity.

···

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

Frank Millman wrote:
>
> So I tried using a wxListCtrl. I
> got it working nicely under Linux, but then found it would not work

properly

> with WIndows - also a problem to do with overlapping. So my horrible
> solution is to use a wxGrid if the platform is WIndows and a wxListCtrl

if

> it is Linux - it seems to work.

Robin Dunn wrote:

Except for wxStaticBox overlapping of sibling controls is not supported.

Perhaps instead of trying to use wxGrid or wxListCtrl in ways they were
not intended you should ceate your own custom control that does what you
want. You'll have lots less portability issues then, and probably lots
less complexity.

Thanks, Robin, and also to David Fox, for your replies. It seems to be
working at the moment, and I have a long list of other tasks to accomplish,
so I will leave it for the time being. But if it does give problems later
on, at least I know I only have myself to blame :slight_smile:

Frank Millman

Frank Millman wrote:
> Does anyone have any ideas on this? Alternatively, are there any other
> recommendations for a low-cost terminal.

Kasper Souren wrote:

Why not use low cost Linux boxes? Something like Morphix (live Linux CD)

could

be easily hacked into a nice terminal thingy on cheap boxes (without
harddrives). Or even on Windows 2000 boxes of course :slight_smile: Just boot from the
CD.

Thanks for this pointer, Kasper - I will follow it up.

Frank Millman

Nathan Yergler wrote:

I've used VNC as a remote administration solution, and the Tab v.
Shift-Tab issue seems to affect more than just wxWindows applications.
If you aren't tied to using Win32 on the desktop, the Linux Terminal
Server Project is well documented with an active user base. Another
alternative would be to run remote X sessions. There are quite a few X
servers for Win32, including Cygwin (http://www.cygwin.org) which is
free.

Hope this helps.

Nathan

Thanks, Nathan, for these ideas. I will follow them up.

Frank Millman