~ubuntu-branches/ubuntu/karmic/model-builder/karmic

« back to all changes in this revision

Viewing changes to model_builder/wxMiniFrame1.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2007-04-10 17:05:04 UTC
  • Revision ID: james.westby@ubuntu.com-20070410170504-y884ntvt656218me
Tags: upstream-0.4.0
Import upstream version 0.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding:iso8859-1 -*- 
 
2
#-----------------------------------------------------------------------------
 
3
# Name:        wxMiniFrame1.py
 
4
# Purpose:
 
5
#
 
6
# Author:      <Fl�vio Code�o Coelho>
 
7
#
 
8
# Created:     2003/02/04
 
9
# RCS-ID:      $Id: wxMiniFrame1.py,v 1.3 2004/01/13 10:51:44 fccoelho Exp $
 
10
# Copyright:   (c) 2003 Fl�vio Code�o Coelho <fccoelho@uerj.br>
 
11
# Licence:     This program is free software; you can redistribute it and/or
 
12
# modify it under the terms of the GNU General Public License
 
13
# as published by the Free Software Foundation; either version 2
 
14
# of the License, or (at your option) any later version.
 
15
#
 
16
# This program is distributed in the hope that it will be useful,
 
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
# GNU General Public License for more details.
 
20
#
 
21
# You should have received a copy of the GNU General Public License
 
22
# along with this program; if not, write to the Free Software
 
23
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
24
#
 
25
#-----------------------------------------------------------------------------
 
26
#Boa:MiniFrame:wxMiniFrame1
 
27
 
 
28
import wx
 
29
import wx.lib.buttons
 
30
from scipy import gplt
 
31
from string import *
 
32
 
 
33
def create(parent):
 
34
    return wxMiniFrame1(parent)
 
35
 
 
36
[wxID_WXMINIFRAME1, wxID_WXMINIFRAME1BUTTON1, wxID_WXMINIFRAME1BUTTON2,
 
37
 wxID_WXMINIFRAME1BUTTON3, wxID_WXMINIFRAME1BUTTON4, wxID_WXMINIFRAME1BUTTON5,
 
38
 wxID_WXMINIFRAME1BUTTON6, wxID_WXMINIFRAME1BUTTON7,
 
39
 wxID_WXMINIFRAME1GENTOGGLEBUTTON1, wxID_WXMINIFRAME1PANEL1,
 
40
] = [wx.NewId() for _init_ctrls in range(10)]
 
41
 
 
42
class wxMiniFrame1(wx.MiniFrame):
 
43
    def _init_ctrls(self, prnt):
 
44
        # generated method, don't edit
 
45
        wx.MiniFrame.__init__(self, id=wxID_WXMINIFRAME1, name='', parent=prnt,
 
46
              pos= wx.Point(258, 166), size= wx.Size(200, 170),
 
47
              style=wx.DEFAULT_FRAME_STYLE, title='Plot Properties')
 
48
        self.SetClientSize(wx.Size(200, 170))
 
49
        self.SetToolTipString('Edit plot properties')
 
50
 
 
51
        self.panel1 = wx.Panel(id=wxID_WXMINIFRAME1PANEL1, name='panel1',
 
52
              parent=self, pos= wx.Point(0, 0), size= wx.Size(200, 170),
 
53
              style=wx.TAB_TRAVERSAL)
 
54
        self.panel1.SetToolTipString('')
 
55
        self.panel1.SetLabel('Plot Properties')
 
56
 
 
57
        self.button1 = wx.Button(id=wxID_WXMINIFRAME1BUTTON1, label='Title',
 
58
              name='button1', parent=self.panel1, pos= wx.Point(14, 14),
 
59
              size= wx.Size(80, 22), style=0)
 
60
        self.button1.SetToolTipString('Set the title.')
 
61
        self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button, id=wxID_WXMINIFRAME1BUTTON1)
 
