[wxPython] wxPython-2_1_14-20000227, Frame Problem and statusbar problem

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] wxPython-2_1_14-20000227, Frame Problem and statusbar problem

Gordon Williams
Hi,

After trying out the new version of wxPython(2.2.14) I found that there
were a couple of problems with my code now.

1) At the bottom of the Frame there is now a bar across the bottom with a
grip? on the right hand side (45 deg lines) and something else on the left
hand side (vertical lines).  This covers over some buttons on the bottom of
the panel inside.

2) I had a status bar in a wxPanel, but this no longer appears.


Regards,

Gordon Williams

Here is the section of code (sorry it is kind of long):

'''
Canvas.py
Provides ploting for analog and digital results.


'''


from wxPython.wx import *
import time
import traceback




#---------------------------------------------------------------------------

class canvas(wxScrolledWindow):
    #Pen defintition
    penRed = wxPen(wxNamedColour('RED'),.1)
    penBlue= wxPen(wxNamedColour('BLUE'),.1)
    penGrey = wxPen(wxLIGHT_GREY,.1)
    penBlack= wxPen(wxBLACK,.1)
   
    def __init__(self,parent):
        wxScrolledWindow.__init__(self, parent, -1, style= wxSUNKEN_BORDER)
        self.SetBackgroundColour(wxNamedColor("WHITE"))
        self.xscale=1
        self.yscale=1
       
        # set curser as cross-hairs
        self.SetCursor(wxCROSS_CURSOR)
       
        # screen clicks with mouse
        EVT_LEFT_DOWN(self, self.OnMouse)
       
        # Set up scroll bar
        self.AdjustScrollbar(500) # pretrig delay + time
       
                   
    def AdjustScrollbar(self, winsize):
        posx= self.GetScrollPos(wxHORIZONTAL)
        rangex= self.GetScrollRange(wxHORIZONTAL)
        if rangex==0: #prevent divide by zero first time through during
setup
            rangex=1
        print 'Size, pos, range, calc',winsize, posx, rangex,
posx*(winsize+20)/(20*rangex)        
        self.SetScrollbars(20, 0, (winsize+20)/20, 0,
posx*(winsize+20)/(20*rangex)+.5, FALSE)
        #self.Refresh()

    def OnMouse(self, event):
        print "hi", event.GetX(), event.GetY()
        print "hi1", self.CalcUnscrolledPosition(event.GetX(),
event.GetY())
        posx= self.GetScrollPos(wxHORIZONTAL)
        rangex= self.GetScrollRange(wxHORIZONTAL)
        print "position, range",posx,rangex

class sideScale(wxPanel):
    def __init__(self,parent):  
        wxPanel.__init__(self,parent, -1, wxPoint(-1,-1),
wxSize(50,-1),style=wxSIMPLE_BORDER)
   
    def MakeLabels(self):
        # Analog
        wxStaticText(self,-1,"CH", (27,108), style=wxALIGN_LEFT)
        A=wxStaticText(self,-1,"\"A\"", (27,123), style=wxALIGN_LEFT)
        A.SetForegroundColour(wxRED)
        B=wxStaticText(self,-1,"\"B\"", (27,138), style=wxALIGN_LEFT)
        B.SetForegroundColour(wxBLUE)

        self.MaxVA=wxStaticText(self,-1,"", (2,0), style=wxALIGN_LEFT)
        self.MaxVA.SetForegroundColour(wxRED)
        self.MaxVB=wxStaticText(self,-1,"", (2,15), style=wxALIGN_LEFT)
        self.MaxVB.SetForegroundColour(wxBLUE)
        self.Zero=wxStaticText(self,-1,"0", (2,132), style=wxALIGN_LEFT)
        self.Zero.SetForegroundColour(wxBLACK)
        self.MinVA=wxStaticText(self,-1,"", (2,250), style=wxALIGN_LEFT)
        self.MinVA.SetForegroundColour(wxRED)
        self.MinVB=wxStaticText(self,-1,"", (2,265), style=wxALIGN_LEFT)
        self.MinVB.SetForegroundColour(wxBLUE)
       

    def SetVolts(self, Arange, Brange):
        self.MaxVA.SetLabel(Arange)
        self.MaxVB.SetLabel(Brange)
        self.MinVA.SetLabel("-"+Arange)
        self.MinVB.SetLabel("-"+Brange)

       
class plotCanvas(wxPanel):
    def __init__(self,parent):
        wxPanel.__init__(self, parent, -1)
       
        box1= wxBoxSizer(wxHORIZONTAL)
        box1.Add(wxButton(self, 10, "<<", wxPoint(-1,-1), wxSize(-1,-1)),1,
wxEXPAND)
        box1.Add(wxButton(self, 15, "RESET", wxPoint(-1,-1),
wxSize(-1,-1)),1, wxEXPAND)
        box1.Add(wxButton(self, 20, ">>", wxPoint(-1,-1), wxSize(-1,-1)),1,
wxEXPAND)
        EVT_BUTTON(self, 10, self.OnButZoomOutX)
        EVT_BUTTON(self, 15, self.OnButZoomResetX)
        EVT_BUTTON(self, 20, self.OnButZoomInX)
       
        self.can= canvas(self)
        self.cantxt= sideScale(self)
        self.cantxt.MakeLabels()
        self.cantxt.SetVolts("2.5", "3.283")
        # wxSize used as default if Fit is used otherwise frame size above
