Setting a value

Using Boa constructor and I have a routing called by a button being
pressed. I can set a variable in there, even do stuff proving that
variable is set right.

However I have not been able to make that variable global as what it
sets is used by a routing called by another button click. Can anyone
help me with what the trick to that is.

···

--
Mike Wagman <mwagman@charter.net>

Mike Wagman wrote:

Using Boa constructor and I have a routing called by a button being
pressed. I can set a variable in there, even do stuff proving that
variable is set right.

However I have not been able to make that variable global as what it
sets is used by a routing called by another button click. Can anyone
help me with what the trick to that is.

Without further clarification or some sample code it is hard to figure out what you are trying to do but if the variable is local to the routine then it will indeed not be available in other routines. What you probably want is to save it in the self instance. For example:

  def OnButton(self, event):
    self.somevariable = somevalue

···

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

Before i go about reinventing the wheel here (especially because coding
takes me so damn long) i was wondering if anyone on the list has already
done any code for creating and eye-dropper / pixel colour sampler for
existing wxPython apps? personnally i'm using wxPython and PIL but if
anyones got anything along the same lines i'd be pretty happy to see it
rather than start completely from scratch.

Long term what i actually want to do is to be able to sample the colours as
i move around the image and have the RGB vaules read out to a table and
alternatively a graph of the R,G,B values.

Cheers

Dave

I figured out what I was doing incorrectly, thanks to all for the help.

···

On Tue, 2003-05-13 at 00:24, Robin Dunn wrote:

Mike Wagman wrote:
> Using Boa constructor and I have a routing called by a button being
> pressed. I can set a variable in there, even do stuff proving that
> variable is set right.
>
> However I have not been able to make that variable global as what it
> sets is used by a routing called by another button click. Can anyone
> help me with what the trick to that is.

Without further clarification or some sample code it is hard to figure
out what you are trying to do but if the variable is local to the
routine then it will indeed not be available in other routines. What
you probably want is to save it in the self instance. For example:

  def OnButton(self, event):
    self.somevariable = somevalue

--
Mike Wagman <mwagman@charter.net>

David McDonnell wrote:

Before i go about reinventing the wheel here (especially because coding
takes me so damn long) i was wondering if anyone on the list has already
done any code for creating and eye-dropper / pixel colour sampler for
existing wxPython apps? personnally i'm using wxPython and PIL but if
anyones got anything along the same lines i'd be pretty happy to see it
rather than start completely from scratch.

Long term what i actually want to do is to be able to sample the colours as
i move around the image and have the RGB vaules read out to a table and
alternatively a graph of the R,G,B values.

Well, I wrote some code that does some of this, but now I cna't find it.
Frankly, it won't be hard to reproduce anyway. What you need to do is
bind the left mouse button click to a function that looks something like
this (untested):

EVT_LEFT_DOWN(self, self.GetColor)

def GetColor(self,event): # self should be the wxWindow that you want
the color from
                          # This is assuming that you've already drawn
you image to the window
    x,y = event.GetX(), event.GetY()
    dc = wxClientDC(self) # create a DC of the Window
    color = dc.GetPixel(x,y)
    (r,g,b) = color.Red, color.Green(), color.Blue()

    # Do something with the values.

Note that you will only get the color resolution that the screen
supports. If it';s less that 24bpp, then that's all you get. If that
might be the case, and you also have the image stored in a PIL image,
then you could use the coordinates to get the color from that.

-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

David McDonnell wrote:

Before i go about reinventing the wheel here (especially because coding
takes me so damn long) i was wondering if anyone on the list has already
done any code for creating and eye-dropper / pixel colour sampler for
existing wxPython apps? personnally i'm using wxPython and PIL but if
anyones got anything along the same lines i'd be pretty happy to see it
rather than start completely from scratch.

I have been using some code out of this script to sample colours out of
images.

http://matt.kimball.net/image_view.html

Sean

···

--
+---------------------------------------------------------------+

All spelling errors are intentional and are there to show new |
and improved ways of spelling old words. |

+---------------------------------------------------------------+

thats the ticket... looks pretty much exactly like the type of things i want
to do.

Cheers for that

Dave

···

I have been using some code out of this script to sample colours out of
images.

http://matt.kimball.net/image_view.html

Sean

Hi all,

Up to now I have been using wxDEFAULT_FRAME_STYLE for my frames. Then I
found the following problem under Windows.