62
 
 
63
        self.button2 = wx.Button(id=wxID_WXMINIFRAME1BUTTON2, label='X title',
 
64
              name='button2', parent=self.panel1, pos= wx.Point(14, 44),
 
65
              size= wx.Size(80, 22), style=0)
 
66
        self.button2.SetToolTipString('Set title of X axis')
 
67
        self.button2.SetHelpText('Set X-axis title')
 
68
        self.button2.Bind(wx.EVT_BUTTON, self.OnButton2Button, id=wxID_WXMINIFRAME1BUTTON2)
 
69
 
 
70
        self.button3 = wx.Button(id=wxID_WXMINIFRAME1BUTTON3, label='Y title',
 
71
              name='button3', parent=self.panel1, pos= wx.Point(14, 74),
 
72
              size= wx.Size(80, 22), style=0)
 
73
        self.button3.SetToolTipString('Set title of Y axis')
 
74
        self.button3.SetHelpText('Set Y-axis title')
 
75
        self.button3.Bind(wx.EVT_BUTTON, self.OnButton3Button, id=wxID_WXMINIFRAME1BUTTON3)
 
76
 
 
77
        self.genToggleButton1 = wx.GenToggleButton(ID=wxID_WXMINIFRAME1GENTOGGLEBUTTON1,
 
78
              label='Grid', name='genToggleButton1', parent=self.panel1,
 
79
              pos= wx.Point(14, 104), size= wx.Size(80, 22), style=0)
 
80
        self.genToggleButton1.SetToggle(1)
 
81
        self.genToggleButton1.SetToolTipString('Toggle gridlines')
 
82
        self.genToggleButton1.Bind(wx.EVT_BUTTON, self.OnGentogglebutton1Button, id=wxID_WXMINIFRAME1GENTOGGLEBUTTON1)
 
83
 
 
84
        self.button4 = wx.Button(id=wxID_WXMINIFRAME1BUTTON4, label='Log Scale',
 
85
              name='button4', parent=self.panel1, pos= wx.Point(14, 134),
 
86
              size= wx.Size(80, 22), style=0)
 
87
        self.button4.SetToolTipString('Set logarithm scale for axes, individually.')
 
88
        self.button4.Bind(wx.EVT_BUTTON, self.OnButton4Button, id=wxID_WXMINIFRAME1BUTTON4)
 
89
 
 
90
        self.button5 = wx.Button(id=wxID_WXMINIFRAME1BUTTON5, label='X limits',
 
91
              name='button5', parent=self.panel1, pos= wx.Point(104, 44),
 
92
              size= wx.Size(80, 22), style=0)
 
93
        self.button5.Bind(wx.EVT_BUTTON, self.OnButton5Button, id=wxID_WXMINIFRAME1BUTTON5)
 
94
 
 
95
        self.button6 = wx.Button(id=wxID_WXMINIFRAME1BUTTON6, label='Y limits',
 
96
              name='button6', parent=self.panel1, pos= wx.Point(104, 74),
 
97
              size= wx.Size(80, 22), style=0)
 
98
        self.button6.Bind(wx.EVT_BUTTON, self.OnButton6Button, id=wxID_WXMINIFRAME1BUTTON6)
 
99
 
 
100
        self.button7 = wx.Button(id=wxID_WXMINIFRAME1BUTTON7, label='Autoscale',
 
101
              name='button7', parent=self.panel1, pos= wx.Point(104, 14),
 
102
              size= wx.Size(80, 22), style=0)
 
103
        self.button7.Bind(wx.EVT_BUTTON, self.OnButton7Button, id=wxID_WXMINIFRAME1BUTTON7)
 
104
 
 
105
    def __init__(self, parent):
 
106
        self._init_ctrls(parent)
 
107
 
 
108
    def OnButton1Button(self, event):
 
109
        """
 
110
        sets the title of the plot on the event
 
111
        """
 
112
        dlg = wx.TextEntryDialog(self, 'Enter a title for this plot:', 'Plot Title', 'Time Series')
 
