1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
#!/usr/bin/env jython
import sys
import os
import java
import javax
from javax.swing import JPanel,JTextArea,JTabbedPane,JLabel,ImageIcon,JButton, JList,JTextPane,JScrollPane
from java.lang import Runtime
from java.awt import BorderLayout as BL, Color, Button, Panel, Frame, Choice, Label, TextArea, TextField, GridBagLayout, GridBagConstraints, Image
def getFileDirectory():
frame = java.awt.Frame()
dialog = java.awt.FileDialog(frame, "Working Directory...", java.awt.FileDialog.LOAD)
import java.lang.System as System
System.setProperty("apple.awt.fileDialogForDirectories", "true");
dialog.show();
System.setProperty("apple.awt.fileDialogForDirectories", "false");
filename = dialog.getDirectory()
filename += dialog.getFile()
return filename
def getFile():
frame = java.awt.Frame()
dialog = java.awt.FileDialog(frame, "Working Directory...", java.awt.FileDialog.LOAD)
dialog.show();
filename = dialog.getDirectory()
filename += dialog.getFile()
return filename
class ResizeList (java.awt.List):
width = 0
height = 0
def __init__(self):
java.awt.List.__init__(self)
self.width = 100
self.height = 100
def getSize(self):
return java.awt.Dimension(self.width, self.height)
def getPreferredSize(self):
return java.awt.Dimension(self.width, self.height)
def getMinimumSize(self):
return java.awt.Dimensions(self.width, self.height)
def getMaximumSize(self):
return java.awt.Dimensions(self.width, self.height)
def setWidth(self, w):
self.width = w
self.invalidate()
def setHeight(self, h):
self.height = h
self.invalidate()
class ListSelectFiles(JPanel):
def __init__(self):
gb = GridBagLayout();
gbc = GridBagConstraints();
JPanel.__init__(self, gb)
component = Label("Assembly Source files to assemble: ")
gbc.gridx = 0
gbc.gridy = 0
gbc.fill = gbc.NONE
gbc.anchor = gbc.WEST
gb.setConstraints(component, gbc)
self.add(component)
FileList = JList()
gbc.gridy = 1
gbc.weightx = 1.0
gbc.weighty = 1.0
gbc.gridheight = 2
gbc.fill = gbc.BOTH
gb.setConstraints(FileList, gbc)
#ASMList.setWidth(400)
self.add(FileList)
component = Button("Add a File", actionPerformed=self.BrowseForFiles)
gbc.gridx = 1
gbc.weightx = 0.0
gbc.weighty = 0.0
gbc.gridheight = 1
gbc.fill = gbc.HORIZONTAL
gbc.anchor = gbc.NORTH
gb.setConstraints(component, gbc)
self.add(component)
component = Button("Remove a File", actionPerformed=self.BrowseForFiles)
gbc.gridy = 2
gbc.anchor = gbc.SOUTH
gb.setConstraints(component, gbc)
self.add(component)
def BrowseForFiles(self, event):
TheFile = getFile()
self.getComponent(1).add(JLabel(TheFile))
self.Refresh()
def Refresh(self):
self.invalidate()
self.validate()
def addFile(self, infile):
pass
class ContentPane (JTabbedPane):
""" Settings pane for the various options. """
def __init__(self):
JTabbedPane.__init__(self)
icon = ImageIcon(ImageIcon("images/GreenRightArrow.png").getImage().getScaledInstance(40, 60, Image.SCALE_SMOOTH))
Pane1 = self.BuildStatusPane()
self.addTab("Status", icon, Pane1, "Does Nothing")
Pane2= self.BuildRunOptPane()
self.addTab("Run Options", icon, Pane2, "Does Nothing #2")
Pane3 = self.BuildProjOptPane()
self.addTab("Compile Options", icon, Pane3, "Does Nothing #3")
#self.setLayout(java.awt.GridLayout(3,1))
self.validate()
def BuildStatusPane(self):
thePane = JPanel()
msgwindow = JTextArea()
#msgwindow.setResizable(True)
#msgwindow.background = 255,255,255
thePane.add(JScrollPane(msgwindow), BL.CENTER)
return thePane
def BuildRunOptPane(self):
thePane = JPanel()
thePane.add(Button("WHATS UP!"), BL.CENTER)
return thePane
def BuildProjOptPane(self):
origb = GridBagLayout()
thisPane = Panel(origb)
gb = GridBagLayout()
gbc = GridBagConstraints()
self.WorkingDir = JPanel(gb)
component = Label("Working Directory: ")
gbc.gridx = 0
gbc.gridy = 0
gbc.weightx = 1.0
gbc.fill = gbc.HORIZONTAL
gb.setConstraints(component, gbc)
self.WorkingDir.add(component)
component = TextField(40)
gbc.gridy = 1
gb.setConstraints(component, gbc)
self.WorkingDir.add(component)
component = Button("Browse", actionPerformed=self.BrowseWorkingDir)
gbc.gridx = 1
gbc.weightx = 0.0
gbc.fill = gbc.NONE
gb.setConstraints(component, gbc)
self.WorkingDir.add(component)
gbc.gridx = 0
gbc.gridy = 0
gbc.weightx = 1.0
gbc.weighty = 0.0
gbc.fill = gbc.HORIZONTAL
origb.setConstraints(self.WorkingDir, gbc)
thisPane.add(self.WorkingDir)
gbc.gridy = 1
gbc.weighty = 1.0
gbc.fill = gbc.BOTH
self.FileListC = ListSelectFiles()
origb.setConstraints(self.FileListC, gbc)
thisPane.add(self.FileListC)
gbc.gridy = 2
self.FileListASM = ListSelectFiles()
origb.setConstraints(self.FileListASM, gbc)
thisPane.add(self.FileListASM)
return thisPane
#ChoiceBox = Choice()
#ChoiceBox.addItem("These come from file.")
#inpane.add(ChoiceBox)
def AddListeners(self, ListenerObj):
self.FileListC.addComponentListener(ListenerObj)
self.WorkingDir.addComponentListener(ListenerObj)
self.FileListASM.addComponentListener(ListenerObj)
def BrowseWorkingDir(self, event):
TheDir = getFileDirectory()
self.WorkingDir.getComponent(1).setText(TheDir)
self.Refresh()
def BrowseCSource(self, event):
TheFile = getFile()
self.FileListC.getComponent(1).add(TheFile)
self.Refresh()
def Refresh(self):
self.invalidate()
self.validate()
class avrIDE(JPanel):
""" A simple GUI example """
def __init__ (self): # constructor
JPanel.__init__(self, BL())
self.ConPane = ContentPane()
self.add(self.ConPane, BL.CENTER)
actionPane = JPanel()
actionPane.add(JButton(ImageIcon("images/ArrowRight.gif")))
actionPane.add(JButton(ImageIcon("images/build.png")))
self.add(actionPane, BL.SOUTH)
self.validate()
class CompListener(java.awt.event.ComponentListener):
def componentResized(self, event):
global MainWindow
TheComponent = event.getComponent()
TheComponent.setBorder(javax.swing.border.EmptyBorder(20,20,0,0))
newx = TheComponent.getWidth()
newy = TheComponent.getHeight()
tmpbounds = MainWindow.getBounds()
if newx > tmpbounds.width:
tmpbounds.width = newx
if newy > tmpbounds.height:
tmpbounds.height = newy
MainWindow.setBounds(tmpbounds)
MainWindow.invalidate()
MainWindow.validate()
def componentMoved(self, event):
self.componentResized(event)
def doRunCompile(self, event):
self.ConPane.ShowRunPane(event)
print "HEY"
if __name__ == "__main__":
global MainWindow
def doClose (event):
import sys
sys.exit()
MainWindow = Frame("AVR Project Manager.", windowClosing=doClose)
MainWindow.setResizable(1)
MainWindow.add( avrIDE() , BL.CENTER)
MainWindow.size = 500, 600
MainWindow.visible = 1
|