I start with Frame A, which is the only frame visible. Frame A invokes Frame
B, which is displayed over Frame A. If it is smaller than Frame A you can
still see the outline of Frame A, but that is ok. Frame B invokes Dialog C,
using ShowModal(). Dialog C appears correctly, but behind it Frame A
reappears on top of Frame B. You cannot access it, as Dialog C has focus and
is modal, but it looks messy and the user loses context of where the dialog
was called from. When Dialog C is closed, Frame B reappears on top of Frame
A, as before. For some reason, this problem does not occur if I invoke a
MessageDialog.

I found a solution, or so I thought. I added the style
wxFRAME_FLOAT_ON_PARENT to my frame, and the problem disappeared. Then I
found that this causes a problem under Linux. Adding this style to the frame
causes the Minimize and Maximize buttons to disappear. I have tried all the
combinations I can think of, and I cannot find one that works.

For now, my solution is as follows.

style=wxDEFAULT_FRAME_STYLE
if sys.platform == 'win32':
    style |= wxFRAME_FLOAT_ON_PARENT

I am sure you will agree this is very ugly. Can anyone suggest a more
correct solution?

Platforms are both Python 2.2.2 and wxPython 2.4.0.2.

Thanks in advance.

Frank Millman

Hi all,

I recently posted a problem to do with using vnc as a thin client connected
to a linux server. The problem was that shift-tab is interpreted the same as
tab. The advice I got was to run a remote X session from the client
workstation instead of vnc.

I have been experimenting with a bootable-cd distribution called NetStation
(or ThinStation), and it shows the same problem. After some more
experimenting, I can report the following facts.

If I use vnc to run Calc (the OpenOffice spreadsheet), tab and shift-tab
work correctly. This seems to suggest that vnc is not the problem.

If I run wxKeyEvents from the demo, using the main server, vnc, and
Netstation, I get the following results. In all cases, the tab key and the
shift key are detected correctly. However, the main server returns a
RawKeyCode of 65289 for tab and 65056 for shift-tab. Both vnc and NetStation
return a RawKeyCode of 65289 for both tab and shift-tab.

I noticed another thing, which may be a sidetrack, but is worth reporting. I
tried running wxKeyEvents from the prompt instead of from inside the demo.
If I run it from the server, it works normally. If I run it from both vnc
and Netstation, it only reports KeyDown events, not KeyUp events.

Another possible clue - when loading NetStation, among many other messages,
the following message appears - "Couldn't load XKB keymap, falling back to
pre-XKB keymap."

I have no idea if the problem lies with wxWindows, remote X, or the client
software, but I hope that this information helps someone more knowledgeable
than me to determine the cause of the problem, and hopefully provide a
solution.

Any suggestions will be much appreciated.

Frank Millman

Frank Millman wrote:

I start with Frame A, which is the only frame visible. Frame A invokes Frame
B, which is displayed over Frame A. If it is smaller than Frame A you can
still see the outline of Frame A, but that is ok. Frame B invokes Dialog C,
using ShowModal(). Dialog C appears correctly, but behind it Frame A
reappears on top of Frame B. You cannot access it, as Dialog C has focus and
is modal, but it looks messy and the user loses context of where the dialog
was called from. When Dialog C is closed, Frame B reappears on top of Frame
A, as before.

Does it still do it if Frame B is not a child of Frame A (using None for the parent of both)?

For some reason, this problem does not occur if I invoke a
MessageDialog.

Because it isn't really a wxDialog, but a win32 API function.

···

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

Frank Millman wrote:
>
> I start with Frame A, which is the only frame visible. Frame A invokes

Frame

> B, which is displayed over Frame A. If it is smaller than Frame A you

can

> still see the outline of Frame A, but that is ok. Frame B invokes Dialog

C,

> using ShowModal(). Dialog C appears correctly, but behind it Frame A
> reappears on top of Frame B. You cannot access it, as Dialog C has focus

and

> is modal, but it looks messy and the user loses context of where the

dialog

> was called from. When Dialog C is closed, Frame B reappears on top of

Frame

> A, as before.

Robin Dunn wrote:

Does it still do it if Frame B is not a child of Frame A (using None for
the parent of both)?

Yes it does. In fact that was how I started off. When I discovered
wxFLOAT_ON_FRAME, I had to change it to a child frame otherwise it would
not work at all.