is used.
        box2= wxBoxSizer(wxHORIZONTAL)
        box2.Add(self.can,1, wxEXPAND)
        box2.Add(self.cantxt,0, wxEXPAND)
       
        #for displaying voltage, time and frequency
        self.pointDisp= wxStatusBar(self, -1)
        self.pointDisp.SetFieldsCount(5)
        self.pointDisp.SetStatusText("T= 0ms",0)
        self.pointDisp.SetStatusText("V= 0V",1)
        self.pointDisp.SetStatusText("dT= 0ms",2)
        self.pointDisp.SetStatusText("dV= 0V",3)
        self.pointDisp.SetStatusText("Freq.= 0KHz",4)


        box= wxBoxSizer(wxVERTICAL)
        box.Add(self.pointDisp,0, wxEXPAND)
        box.Add(box2,1, wxEXPAND)
        box.Add(box1,0, wxEXPAND)
       
        # Following are required to make sizers work poperly!!!!!
        self.SetAutoLayout(TRUE)
        self.SetSizeHints(200,200,600,600)
        self.SetSizer(box)
        box.Fit(self)  


       
    def OnButZoomInX(self, event):
        self.can.xscale= self.can.xscale*1.1
       
        self.can.AdjustScrollbar((500+256)*self.can.xscale)
        print "Zoom In:",self.can.xscale
        self.can.Refresh()

    def OnButZoomResetX(self, event):
        self.can.xscale= 1
        self.can.AdjustScrollbar((500+256))
        print "Zoom Reset:",self.can.xscale
        self.can.Refresh()        
   
    def OnButZoomOutX(self, event):
        self.can.xscale= self.can.xscale/1.1
        self.can.AdjustScrollbar((500+256)*self.can.xscale)
        print "Zoom Out:",self.can.xscale
        self.can.Refresh()                


#---------------------------------------------------------------------------

if __name__ == '__main__':
    class myFrame(wxFrame):
        def __init__(self, parent=NULL):
            wxFrame.__init__(self, parent, -1, "wx_plot_lines",
                wxDefaultPosition,wxSize(600,520)) #size is used as default
unless Fit is used.
         
            try:
                plotCanvas(self)
           
            except:
                self.Destroy() # causes main loop to exit
                traceback.print_exc() # and you still get your trace
           
        def OnCloseWindow(self, event):
            self.Destroy()
       
        def OnExit(self, event):
            self.Close(true)
   
   
#---------------------------------------------------------------------------

    class myApp(wxApp):
        def OnInit(self):
            global pcan
            topframe=myFrame()
            topframe.Show(TRUE)
            self.SetTopWindow(topframe)
         
            return TRUE



    app = myApp(0)
    app.MainLoop()




_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] wxPython-2_1_14-20000227, Frame Problem and statusbar problem

Piet van Oostrum
>>>>> "Gordon Williams" <[hidden email]> (GW) writes:

GW> Hi,
GW> After trying out the new version of wxPython(2.2.14) I found that there
GW> were a couple of problems with my code now.

GW> 1) At the bottom of the Frame there is now a bar across the bottom with a
GW> grip? on the right hand side (45 deg lines) and something else on the left
GW> hand side (vertical lines).  This covers over some buttons on the bottom of
GW> the panel inside.

This is your status bar. The vertical lines are the separators between the
fields, which are empty.

GW> 2) I had a status bar in a wxPanel, but this no longer appears.

You have to add the statusbar to the Frame, not to the Panel. And you have
to do it with
            self.SetStatusBar(self.pointDisp)
rather than box.Add(self.pointDisp,0, wxEXPAND)
--
Piet van Oostrum <[hidden email]>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: [hidden email]


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

[wxPython] Python Editor

Gary Greyling-2
What is the best Python editor floating around at the monent ??

--
Gary Greyling
Electric Genetics

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Python Editor

Gerrit Holl
<quote name="Gary Greyling" date="951926202" email="[hidden email]">
> What is the best Python editor floating around at the monent ??

Assumed you mean IDE:

    http://www.python.org/idle/

</quote>

regards,
Gerrit.

--
-----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com
Version: 3.12
GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE?
Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y
-----END GEEK CODE BLOCK-----

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Python Editor

Gary Greyling-2
Yes IDE but IDLE eeww
--
Gary Greyling
Electric Genetics

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Python Editor

Gerrit Holl
<quote name="Gary Greyling" date="951928185" email="[hidden email]">
> Yes IDE but IDLE eeww

Please clarify - I'm afraid I don't understand you.

'eeww'... Hmm, anything wrong with idle?

