All,

And yet another situation. In this case, compiling using Aptana and Pydev, I 
can see a small window open in the upper left corner of my screen, but then 
quickly close. How can I access the information that I think is in that small 
window, but doesn't stick around long enough to view?

import numpy as np
import wx

import matplotlib
matplotlib.interactive(False)
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.figure import Figure
from matplotlib.pyplot import gcf, setp

class Knob:
    pass

class Param:
    
    def __init__(self, initialValue=None, minimum=0., maximum=1.):
        self.minimum = minimum
        self.maximum = maximum
        if initialValue != self.constrain(initialValue):
            raise ValueError('illegal initial value')
        self.value = initialValue
        self.knobs = []
        
    def attach(self, knob):
        self.knobs += [knob]
        
    def set(self, value, knob=None):
        self.value = value
        self.value = self.constrain(value)
        for feedbackKnob in self.knobs:
            if feedbackKnob != knob:
                feedbackKnob.setKnob(self.value)
        return self.value
    
    def constrain(self, value):
        if value <= self.minimum:
            value = self.minimum
        if value >= self.maximum:
            value = self.maximum
        return value
        
class SliderGroup(Knob):
    def __init__(self, parent, label, param):
        self.sliderLabel = wx.StaticText(parent, label=label)
        self.sliderText = wx.TextCtrl(parent, -1, style=wx.TE_PROCESS_ENTER)
        self.slider = wx.Slider(parent, -1)
        self.slider.SetMax(param.maximum * 1000)
        self.setKnob(param.value)
        
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self.sliderLabel, 0, wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, 
border=2)
        sizer.Add(self.sliderText, 0, wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, 
border=2)
        sizer.Add(self.slider, 1, wx.EXPAND)
        self.sizer = sizer
        
class FourierDemoFrame(wx.Frame):
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)
        
        self.frequencySliderGroup=SliderGroup(self,label='Frequency f0:')
        self.amplitudeSliderGroup=SliderGroup(self,label='Amplitude a:')
        
        sizer=wx.BoxSizer(wx.VERTICAL)
        
sizer.Add(self.frequencySliderGroup.sizer,0,wx.EXPAND|wx.ALIGN_CENTER|wx.ALL,border=5)
        
sizer.Add(self.amplitudeSliderGroup.sizer,0,wx.EXPAND|wx.ALIGN_CENTER|wx.ALL,border=5)
        self.SetSizer(sizer)
        
class App(wx.App):        
    def OnInit(self):
        self.frame1=FourierDemoFrame(parent=None,title="Fourier 
Demo",size=(640,480))
        self.frame1.Centre()
        self.frame1.Show()
        return True
        
app=App()
app.MainLoop()
        
David.


On Mar 7, 2010, at 1:40 PM, David Arnold wrote:

> All,
> 
> Here is a similar situation:
> 
> import wx
> 
> ID_STAT = 1
> ID_TOOL = 2
> 
> class CheckMenuItem(wx.Frame):
>    def __init__(self, parent, id, title):
>        wx.Frame.__init__(self, parent, id, title, size=(350, 250))
> 
>        # create a menubar
>        menubar = wx.MenuBar()
> 
>        # create file menu
>        file = wx.Menu()
> 
>        # create view menu
>        view = wx.Menu()
> 
>        # add items to view menu
>        self.shst = view.Append(ID_STAT, 'Show statusbar', 'Show statusbar', 
> kind=wx.ITEM_CHECK)
>        self.shtl = view.Append(ID_TOOL, 'Show toolbar', 'Show toolbar', 
> kind=wx.ITEM_CHECK)
>        view.Check(ID_STAT,True)
>        view.Check(ID_TOOL,True)
> 
>        # bindings
>        self.Bind(wx.EVT_MENU,self.toggleStatusBar,id=ID_STAT)
> 
>        # add menus to menubar
>        menubar.Append(file, '&File')
>        menubar.Append(view, '&View')
> 
>        # add menubar to Frame
>        self.SetMenuBar(menubar)
> 
>        # add toolbar
>        self.toolbar = self.CreateToolBar()
>        self.toolbar.AddLabelTool(3,'',wx.Bitmap('icons/calendar.png'))
>        self.toolbar.Realize()
> 
>        # add status bar
>        self.statusbar = self.CreateStatusBar()
>        self.statusbar.Show()
> 
>        # center and show frame
>        self.Centre()
>        self.Show()
> 
>    def ToggleStatusBar(self,event):
>        if self.shst.IsChecked():
>            self.statusbar.Show()
>        else:
>            self.statusbar.Hide()
> 
> 
> app = wx.App()        
> CheckMenuItem(None, -1, 'Check Menu Item')
> app.MainLoop()
> 
> Because I wrote toggleStatusBar instead of ToggleStatusBar in my binding, the 
> GUI won't run, but no errors are reported anywhere in PyDev.
> 
> What can I do in this situation other than struggle manually to find this 
> little typo?
> 
> D.
> 
> 
> On Mar 7, 2010, at 12:13 PM, David Arnold wrote:
> 
>> All,
>> 
>> Here is a situation I find myself in frequently. The code throws no errors, 
>> but the GUI won't open.
>> 
>> import wx
>> 
>> class MenuExample(wx.Frame):
>>   def __init__(self, parent, id, title):
>>       wx.Frame.__init__(self, parent, id, title, size=(250, 200))
>> 
>>       # this creates the menubar
>>       menubar = wx.MenuBar()
>> 
>>       # this creates main 'file' menu
>>       file = wx.Menu()
>> 
>>       # add an 'Open' submenu to 'file' menu
>>       open = wx.MenuItem(file, 1, '&Open\tCtrl+O')
>>       file.AppendItem(open)
>> 
>>       # add a 'Quit' submenu to 'file' menu
>>       quit = wx.MenuItem(file, 2, '&Quit\tCtrl+Q')
>>       file.AppendItem(quit)
>> 
>>       self.Bind(wx.EVT_MENU, self.onQuit, 2)
>> 
>>       # this adds the 'file' menu to the menubar
>>       menubar.Append(file, '&File')
>> 
>>       # this adds the menubar to the frame
>>       self.SetMenuBar(menubar)
>> 
>>       # center and show the frame
>>       self.Centre()
>>       self.Show()
>> 
>>   def onQuit(self,event):
>>       self.Close()
>> 
>> app = wx.App()
>> MenuExample(None, -1, 'Menu Example')
>> app.MainLoop()
>> 
>> 
>> I found the error. I should have:          self.Bind(wx.EVT_MENU, 
>> self.onQuit, id=2)
>> 
>> However, I am wondering if there is anything I can do with the PyDev 
>> debugger (or other strategy) to help locate this type of error when it 
>> happens. It is very frustrating when no errors are returned but the GUI 
>> won't run.
>> 
>> David.
>> 
>> 
>> 
>> 
>> 
>> ------------------------------------------------------------------------------
>> Download Intel&#174; Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Pydev-users mailing list
>> Pydev-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/pydev-users
> 
> 
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Pydev-users mailing list
> Pydev-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pydev-users


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Pydev-users mailing list
Pydev-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pydev-users

Reply via email to