113
        try:
 
114
            if dlg.ShowModal() == wx.ID_OK:
 
115
                answer = dlg.GetValue()
 
116
                gplt.title(answer)
 
117
 
 
118
        finally:
 
119
            dlg.Destroy()
 
120
 
 
121
    def OnButton2Button(self, event):
 
122
        """
 
123
        sets the X axis title of the plot on the event
 
124
        """
 
125
        dlg = wx.TextEntryDialog(self, 'Enter the X-axis title:', 'X-axis Title', 'Time')
 
126
        try:
 
127
            if dlg.ShowModal() == wx.ID_OK:
 
128
                answer = dlg.GetValue()
 
129
                gplt.xtitle(answer)
 
130
        finally:
 
131
            dlg.Destroy()
 
132
 
 
133
 
 
134
 
 
135
 
 
136
    def OnButton3Button(self, event):
 
137
        """
 
138
        sets the Y axis title of the plot on the event
 
139
        """
 
140
        dlg = wx.TextEntryDialog(self, 'Enter the Y-axis title:', 'Y-axis Title', 'Y[i]')
 
141
        try:
 
142
            if dlg.ShowModal() == wx.ID_OK:
 
143
                answer = dlg.GetValue()
 
144
                gplt.ytitle(answer)
 
145
        finally:
 
146
            dlg.Destroy()
 
147
 
 
148
    def OnGentogglebutton1Button(self, event):
 
149
        """
 
150
        toggle gridlines
 
151
        """
 
152
        t = self.genToggleButton1.GetValue()
 
153
        if t == 1:
 
154
            gplt.grid('on')
 
155
        else:
 
156
            gplt.grid('off')
 
157
 
 
158
    def OnButton4Button(self, event):
 
159
        """
 
160
        log scale on chosen axis
 
161
        """
 
162
        dlg = wx.SingleChoiceDialog(self, 'Choose Axis', 'Caption', ['X-axis','Y-axis', 'None'])
 
163
        try:
 
164
            if dlg.ShowModal() == wx.ID_OK:
 
165
                selected = dlg.GetStringSelection()
 
166
                if selected == 'X-axis':
 
167
                    gplt.logx()
 
168
                elif selected == 'Y-axis':
 
169
                    gplt.logy()
 
170
                elif selected == 'None':
 
171
                    gplt.logx('off')
 
172
                    gplt.logy('off')
 
173
        finally:
 
174
            dlg.Destroy()
 
175
 
 
176
    def OnButton5Button(self, event):
 
177
        dlg = wx.TextEntryDialog(self, 'Enter two numbers separated by a space:', 'Define X-Axis Limits', '')
 
178
        try:
 
179
            if dlg.ShowModal() == wx.ID_OK:
 
180
                answer = dlg.GetValue()
 
181
                lims = [i for i in strip(answer).split(' ') if i!= '']
 
182
                gplt.xaxis((float(lims[0]),float(lims[1])))
 
183
        finally:
 
184
            dlg.Destroy()
 
185
 
 
186
 
 
187
        event.Skip()
 
188
 
 
189
    def OnButton6Button(self, event):
 
190
        dlg = wx.TextEntryDialog(self, 'Enter two numbers separated by a space:', 'Define Y-Axis Limits', '')
 
191
        try:
 
192
            if dlg.ShowModal() == wx.ID_OK:
 
193
                answer = dlg.GetValue()
 
194
                answer = dlg.GetValue()
 
195
                lims = [i for i in strip(answer).split(' ') if i!= '']
 
196
                gplt.yaxis((float(lims[0]),float(lims[1])))
 
197
 
 
198
        finally:
 
199
            dlg.Destroy()
 
200
 
 
201
 
 
202
        event.Skip()
 
203
 
 
204
    def OnButton7Button(self, event):
 
205
        gplt.autoscale()
 
206
        event.Skip()