Vim has syntax color highlighting too, but it's not an IDE.
Maybe you'll like Emacs - I don't :)
</quote>

regards,
Gerrit.

--
-----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com
Version: 3.12
GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE?
Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y
-----END GEEK CODE BLOCK-----

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Python Editor

Gary Greyling-2
> Please clarify - I'm afraid I don't understand you.

IDLE lacks in usability (imho) and the syntax highlighting leaves something to
be desired.
 
> Vim has syntax color highlighting too, but it's not an IDE.
> Maybe you'll like Emacs - I don't :)

I'm using Moonshine at the moment. Much better than anything else i've found. I
was just checking if anything better has come along yet.

--
Gary Greyling
Electric Genetics

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Python Editor

Fredrik Lundh-3
(off topic?)

Gary Greyling <[hidden email]> wrote:
> > Please clarify - I'm afraid I don't understand you.
>
> IDLE lacks in usability (imho) and the syntax highlighting leaves something to
> be desired.

just curious, but I thought IDLE had "perfect"
syntax highlighting?  (i.e. it never messes up).

or is it just not fast enough?

> > Maybe you'll like Emacs - I don't :)
>
> I'm using Moonshine at the moment. Much better than anything else i've found. I
> was just checking if anything better has come along yet.

got a pointer?

</F>


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Python Editor

Steve Halpin
In reply to this post by Gary Greyling-2
Sorry if this is off topic.

>> I'm using Moonshine at the moment. Much better than anything else i've
found. I
>> was just checking if anything better has come along yet.

>got a pointer?
I presume this is the moonshine at:
http://www.suite3220.com/

Up until now, I have been using Programmers File Editor (free but
discontinued, and win only):
http://www.lancs.ac.uk/people/cpaap/pfe/
No python specific features, but IMHO helpful, simple and very reliable.

I too would be interested in knowing what other people recommend - features
that I have seen that I don't have that I would like:
* reliable source coloring
* folding of functions (they display on one line until you do something to
display them)
* integrated debugging environment
* runs on (in order of preference NT, Win98, HP-UX, Linux

Best Regards
Steve


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: Re: [wxPython] Python Editor

Volker Goebbels-2
Hi,

> Sorry if this is off topic.

maybe, but still interesting :)

[...]

> Up until now, I have been using Programmers File Editor (free but
> discontinued, and win only):
> http://www.lancs.ac.uk/people/cpaap/pfe/
> No python specific features, but IMHO helpful, simple and very reliable.
>
> I too would be interested in knowing what other people recommend -
> features
> that I have seen that I don't have that I would like:
> * reliable source coloring
> * folding of functions (they display on one line until you do something
> to
> display them)
> * integrated debugging environment
> * runs on (in order of preference NT, Win98, HP-UX, Linux

For a pure windooze editor, try TextPad 32:
- Syntax highlightning by plugins. Python mode is available and working
  very well. Plugins for let's say 10-15 different languages/file types
  are available. Key bindings are switchable between different editor
  mimics a.s.o. ...
- Small and handy

For a cross platform editing OS ... errr ... editor, look for XEmacs:
- Available for many platforms, even Win32.
- Syntax hightlightning for Python and many (and I mean _many_) other
  file types
- Gods own keybindings (aka emacs :*), vi is also possible ...
- Draw back: it's HUGE! On my NT machine @ work it occupies around 60 MB
  for a not at all full installation ... but hey, it's xemacs :)

I hope that's not too much offtopic spam ... get them and try them out.

Oh, and have fun :)

Greetings,
Volker Goebbels

--
2science Scientific Consulting        Dr. rer. nat Volker M. Göbbels
            Martin-Luther-Kingstr. 70, 52146 Würselen
Tel. 0177-4736586                            EMail: [hidden email]


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] wxPython-2_1_14-20000227, Frame Problem and statusbar problem

Gordon Williams
In reply to this post by Gordon Williams
Hi Robin, Piet

Thanks for your note.  I tried the code that Robin sent and it does display
the values in the status bar, but the status bar is not in the place that I
wanted it.  I want it at the top of the panel. In version 2.1.11 it worked
ok and was shown properly, so something has changed between 2.1.11 and
2.1.14.

I had a look at the docs and the parameters are:
Parameters
parent
The window parent, usually a frame.
id
The window identifier. It may take a value of -1 to indicate a default
value.
pos
The window position. A value of (-1, -1) indicates a default position,
chosen by either the windowing system or wxWindows, depending on platform.
size
The window size. A value of (-1, -1) indicates a default size, chosen by
either the windowing system or wxWindows, depending on platform.
style
The window style. See wxStatusBar.

so I assume that panel as a parent would be ok (although maybe not
typical).  Also, a position is allowed so I assume that this can be placed
anywhere on its parent.

One other note is that the default style is without the grip which is only
available on windows.  If no style is specified it should not appear
although it does.

If the status bar is derived from wxWindow why cant it be used like any
other wxWindow derived object?


Regards,

Gordon Williams


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users