CVS: anygui/lib/anygui/backends javagui.py,1.50,1.51
Magnus Lie Hetland <[email protected]> Sat, 31 Aug 2002 15:49:27 -0700
| Newsgroups | gmane.comp.python.anygui.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/anygui/anygui/lib/anygui/backends
In directory usw-pr-cvs1:/tmp/cvs-serv22444/lib/anygui/backends
Modified Files:
javagui.py
Log Message:
ListBox, Button, and TextField now work in javagui
Index: javagui.py
===================================================================
RCS file: /cvsroot/anygui/anygui/lib/anygui/backends/javagui.py,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -r1.50 -r1.51
*** javagui.py 13 Aug 2002 18:50:13 -0000 1.50
--- javagui.py 31 Aug 2002 22:49:24 -0000 1.51
***************
*** 5,9 ****
--- 5,11 ----
Application
+ ButtonWrapper
LabelWrapper
+ TextFieldWrapper
ListBoxWrapper
WindowWrapper
***************
*** 72,75 ****
--- 74,92 ----
self.proxy.push()
+ def create(self, *args, **kwds):
+
+ #FIXME: This does no harm in Jython, since the GUI will run
+ #before app.run() anyway. However, this does mean that javagui
+ #will behave differently from other back-ends, i.e. the
+ #widgets will appear earlier than expected. Also, the reason
+ #why this overriding was needed was that
+ #AbstractWrapper.create wasn't called after the main loop was
+ #entered. That should be fixed, and this method should then
+ #probably be removed. [mlh@20020831]
+
+ if self.noWidget():
+ self.widget = self.widgetFactory(*args, **kwds)
+ self.widgetSetUp()
+
# internalDestroy?
***************
*** 137,141 ****
except AttributeError: pass
else:
! bounds = comp.bounds
container.remove(self.widget)
container.repaint(bounds)
--- 154,158 ----
except AttributeError: pass
else:
! bounds = self.widget.bounds
container.remove(self.widget)
container.repaint(bounds)
***************
*** 157,161 ****
else:
return "" # @@@ What would be the best behaviour here? Should there be an exception?
!
################################################################
--- 174,193 ----
else:
return "" # @@@ What would be the best behaviour here? Should there be an exception?
!
! ################################################################
!
! class ButtonWrapper(ComponentWrapper):
!
! def clickHandler(self, event):
! send(self.proxy, 'click')
!
! def widgetSetUp(self):
! insets = awt.Insets(0, 0, 0, 0)
! self.widget.margin = insets
! self.widget.actionPerformed = self.clickHandler
!
! def widgetFactory(self, *args, **kwds):
! return swing.JButton()
!
################################################################
***************
*** 168,171 ****
--- 200,232 ----
return widget
+ ################################################################
+
+ class TextFieldWrapper(ComponentWrapper):
+
+ def widgetFactory(self, *args, **kwds):
+ return swing.JTextField()
+
+ def widgetSetUp(self):
+ self.widget.actionPerformed = self.enterHandler
+
+ def enterHandler(self, event):
+ send(self, 'enterkey')
+
+ def getSelection(self):
+ return self.widget.selectionStart, \
+ self.widget.selectionEnd
+
+ def setSelection(self, selection):
+ self.widget.selectionStart = selection[0]
+ self.widget.selectionStart = selection[1]
+
+ def setEditable(self, editable):
+ self.widget.editable = editable
+
+ def setText(self, text):
+ self.widget.text = text
+
+ def getText(self):
+ return self.widget.text
################################################################
***************
*** 210,213 ****
--- 271,275 ----
def getSelection(self):
+ # FIXME: This should be handled differently
if isDummy(self.widget): return 0
return self.widget.getSelectedIndex()
***************
*** 232,236 ****
def clickHandler(self, event):
! send(self, 'select')
################################################################
--- 294,299 ----
def clickHandler(self, event):
! send(self.proxy, 'select')
! send(self.proxy, 'click')
################################################################
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone? Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390