Just to confirm that we are talking about the same problem, I am happy to
use F_O_F. The problem is that it removes the min/max buttons on Linux.
Obviously if there is a solution that does not require F_O_F, that may solve
both problems at the same time.

Thanks

Frank Millman

Frank Millman wrote:

Robin Dunn wrote:

Does it still do it if Frame B is not a child of Frame A (using None for
the parent of both)?

Yes it does. In fact that was how I started off. When I discovered
wxFLOAT_ON_FRAME, I had to change it to a child frame otherwise it would
not work at all.

Just to confirm that we are talking about the same problem, I am happy to
use F_O_F. The problem is that it removes the min/max buttons on Linux.
Obviously if there is a solution that does not require F_O_F, that may solve
both problems at the same time.

If you make a small sample I'll take a look at it.

···

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

Frank Millman wrote:
> Robin Dunn wrote:
>
>>Does it still do it if Frame B is not a child of Frame A (using None for
>>the parent of both)?
>>
>
>
> Yes it does. In fact that was how I started off. When I discovered
> wxFLOAT_ON_FRAME, I had to change it to a child frame otherwise it

would

> not work at all.
>
> Just to confirm that we are talking about the same problem, I am happy

to

> use F_O_F. The problem is that it removes the min/max buttons on Linux.
> Obviously if there is a solution that does not require F_O_F, that may

solve

> both problems at the same time.
>

If you make a small sample I'll take a look at it.

Thanks, Robin, but I found the problem - once again proving the benefit of
reducing it to a small sample.

To recap, Frame A invokes Frame B, which invokes Dialog C. I did not supply
a parent for the dialog, so it seems that MSW thinks it is linked to Frame
A. Once I supplied Frame B as the parent for the dialog, it worked
correctly. Many thanks.

BTW, do you know if anyone is looking into my problem with shift-tab from a
remote workstation, or am I on my own with this one? If the latter, I must
start doing some serious investigation, as it has a major effect on my plans
for deployment of my application.

Thanks for the great service as always.

Frank Millman

Frank Millman wrote:

Thanks, Robin, but I found the problem - once again proving the benefit of
reducing it to a small sample.

:slight_smile:

To recap, Frame A invokes Frame B, which invokes Dialog C. I did not supply
a parent for the dialog, so it seems that MSW thinks it is linked to Frame
A. Once I supplied Frame B as the parent for the dialog, it worked
correctly. Many thanks.

Yep, I think that (in some situations at least) wxDialogs need to have a parent on MSW so if no parent is given to modal dialogs then wxGetApp()->GetTopWindow() is used.

BTW, do you know if anyone is looking into my problem with shift-tab from a
remote workstation, or am I on my own with this one? If the latter, I must
start doing some serious investigation, as it has a major effect on my plans
for deployment of my application.

Not that I know of. Didn't you say that it wasn't specific to wxWindows apps, or am I misremembering?

···

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

Frank Millman wrote:
> BTW, do you know if anyone is looking into my problem with shift-tab

from a

> remote workstation, or am I on my own with this one? If the latter, I

must

> start doing some serious investigation, as it has a major effect on my

plans

> for deployment of my application.

Robin Dunn wrote:

Not that I know of. Didn't you say that it wasn't specific to wxWindows
apps, or am I misremembering?

Someone else (can't remember your name, sorry) replied to my original post
and said that they had noticed it in other applications, but gave no
details.

The only other app I know to test it with is Calc (the OpenOffice
spreadsheet) and shift-tab does work correctly there.

I originally thought that it was vnc specific, but I have now found the same
problem using a remote X thin client called ThinStation, which runs a
version of Linux from a bootable-cd.

The following information may be relevant, or may be a sidetrack.

1. If I run wxKeyEvents from the demo using the remote workstation, and I
press shift-tab, the shift key and the tab key are detected correctly, but
the RawKeyCode returned is the same as for tab. If I run it from the server,
the RawKeyCode for shift-tab is different from tab.

2. If I run wxKeyEvents from the prompt instead of from the demo, key down
events are detected but key up events are not.

3. When booting up ThinStation, among all the other messages, the following
message appears - "Couldn't load XKB keymap, falling back to pre-XKB
keymap."

I have recently upgraded my server from Redhat 8 to Redhat 9, but the
problem is still there.

Let me know if there are any other tests you would like me to try.

Many thanks

Frank Millman