Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

general cleanup from stefan, != None must be is not None etc.

git-svn-id: https://pyjamas.svn.sourceforge.net/svnroot/pyjamas/trunk@785 7a2bd370-bda8-463c-979e-2900ccfb811e
  • Loading branch information...
commit 7b393382efd85c71b4bb61253aafd128d8ba6b26 1 parent 42e7746
lkcl authored
Showing with 184 additions and 178 deletions.
  1. +3 −0  CHANGELOG
  2. +1 −1  doc/book/public/ui_module.txt
  3. +3 −3 examples/infohierarchy/InfoDirectory.py
  4. +1 −1  examples/infohierarchy/Trees.py
  5. +1 −1  examples/kitchensink/Trees.py
  6. +1 −1  examples/mail/MailList.py
  7. +2 −2 examples/shell/Popups.py
  8. +4 −4 examples/showcase/pyColourize.py
  9. +3 −3 examples/showcase/src/Showcase.py
  10. +1 −1  examples/showcase/src/demos_widgets/tree.py
  11. +4 −4 examples/showcase/src/uiHelpers.py
  12. +2 −2 library/browser.py
  13. +8 −6 library/gtk.py
  14. +1 −1  library/pyjamas/DOM.py
  15. +1 −1  library/pyjamas/DeferredCommand.py
  16. +2 −2 library/pyjamas/HTTPRequest.py
  17. +4 −4 library/pyjamas/JSONService.py
  18. +1 −1  library/pyjamas/Window.py
  19. +1 −1  library/pyjamas/platform/DOMPyJS.py
  20. +2 −2 library/pyjamas/platform/HTTPRequestPyJS.py
  21. +2 −2 library/pyjamas/platform/JSONServicePyJS.py
  22. +1 −1  library/pyjamas/ui/AbsolutePanel.py
  23. +2 −2 library/pyjamas/ui/AutoComplete.py
  24. +2 −2 library/pyjamas/ui/CellPanel.py
  25. +1 −1  library/pyjamas/ui/ClickDelegatePanel.py
  26. +1 −1  library/pyjamas/ui/Composite.py
  27. +1 −1  library/pyjamas/ui/DeckPanel.py
  28. +2 −2 library/pyjamas/ui/DialogBox.py
  29. +3 −3 library/pyjamas/ui/DockPanel.py
  30. +1 −1  library/pyjamas/ui/FormPanel.py
  31. +4 −4 library/pyjamas/ui/HTMLPanel.py
  32. +12 −12 library/pyjamas/ui/HTMLTable.py
  33. +3 −3 library/pyjamas/ui/Hidden.py
  34. +2 −2 library/pyjamas/ui/ListBox.py
  35. +16 −16 library/pyjamas/ui/MenuBar.py
  36. +1 −1  library/pyjamas/ui/MenuItem.py
  37. +2 −2 library/pyjamas/ui/PopupPanel.py
  38. +1 −1  library/pyjamas/ui/RootPanel.py
  39. +1 −1  library/pyjamas/ui/ScrollPanel.py
  40. +7 −7 library/pyjamas/ui/SimplePanel.py
  41. +4 −4 library/pyjamas/ui/StackPanel.py
  42. +3 −3 library/pyjamas/ui/TabBar.py
  43. +2 −2 library/pyjamas/ui/TabPanel.py
  44. +2 −2 library/pyjamas/ui/TextBoxBase.py
  45. +2 −2 library/pyjamas/ui/Tooltip.py
  46. +13 −13 library/pyjamas/ui/Tree.py
  47. +16 −16 library/pyjamas/ui/TreeItem.py
  48. +3 −3 library/pyjamas/ui/UIObject.py
  49. +2 −2 library/pyjamas/ui/Widget.py
  50. +4 −4 library/pyjamas/ui/decoratorpanel.py
  51. +6 −6 library/pyjamas/ui/splitpanel.py
  52. +2 −2 pygtkweb/001-gpython.py
  53. +1 −1  pygtkweb/024-colorsel.py
  54. +1 −1  pygtkweb/064-getselection.py
  55. +2 −2 pygtkweb/068-scribblesimple.py
  56. +4 −3 pyjd/hula.py
  57. +5 −5 pyjs/pyjs.py
  58. +1 −1  pyjs/tests/test012.py
View
3  CHANGELOG
@@ -1,6 +1,9 @@
Changes made to Pyjamas since 0.5p1
-----------------------------------
+ * Patch from Stefan Schwarzer to replace != None with is not None
+ and == None with is None, general clean-up.
+
* Got SVG 2D Canvas addonsgallery example working under Pyjamas-Desktop
(Gecko Engine). Requires a patch to XulRunner, for drawImage to work:
https://bugzilla.mozilla.org/show_bug.cgi?id=502234
View
2  doc/book/public/ui_module.txt
@@ -1639,7 +1639,7 @@ class TreeDemo(SimplePanel):
def createItem(self, label, value=None):
item = TreeItem(label)
DOM.setStyleAttribute(item.getElement(), "cursor", "pointer")
- if value != None:
+ if value is not None:
item.setUserObject(value)
return item
View
6 examples/infohierarchy/InfoDirectory.py
@@ -27,7 +27,7 @@
class CollapserPanel(SimplePanel):
def __init__(self, sink):
SimplePanel.__init__(self)
- self.sink = sink
+ self.sink = sink
self.caption = HTML()
self.child = None
self.showing = False
@@ -120,10 +120,10 @@ def doDetachChildren(self):
self.caption.onDetach()
def setWidget(self, widget):
- if self.child != None:
+ if self.child is not None:
self.panel.remove(self.child)
- if widget != None:
+ if widget is not None:
self.panel.setWidget(1, 0, widget)
self.child = widget
View
2  examples/infohierarchy/Trees.py
@@ -74,7 +74,7 @@ def __init__(self, text, children=None):
self.text = text
self.root = '/'
- if children != None:
+ if children is not None:
self.children = children
def pathify(self):
View
2  examples/kitchensink/Trees.py
@@ -107,7 +107,7 @@ def __init__(self, text, children=None):
self.item = None
self.text = text
- if children != None:
+ if children is not None:
self.children = children
View
2  examples/mail/MailList.py
@@ -104,7 +104,7 @@ def selectRow(self, row):
# When a row (other than the first one, which is used as a header) is
# selected, display its associated MailItem.
item = MailItems().getMailItem(self.startIndex + row)
- if (item == None):
+ if item is None:
return
self.styleRow(self.selectedRow, False)
View
4 examples/shell/Popups.py
@@ -123,10 +123,10 @@ def doDetachChildren(self):
self.caption.onDetach()
def setWidget(self, widget):
- if self.child != None:
+ if self.child is not None:
self.panel.remove(self.child)
- if widget != None:
+ if widget is not None:
self.panel.setWidget(1, 0, widget)
self.child = widget
View
8 examples/showcase/pyColourize.py
@@ -238,7 +238,7 @@ def Main():
except:
scheme = None
- if input == None:
+ if input is None:
# if there was no input specified then we try to
# parse ourselves and do it in diffrent flavors.
WebIt(sys.argv[0], '/MyDir/null', _Null, 1)
@@ -263,7 +263,7 @@ def WebAll(sourcePath, outdir=None, colors=None, show=0):
# Then we need to colorize them with WebIt
else:
fileList = WalkDir(sourcePath)
- if fileList != None:
+ if fileList is not None:
for i in fileList:
c+=1
WebIt(i, outdir, colors, show)
@@ -273,11 +273,11 @@ def WebIt(sourcePath, outdir=None, colors=None, show=0):
''' Converts python source to html.
'''
print" Converting %s into HTML" % sourcePath
- if colors == None:
+ if colors is None:
# Default colorscheme
colors = _Dark
# If no outdir is given we use the sourcePath
- if outdir == None:
+ if outdir is None:
htmlPath = sourcePath + '.html'
else:
# If we do give an outdir, and it does
View
6 examples/showcase/src/Showcase.py
@@ -139,7 +139,7 @@ def onTreeItemSelected(self, item):
""" Respond to the user selecting an item in our tree.
"""
demo = item.getUserObject()
- if demo == None:
+ if demo is None:
self.showDemo(None)
else:
self.showDemo(demo['name'])
@@ -154,7 +154,7 @@ def onTreeItemStateChanged(self, item):
def showDemo(self, name):
""" Show the demonstration with the given name.
"""
- if self._curContents != None:
+ if self._curContents is not None:
self._rightPanel.remove(self._curContents)
self._curContents = None
@@ -164,7 +164,7 @@ def showDemo(self, name):
demo = d
break
- if demo != None:
+ if demo is not None:
exampleID = HTMLPanel.createUniqueId()
html = []
View
2  examples/showcase/src/demos_widgets/tree.py
@@ -44,7 +44,7 @@ def __init__(self):
def createItem(self, label, value=None):
item = TreeItem(label)
DOM.setStyleAttribute(item.getElement(), "cursor", "pointer")
- if value != None:
+ if value is not None:
item.setUserObject(value)
return item
View
8 examples/showcase/src/uiHelpers.py
@@ -61,17 +61,17 @@ def indent(contents, all=None, left=None, right=None, top=None, bottom=None,
Upon completion, we return a Panel object contained the wrapped-up
contents.
"""
- if all != None:
+ if all is not None:
left = all
right = all
top = all
bottom = all
- if hIndent != None:
+ if hIndent is not None:
left = hIndent
right = hIndent
- if vIndent != None:
+ if vIndent is not None:
top = vIndent
bottom = vIndent
@@ -198,7 +198,7 @@ def showPanel(self, panelID):
"""
if panelID == self._curPanelID: return
- if self._curPanelID != None:
+ if self._curPanelID is not None:
self._root.remove(self._panels[self._curPanelID])
self._root.add(self._panels[panelID])
View
4 library/browser.py
@@ -2,11 +2,11 @@
class Element:
def __init__(self, tag=None, element=None):
- if tag != None:
+ if tag is not None:
JS('''
this.element = $doc.createElement(tag);
''')
- elif element != None:
+ elif element is not None:
self.element = element
else:
raise Exception("Cannot create Element without tag or element")
View
14 library/gtk.py
@@ -25,7 +25,7 @@
HAS_DEFAULT = 1024
HAS_GRAB = 2048
RC_STYLE = 4096
-COMPOSITE_CHILD = 8192
+COMPOSITE_CHILD = 8192
NO_REPARENT = 16384
APP_PAINTABLE = 32768
RECEIVES_DEFAULT = 65536
@@ -42,6 +42,7 @@
POS_TOP = 4
POS_BOTTOM = 8
+
class GObject:
def __init__(self):
self.callbacks = {}
@@ -402,7 +403,7 @@ def __init__(self, label=None):
Bin.__init__(self)
self.widget_cont.catchEvents(['click'], self)
self.child = None
- if label != None:
+ if label is not None:
self.add(Label(label))
self.widget_int.setStyle('textAlign','center')
@@ -480,7 +481,7 @@ def __init__(self, label=None):
self.box.pack_start(self.check_widget, False)
self.add(self.box)
- if label!=None:
+ if label is not None:
self.label = Label(label)
self.box.pack_start(self.label, False)
self.widget_int.setProperty('className','checkbutton')
@@ -512,7 +513,7 @@ class RadioButton(CheckButton):
def __init__(self, group=None, label=None):
CheckButton.__init__(self, label)
self.check.setProperty('type','radio')
- if group==None:
+ if group is None:
self.group = RadioButton.counter
RadioButton.counter += 1
RadioButton.groups[self.group] = [self]
@@ -567,6 +568,7 @@ def _redraw(self):
self.minwidth = self.img.getWidth()
self.minheight = self.img.getHeight()
+
class Label(Misc):
def __init__(self, str=None):
@@ -642,7 +644,7 @@ def __init__(self, adjustment=None):
self.value = browser.Element('div')
self.value.setStyle('position', 'absolute')
self.widget_cont.append(self.value)
- if adjustment!=None:
+ if adjustment is not None:
self.adjustment = adjustment
else:
self.adjustment = Adjustment()
@@ -1129,7 +1131,7 @@ def _clicked(self, elem, data=None):
def _selected(self, elem, data=None):
act = self.menu.get_active()
- if act!=None:
+ if act is not None:
self.label.set_text(act.label_cont)
def set_menu(self, menu):
View
2  library/pyjamas/DOM.py
@@ -814,7 +814,7 @@ def eventGetCurrentEvent():
def insertListItem(select, item, value, index):
option = createElement("OPTION")
setInnerText(option, item)
- if value != None:
+ if value is not None:
setAttribute(option, "value", value)
if index == -1:
appendChild(select, option)
View
2  library/pyjamas/DeferredCommand.py
@@ -17,7 +17,7 @@ def flushDeferredCommands(self):
current = deferredCommands[0]
del deferredCommands[0]
- if current == None:
+ if current is None:
return
else:
current.execute()
View
4 library/pyjamas/HTTPRequest.py
@@ -13,13 +13,13 @@
class HTTPRequest:
# also callable as: asyncPost(self, url, postData, handler)
def asyncPost(self, user, pwd, url, postData=None, handler=None):
- if postData == None:
+ if postData is None:
return self.asyncPostImpl(None, None, user, pwd, url)
return self.asyncPostImpl(user, pwd, url, postData, handler)
# also callable as: asyncGet(self, url, handler)
def asyncGet(self, user, pwd, url, handler):
- if url == None:
+ if url is None:
return self.asyncGetImpl(None, None, user, pwd)
return self.asyncGetImpl(user, pwd, url, handler)
View
8 library/pyjamas/JSONService.py
@@ -15,7 +15,7 @@
# no stream support
class JSONService:
- def __init__(self, url, handler = None):
+ def __init__(self, url, handler=None):
"""
Create a JSON remote service object. The url is the URL that will receive
POST data with the JSON request. See the JSON-RPC spec for more information.
@@ -28,10 +28,10 @@ def __init__(self, url, handler = None):
self.handler = handler
def callMethod(self, method, params, handler = None):
- if handler == None:
+ if handler is None:
handler = self.handler
- if handler == None:
+ if handler is None:
return self.__sendNotify(method, params)
else:
return self.__sendRequest(method, params, handler)
@@ -40,7 +40,7 @@ def onCompletion(self):
pass
def sendNotify(self, method, params):
- msg = {"id":None, "method":method, "params":params}
+ msg = {"id": None, "method": method, "params": params}
msg_data = dumps(msg)
if not HTTPRequest().asyncPost(self.url, msg_data, self):
return -1
View
2  library/pyjamas/Window.py
@@ -150,7 +150,7 @@ def fireClosingImpl():
ret = None
for listener in closingListeners:
msg = listener.onWindowClosing()
- if ret == None:
+ if ret is None:
ret = msg
return ret
View
2  library/pyjamas/platform/DOMPyJS.py
@@ -799,7 +799,7 @@ def eventGetCurrentEvent():
def insertListItem(select, item, value, index):
option = createElement("OPTION")
setInnerText(option, item)
- if value != None:
+ if value is not None:
setAttribute(option, "value", value)
if index == -1:
appendChild(select, option)
View
4 library/pyjamas/platform/HTTPRequestPyJS.py
@@ -3,13 +3,13 @@ class HTTPRequest:
# also callable as: asyncPost(self, url, postData, handler)
def asyncPost(self, user, pwd, url, postData=None, handler=None,
returnxml=0):
- if postData == None:
+ if postData is None:
return self.asyncPostImpl(None, None, user, pwd, url, returnxml)
return self.asyncPostImpl(user, pwd, url, postData, handler, returnxml)
# also callable as: asyncGet(self, url, handler)
def asyncGet(self, user, pwd, url, handler, returnxml=0):
- if url == None:
+ if url is None:
return self.asyncGetImpl(None, None, user, pwd, returnxml)
return self.asyncGetImpl(user, pwd, url, handler, returnxml)
View
4 library/pyjamas/platform/JSONServicePyJS.py
@@ -15,10 +15,10 @@ def __init__(self, url, handler = None):
self.handler = handler
def callMethod(self, method, params, handler = None):
- if handler == None:
+ if handler is None:
handler = self.handler
- if handler == None:
+ if handler is None:
return self.__sendNotify(method, params)
else:
return self.__sendRequest(method, params, handler)
View
2  library/pyjamas/ui/AbsolutePanel.py
@@ -27,7 +27,7 @@ def __init__(self):
def add(self, widget, left=None, top=None):
ComplexPanel.add(self, widget, self.getElement())
- if left != None:
+ if left is not None:
self.setWidgetPosition(widget, left, top)
def setWidgetPosition(self, widget, left, top):
View
4 library/pyjamas/ui/AutoComplete.py
@@ -121,12 +121,12 @@ def complete(self):
class SimpleAutoCompletionItems:
def __init__(self, items = None):
- if items == None:
+ if items is None:
items = []
self.completions = items
def getCompletionItems(self, match):
- matches = []
+ matches = []
match = match.lower()
for i in range(len(self.completions)):
View
4 library/pyjamas/ui/CellPanel.py
@@ -53,12 +53,12 @@ def setCellHeight(self, widget, height):
def setCellHorizontalAlignment(self, widget, align):
td = self.getWidgetTd(widget)
- if td != None:
+ if td is not None:
DOM.setAttribute(td, "align", align)
def setCellVerticalAlignment(self, widget, align):
td = self.getWidgetTd(widget)
- if td != None:
+ if td is not None:
DOM.setStyleAttribute(td, "verticalAlign", align)
def setCellWidth(self, widget, width):
View
2  library/pyjamas/ui/ClickDelegatePanel.py
@@ -32,7 +32,7 @@ def __init__(self, p, child, cDelegate, kDelegate) :
self.focusablePanel = SimplePanel(Focus.createFocusable())
self.focusablePanel.setWidget(child)
wrapperWidget = p.createTabTextWrapper()
- if wrapperWidget == None:
+ if wrapperWidget is None:
self.initWidget(self.focusablePanel)
else :
wrapperWidget.setWidget(self.focusablePanel)
View
2  library/pyjamas/ui/Composite.py
@@ -21,7 +21,7 @@ def __init__(self):
self.widget = None
def initWidget(self, widget):
- if self.widget != None:
+ if self.widget is not None:
return
widget.removeFromParent()
View
2  library/pyjamas/ui/DeckPanel.py
@@ -64,7 +64,7 @@ def remove(self, widget):
def showWidget(self, index):
self.checkIndex(index)
- if self.visibleWidget != None:
+ if self.visibleWidget is not None:
self.visibleWidget.setVisible(False)
self.visibleWidget = self.getWidget(index)
View
4 library/pyjamas/ui/DialogBox.py
@@ -106,10 +106,10 @@ def doDetachChildren(self):
self.caption.onDetach()
def setWidget(self, widget):
- if self.child != None:
+ if self.child is not None:
self.panel.remove(self.child)
- if widget != None:
+ if widget is not None:
self.panel.setWidget(1, 0, widget)
self.child = widget
View
6 library/pyjamas/ui/DockPanel.py
@@ -53,7 +53,7 @@ def __init__(self):
def add(self, widget, direction):
if direction == self.CENTER:
- if self.center != None:
+ if self.center is not None:
console.error("Only one CENTER widget may be added")
self.center = widget
@@ -179,13 +179,13 @@ def realizeTable(self, beingAdded):
elif layout.direction == self.CENTER:
centerTd = td
- if self.center != None:
+ if self.center is not None:
row = rows[northRow]
DOM.insertChild(row.tr, centerTd, row.center)
self.appendAndMaybeAdopt(centerTd, self.center.getElement(), beingAdded)
def appendAndMaybeAdopt(self, parent, child, beingAdded):
- if beingAdded != None:
+ if beingAdded is not None:
if DOM.compare(child, beingAdded.getElement()):
CellPanel.add(self, beingAdded, parent)
return
View
2  library/pyjamas/ui/FormPanel.py
@@ -66,7 +66,7 @@ def __init__(self, target = None):
self.sinkEvents(Event.ONLOAD)
- if target != None:
+ if target is not None:
self.setTarget(target)
def addFormHandler(self, handler):
View
8 library/pyjamas/ui/HTMLPanel.py
@@ -25,7 +25,7 @@ def __init__(self, html):
def add(self, widget, id):
element = self.getElementById(self.getElement(), id)
- if element == None:
+ if element is None:
# throw new NoSuchElementException()
return
ComplexPanel.add(self, widget, element)
@@ -39,13 +39,13 @@ def createUniqueId():
def getElementById(self, element, id):
element_id = DOM.getAttribute(element, "id")
- if element_id != None and element_id == id:
+ if element_id is not None and element_id == id:
return element
child = DOM.getFirstChild(element)
- while child != None:
+ while child is not None:
ret = self.getElementById(child, id)
- if ret != None:
+ if ret is not None:
return ret
child = DOM.getNextSibling(child)
View
24 library/pyjamas/ui/HTMLTable.py
@@ -43,7 +43,7 @@ def clear(self):
for row in range(self.getRowCount()):
for col in range(self.getCellCount(row)):
child = self.getWidget(row, col)
- if child != None:
+ if child is not None:
self.removeWidget(child)
# assert len(self.widgetMap) == 0
@@ -80,13 +80,13 @@ def getText(self, row, column):
# also callable as getWidget(widgetElement)
def getWidget(self, row, column=None):
- if column == None:
+ if column is None:
key = self.computeKeyForElement(row)
else:
self.checkCellBounds(row, column)
key = self.computeKey(row, column)
- if key == None:
+ if key is None:
return None
return self.widgetMap[key]
@@ -142,18 +142,18 @@ def setCellSpacing(self, spacing):
def setHTML(self, row, column, html):
self.prepareCell(row, column)
td = self.cleanCell(row, column)
- if html != None:
+ if html is not None:
DOM.setInnerHTML(td, html)
def setText(self, row, column, text):
self.prepareCell(row, column)
td = self.cleanCell(row, column)
- if text != None:
+ if text is not None:
DOM.setInnerText(td, text)
def setWidget(self, row, column, widget):
self.prepareCell(row, column)
- if widget == None:
+ if widget is None:
return
widget.removeFromParent()
@@ -172,7 +172,7 @@ def cleanCell(self, row, column):
def computeKey(self, row, column):
element = self.cellFormatter.getRawElement(row, column)
child = DOM.getFirstChild(element)
- if child == None:
+ if child is None:
return None
return self.computeKeyForElement(child)
@@ -206,7 +206,7 @@ def getBodyElement(self):
# also callable as getDOMCellCount(row)
def getDOMCellCount(self, element, row=None):
- if row == None:
+ if row is None:
return self.getDOMCellCountImpl(self.bodyElem, element)
return self.getDOMCellCountImpl(element, row)
@@ -215,7 +215,7 @@ def getDOMCellCountImpl(self, element, row):
# also callable as getDOMRowCount(element)
def getDOMRowCount(self, element=None):
- if element == None:
+ if element is None:
element = self.bodyElem
return self.getDOMRowCountImpl(element)
@@ -224,7 +224,7 @@ def getDOMRowCountImpl(self, element):
def getEventTargetCell(self, event):
td = DOM.eventGetTarget(event)
- while td != None:
+ while td is not None:
if DOM.getAttribute(td, "tagName").lower() == "td":
tr = DOM.getParent(td)
body = DOM.getParent(tr)
@@ -258,10 +258,10 @@ def insertRow(self, beforeRow):
def internalClearCell(self, td):
maybeChild = DOM.getFirstChild(td)
widget = None
- if maybeChild != None:
+ if maybeChild is not None:
widget = self.getWidget(maybeChild)
- if widget != None:
+ if widget is not None:
self.removeWidget(widget)
return True
View
6 library/pyjamas/ui/Hidden.py
@@ -23,10 +23,10 @@ def __init__(self, name=None, value=None):
self.setElement(element)
DOM.setAttribute(element, "type", "hidden")
- if name != None:
+ if name is not None:
self.setName(name)
- if value != None:
+ if value is not None:
self.setValue(value)
def getDefaultValue(self):
@@ -42,7 +42,7 @@ def setDefaultValue(self, defaultValue):
DOM.setAttribute(self.getElement(), "defaultValue", defaultValue)
def setName(self, name):
- if name == None:
+ if name is None:
#throw new NullPointerException("Name cannot be null");
console.error("Name cannot be null")
elif len(name) == 0:
View
4 library/pyjamas/ui/ListBox.py
@@ -59,7 +59,7 @@ def getVisibleItemCount(self):
# also callable as insertItem(item, index)
def insertItem(self, item, value, index=None):
- if index == None:
+ if index is None:
index = value
value = None
DOM.insertListItem(self.getElement(), item, value, index)
@@ -113,7 +113,7 @@ def selectValue(self, value):
def setItemText(self, index, text):
self.checkIndex(index)
- if text == None:
+ if text is None:
console.error("Cannot set an option to have null text")
return
DOM.setOptionText(self.getElement(), text, index)
View
32 library/pyjamas/ui/MenuBar.py
@@ -82,7 +82,7 @@ def onBrowserEvent(self, event):
Widget.onBrowserEvent(self, event)
item = self.findItem(DOM.eventGetTarget(event))
- if item == None:
+ if item is None:
return False
type = DOM.eventGetType(event)
@@ -118,29 +118,29 @@ def setAutoOpen(self, autoOpen):
def closeAllParents(self):
curMenu = self
- while curMenu != None:
+ while curMenu is not None:
curMenu.close()
- if (curMenu.parentMenu == None) and (curMenu.selectedItem != None):
+ if curMenu.parentMenu is None and curMenu.selectedItem is not None:
curMenu.selectedItem.setSelectionStyle(False)
curMenu.selectedItem = None
curMenu = curMenu.parentMenu
def doItemAction(self, item, fireCommand):
- if (self.shownChildMenu != None) and (item.getSubMenu() == self.shownChildMenu):
+ if (self.shownChildMenu is not None) and (item.getSubMenu() == self.shownChildMenu):
return
- if (self.shownChildMenu != None):
+ if (self.shownChildMenu is not None):
self.shownChildMenu.onHide()
self.popup.hide()
- if item.getSubMenu() == None:
+ if item.getSubMenu() is None:
if fireCommand:
self.closeAllParents()
cmd = item.getCommand()
- if cmd != None:
+ if cmd is not None:
DeferredCommand().add(cmd)
return
@@ -160,24 +160,24 @@ def doItemAction(self, item, fireCommand):
self.popup.show()
def onDetach(self):
- if self.popup != None:
+ if self.popup is not None:
self.popup.hide()
Widget.onDetach(self)
def itemOver(self, item):
- if item == None:
- if (self.selectedItem != None) and (self.shownChildMenu == self.selectedItem.getSubMenu()):
+ if item is None:
+ if (self.selectedItem is not None) and (self.shownChildMenu == self.selectedItem.getSubMenu()):
return
self.selectItem(item)
- if item != None:
- if (self.shownChildMenu != None) or (self.parentMenu != None) or self.autoOpen:
+ if item is not None:
+ if (self.shownChildMenu is not None) or (self.parentMenu is not None) or self.autoOpen:
self.doItemAction(item, False)
def close(self):
- if self.parentMenu != None:
+ if self.parentMenu is not None:
self.parentMenu.popup.hide()
def findItem(self, hItem):
@@ -194,7 +194,7 @@ def getItemContainerElement(self):
return DOM.getChild(self.body, 0)
def onHide(self):
- if self.shownChildMenu != None:
+ if self.shownChildMenu is not None:
self.shownChildMenu.onHide()
self.popup.hide()
@@ -206,10 +206,10 @@ def selectItem(self, item):
if item == self.selectedItem:
return
- if self.selectedItem != None:
+ if self.selectedItem is not None:
self.selectedItem.setSelectionStyle(False)
- if item != None:
+ if item is not None:
item.setSelectionStyle(True)
self.selectedItem = item
View
2  library/pyjamas/ui/MenuItem.py
@@ -24,7 +24,7 @@ class MenuItem(UIObject):
# MenuItem(text, asHTML)
def __init__(self, text, asHTML, subMenu=None):
cmd = None
- if subMenu == None:
+ if subMenu is None:
if hasattr(asHTML, "execute"): # text, cmd
cmd = asHTML
asHTML = False
View
4 library/pyjamas/ui/PopupPanel.py
@@ -91,7 +91,7 @@ def onEventPreview(self, event):
and (not self.modal or self._event_targets_popup(event))
)
elif type == "mousedown":
- if DOM.getCaptureElement() != None:
+ if DOM.getCaptureElement() is not None:
return True
if self.autoHide and not self._event_targets_popup(event):
self.hide(True)
@@ -101,7 +101,7 @@ def onEventPreview(self, event):
or type == "click"
or type == "dblclick"
):
- if DOM.getCaptureElement() != None:
+ if DOM.getCaptureElement() is not None:
return True
return not self.modal or self._event_targets_popup(event)
View
2  library/pyjamas/ui/RootPanel.py
@@ -25,7 +25,7 @@
class RootPanelCls(AbsolutePanel):
def __init__(self, element=None):
AbsolutePanel.__init__(self)
- if element == None:
+ if element is None:
element = self.getBodyElement()
self.setElement(element)
View
2  library/pyjamas/ui/ScrollPanel.py
@@ -24,7 +24,7 @@ def __init__(self, child=None):
self.setAlwaysShowScrollBars(False)
self.sinkEvents(Event.ONSCROLL)
- if child != None:
+ if child is not None:
self.setWidget(child)
def addScrollListener(self, listener):
View
14 library/pyjamas/ui/SimplePanel.py
@@ -17,18 +17,18 @@
class SimplePanel(Panel):
"""
- A panel which contains a single widget. Useful if you have an area where
- you'd like to be able to replace the widget with another, or if you need to
- wrap something in a DIV.
+ A panel which contains a single widget. Useful if you have an area where
+ you'd like to be able to replace the widget with another, or if you need to
+ wrap something in a DIV.
"""
def __init__(self, element=None):
Panel.__init__(self)
- if element == None:
+ if element is None:
element = DOM.createDiv()
self.setElement(element)
def add(self, widget):
- if self.getWidget() != None:
+ if self.getWidget() is not None:
console.error("SimplePanel can only contain one child widget")
return
self.setWidget(widget)
@@ -52,10 +52,10 @@ def setWidget(self, widget):
if self.getWidget() == widget:
return
- if self.getWidget() != None:
+ if self.getWidget() is not None:
self.remove(self.getWidget())
- if widget != None:
+ if widget is not None:
self.adopt(widget, self.getContainerElement())
self.children.append(widget)
View
8 library/pyjamas/ui/StackPanel.py
@@ -81,7 +81,7 @@ def onBrowserEvent(self, event):
# also callable as remove(child) and remove(index)
def remove(self, child, index=None):
- if index == None:
+ if index is None:
if isinstance(child, int):
index = child
child = self.getWidget(child)
@@ -136,9 +136,9 @@ def showStack(self, index):
self.setStackVisible(self.visibleStack, True)
def getDividerIndex(self, elem):
- while (elem != None) and not DOM.compare(elem, self.getElement()):
+ while (elem is not None) and not DOM.compare(elem, self.getElement()):
expando = self.indices.get(elem)
- if expando != None:
+ if expando is not None:
return int(expando)
elem = DOM.getParent(elem)
@@ -147,7 +147,7 @@ def getDividerIndex(self, elem):
def setStackVisible(self, index, visible):
tr = DOM.getChild(self.body, (index * 2))
- if tr == None:
+ if tr is None:
return
td = DOM.getFirstChild(tr)
View
6 library/pyjamas/ui/TabBar.py
@@ -56,7 +56,7 @@ def addTabListener(self, listener):
self.tabListeners.append(listener)
def getSelectedTab(self):
- if self.selectedTab == None:
+ if self.selectedTab is None:
return -1
return self.panel.getWidgetIndex(self.selectedTab) - 1
@@ -83,7 +83,7 @@ def createTabTextWrapper(self):
def insertTab(self, text, asHTML, beforeIndex=None):
""" 1st arg can, instead of being 'text', be a widget
"""
- if beforeIndex == None:
+ if beforeIndex is None:
beforeIndex = asHTML
asHTML = False
@@ -161,7 +161,7 @@ def checkTabIndex(self, index):
pass
def setSelectionStyle(self, item, selected):
- if item != None:
+ if item is not None:
if selected:
item.addStyleName("gwt-TabBarItem-selected")
self.setStyleName(DOM.getParent(item.getElement()),
View
4 library/pyjamas/ui/TabPanel.py
@@ -23,7 +23,7 @@ def __init__(self, tabBar=None):
Composite.__init__(self)
self.tab_children = [] # TODO: can self.children be used instead?
self.deck = DeckPanel()
- if tabBar == None:
+ if tabBar is None:
self.tabBar = TabBar()
else:
self.tabBar = tabBar
@@ -41,7 +41,7 @@ def __init__(self, tabBar=None):
self.deck.setStyleName("gwt-TabPanelBottom")
def add(self, widget, tabText=None, asHTML=False):
- if tabText == None:
+ if tabText is None:
console.error("A tabText parameter must be specified with add().")
self.insert(widget, tabText, asHTML, self.getWidgetCount())
View
4 library/pyjamas/ui/TextBoxBase.py
@@ -37,7 +37,7 @@ def addClickListener(self, listener):
self.clickListeners.append(listener)
def cancelKey(self):
- if self.currentEvent != None:
+ if self.currentEvent is not None:
DOM.eventPreventDefault(self.currentEvent)
def getCursorPos(self):
@@ -90,7 +90,7 @@ def setCursorPos(self, pos):
self.setSelectionRange(pos, 0)
def setKey(self, key):
- if self.currentEvent != None:
+ if self.currentEvent is not None:
DOM.eventSetKeyCode(self.currentEvent, key)
def setName(self, name):
View
4 library/pyjamas/ui/Tooltip.py
@@ -75,12 +75,12 @@ def __init__(self, text, show_delay = 1000, hide_delay = 5000, styleName = ""):
self.offsetY = TooltipListener.DEFAULT_OFFSET_Y
def onMouseEnter(self, sender):
- if self.tooltip != None:
+ if self.tooltip is not None:
self.tooltip.hide()
self.tooltip = Tooltip(sender, self.offsetX, self.offsetY, self.text, self.show_delay, self.hide_delay, self.styleName)
def onMouseLeave(self, sender):
- if self.tooltip != None:
+ if self.tooltip is not None:
self.tooltip.hide()
def onMouseMove(self, sender, x, y):
View
26 library/pyjamas/ui/Tree.py
@@ -83,11 +83,11 @@ def clear(self):
self.root.getChild(i-1).remove()
def ensureSelectedItemVisible(self):
- if self.curSelection == None:
+ if self.curSelection is None:
return
parent = self.curSelection.getParentItem()
- while parent != None:
+ while parent is not None:
parent.setState(True)
parent = parent.getParentItem()
@@ -124,7 +124,7 @@ def onBrowserEvent(self, event):
elif type == "blur" or type == "focus":
FocusListener.fireFocusEvent(self.focusListeners, self, event)
elif type == "keydown":
- if self.curSelection == None:
+ if self.curSelection is None:
if self.root.getChildCount() > 0:
self.onSelection(self.root.getChild(0), True)
Widget.onBrowserEvent(self, event)
@@ -196,8 +196,8 @@ def setImageBase(self, baseUrl):
self.root.updateStateRecursive()
def setSelectedItem(self, item, fireEvents=True):
- if item == None:
- if self.curSelection == None:
+ if item is None:
+ if self.curSelection is None:
return
self.curSelection.setSelected(False)
self.curSelection = None
@@ -214,7 +214,7 @@ def treeItemIterator(self):
return accum.__iter__()
def collectElementChain(self, chain, hRoot, hElem):
- if (hElem == None) or DOM.compare(hElem, hRoot):
+ if (hElem is None) or DOM.compare(hElem, hRoot):
return
self.collectElementChain(chain, hRoot, DOM.getParent(hElem))
@@ -225,7 +225,7 @@ def elementClicked(self, root, hElem):
self.collectElementChain(chain, self.getElement(), hElem)
item = self.findItemByChain(chain, 0, root)
- if item != None:
+ if item is not None:
if DOM.compare(item.getImageElement(), hElem):
item.setState(not item.getState(), True)
return True
@@ -249,7 +249,7 @@ def findItemByChain(self, chain, idx, root):
child = root.getChild(i)
if DOM.compare(child.getElement(), hCurElem):
retItem = self.findItemByChain(chain, idx + 1, root.getChild(i))
- if retItem == None:
+ if retItem is None:
return child
return retItem
@@ -257,7 +257,7 @@ def findItemByChain(self, chain, idx, root):
def moveFocus(self, selection):
focusableWidget = selection.getFocusableWidget()
- if focusableWidget != None:
+ if focusableWidget is not None:
focusableWidget.setFocus(True)
DOM.scrollIntoView(focusableWidget.getElement())
else:
@@ -283,7 +283,7 @@ def moveSelectionDown(self, sel, dig):
return
parent = sel.getParentItem()
- if parent == None:
+ if parent is None:
parent = self.root
idx = parent.getChildIndex(sel)
@@ -297,7 +297,7 @@ def moveSelectionDown(self, sel, dig):
def moveSelectionUp(self, sel, climb):
parent = sel.getParentItem()
- if parent == None:
+ if parent is None:
parent = self.root
idx = parent.getChildIndex(sel)
@@ -311,12 +311,12 @@ def onSelection(self, item, fireEvents):
if item == self.root:
return
- if self.curSelection != None:
+ if self.curSelection is not None:
self.curSelection.setSelected(False)
self.curSelection = item
- if self.curSelection != None:
+ if self.curSelection is not None:
self.moveFocus(self.curSelection)
self.curSelection.setSelected(True)
if fireEvents and len(self.listeners):
View
32 library/pyjamas/ui/TreeItem.py
@@ -71,7 +71,7 @@ def __init__(self, html=None):
DOM.setStyleAttribute(self.childSpanElem, "whiteSpace", "nowrap")
self.setStyleName(self.contentElem, "gwt-TreeItem", True)
- if html != None:
+ if html is not None:
if isinstance(html, str):
self.setHTML(html)
else:
@@ -83,7 +83,7 @@ def addItem(self, item):
#if not item.getTree:
item = TreeItem(item)
- if (item.getParentItem() != None) or (item.getTree() != None):
+ if (item.getParentItem() is not None) or (item.getTree() is not None):
item.remove()
item.setTree(self.tree)
@@ -127,7 +127,7 @@ def getUserObject(self):
return self.userObject
def getWidget(self):
- if self.contentPanel == None:
+ if self.contentPanel is None:
return None
return self.contentPanel.getWidget()
@@ -136,9 +136,9 @@ def isSelected(self):
return self.selected
def remove(self):
- if self.parent != None:
+ if self.parent is not None:
self.parent.removeItem(self)
- elif self.tree != None:
+ elif self.tree is not None:
self.tree.removeItem(self)
def removeItem(self, item):
@@ -190,21 +190,21 @@ def setWidget(self, widget):
self.contentPanel.setWidget(widget)
def clearContentPanel(self):
- if self.contentPanel != None:
+ if self.contentPanel is not None:
child = self.contentPanel.getWidget()
- if child != None:
+ if child is not None:
self.contentPanel.remove(child)
- if self.tree != None:
+ if self.tree is not None:
self.tree.disown(self.contentPanel)
self.contentPanel = None
def ensureContentPanel(self):
- if self.contentPanel == None:
+ if self.contentPanel is None:
DOM.setInnerHTML(self.contentElem, "")
self.contentPanel = TreeContentPanel(self.contentElem)
self.contentPanel.setTreeItem(self)
- if self.getTree() != None:
+ if self.getTree() is not None:
self.tree.adopt(self.contentPanel)
def addTreeItems(self, accum):
@@ -228,7 +228,7 @@ def getTreeTop(self):
item = self
ret = 0
- while item != None:
+ while item is not None:
ret += DOM.getIntAttribute(item.getElement(), "offsetTop")
item = item.getParentItem()
@@ -241,7 +241,7 @@ def getFocusableWidget(self):
return None
def imgSrc(self, img):
- if self.tree == None:
+ if self.tree is None:
return img
src = self.tree.getImageBase() + img
return src
@@ -253,18 +253,18 @@ def setTree(self, tree):
if self.tree == tree:
return
- if self.tree != None:
+ if self.tree is not None:
if self.tree.getSelectedItem() == self:
self.tree.setSelectedItem(None)
- if self.contentPanel != None:
+ if self.contentPanel is not None:
self.tree.disown(self.contentPanel)
self.tree = tree
for child in self.children:
child.setTree(tree)
self.updateState()
- if tree != None and self.contentPanel != None:
+ if tree is not None and self.contentPanel is not None:
tree.adopt(self.contentPanel)
def updateState(self):
@@ -289,7 +289,7 @@ def updateStateRecursive(self):
class RootTreeItem(TreeItem):
def addItem(self, item):
- if (item.getParentItem() != None) or (item.getTree() != None):
+ if (item.getParentItem() is not None) or (item.getTree() is not None):
item.remove()
item.setTree(self.getTree())
View
6 library/pyjamas/ui/UIObject.py
@@ -17,7 +17,7 @@
def setStyleName(element, style, add):
oldStyle = DOM.getAttribute(element, "className")
- if oldStyle == None:
+ if oldStyle is None:
oldStyle = ""
idx = oldStyle.find(style)
@@ -132,7 +132,7 @@ def setStyleName(self, element, style=None, add=True):
associated with this UIObject's element with the given parameter. Otherwise,
this is assumed to be a worker function for addStyleName and removeStyleName."""
# emulate setStyleName(self, style)
- if style == None:
+ if style is None:
style = element
DOM.setAttribute(self.element, "className", style)
return
@@ -177,7 +177,7 @@ def setVisible(self, element, visible=None):
given, the self.element is used. This modifies the CSS property 'display',
which means that an invisible element not only is not drawn, but doesn't
occupy any space on the page."""
- if visible==None:
+ if visible is None:
visible = element
element = self.element
View
4 library/pyjamas/ui/Widget.py
@@ -100,8 +100,8 @@ def setParent(self, parent):
assumes we are being attached also and calls onAttach()."""
oldparent = self.parent
self.parent = parent
- if parent == None:
- if oldparent != None and oldparent.attached:
+ if parent is None:
+ if oldparent is not None and oldparent.attached:
self.onDetach()
elif parent.attached:
self.onAttach()
View
8 library/pyjamas/ui/decoratorpanel.py
@@ -62,7 +62,7 @@ def __init__(self, rowStyles=None,
@param containerIndex the index of the container row
"""
- if rowStyles == None:
+ if rowStyles is None:
rowStyles = self.DEFAULT_ROW_STYLENAMES
SimplePanel.__init__(self, DOM.createTable())
@@ -161,10 +161,10 @@ class DecoratorTitledPanel(DecoratorPanel):
def __init__(self, title, titleStyle=None, imgStyle=None,
rowStyles=None,
containerIndex=2, titleIndex=1) :
- if rowStyles == None:
- rowStyles = [ "top", "top2", "middle", "bottom" ]
+ if rowStyles is None:
+ rowStyles = ["top", "top2", "middle", "bottom"]
- if titleStyle == None:
+ if titleStyle is None:
titleStyle = "title"
DecoratorPanel.__init__(self, rowStyles, containerIndex)
View
12 library/pyjamas/ui/splitpanel.py
@@ -136,9 +136,9 @@ def setElemWidth(self, elem, width):
DOM.setStyleAttribute(elem, "width", width)
def add(self, w):
- if self.getWidget(0) == None:
+ if self.getWidget(0) is None:
self.setWidget(0, w)
- elif self.getWidget(1) == None:
+ elif self.getWidget(1) is None:
self.setWidget(1, w)
#else:
# raise IllegalStateException("A Splitter can only contain two Widgets.")
@@ -172,7 +172,7 @@ def onBrowserEvent(self, event):
elif typ == 'mousemove':
if self.isResizing:
- #assert DOM.getCaptureElement() != None
+ #assert DOM.getCaptureElement() is not None
self.onSplitterResize(DOM.eventGetClientX(event) -
self.getAbsoluteLeft(),
DOM.eventGetClientY(event) - self.getAbsoluteTop())
@@ -224,11 +224,11 @@ def setWidget(self, index, w):
if oldWidget == w:
return
- if (w != None):
+ if w is not None:
w.removeFromParent()
# Remove the old child.
- if (oldWidget != None):
+ if oldWidget is not None:
# Orphan old.
self.disown(oldWidget)
# Physical detach old.
@@ -237,7 +237,7 @@ def setWidget(self, index, w):
# Logical detach old / attach new.
self.widgets[index] = w
- if (w != None):
+ if w is not None:
# Physical attach new.
DOM.appendChild(self.elements[index], w.getElement())
View
4 pygtkweb/001-gpython.py
@@ -112,8 +112,8 @@ def code_exec (self):
"""Execute waiting code. Called every timeout period."""
self.ready.acquire ()
if self._kill: gtk.main_quit ()
- if self.new_cmd != None:
- self.ready.notify ()
+ if self.new_cmd is not None:
+ self.ready.notify()
self.cmd = self.cmd + self.new_cmd
self.new_cmd = None
try:
View
2  pygtkweb/024-colorsel.py
@@ -27,7 +27,7 @@ def area_event(self, widget, event):
handled = True
# Create color selection dialog
- if self.colorseldlg == None:
+ if self.colorseldlg is None:
self.colorseldlg = gtk.ColorSelectionDialog(
"Select background color")
View
2  pygtkweb/064-getselection.py
@@ -32,7 +32,7 @@ def selection_received(self, widget, selection_data, data):
targets = selection_data.get_targets()
for target in targets:
name = str(target)
- if name != None:
+ if name is not None:
print "%s" % name
else:
print "(bad target)"
View
4 pygtkweb/068-scribblesimple.py
@@ -55,7 +55,7 @@ def draw_brush(widget, x, y):
widget.queue_draw_area(rect[0], rect[1], rect[2], rect[3])
def button_press_event(widget, event):
- if event.button == 1 and pixmap != None:
+ if event.button == 1 and pixmap is not None:
draw_brush(widget, event.x, event.y)
return True
@@ -67,7 +67,7 @@ def motion_notify_event(widget, event):
y = event.y
state = event.state
- if state & gtk.gdk.BUTTON1_MASK and pixmap != None:
+ if state & gtk.gdk.BUTTON1_MASK and pixmap is not None:
draw_brush(widget, x, y)
return True
View
7 pyjd/hula.py
@@ -53,7 +53,7 @@ def __init__(self, application, appdir):
def load_app(self):
uri = self.application
- if uri.find("://") == -1:
+ if uri.find(":") == -1:
# assume file
uri = 'file://'+os.path.abspath(uri)
@@ -125,9 +125,10 @@ def is_loaded():
global wv
return wv.already_initialised
-def run(one_event=False):
+def run(one_event=False, block=True):
if one_event:
- gtk.main_iteration()
+ if block or gtk.events_pending():
+ gtk.main_iteration()
else:
gtk.main()
View
10 pyjs/pyjs.py
@@ -401,7 +401,7 @@ def dedent(self):
return self.spacing()
def push_options(self):
- self.option_stack.append((\
+ self.option_stack.append((\
self.debug, self.print_statements, self.function_argument_checking,
self.attribute_checking, self.source_tracking,
self.line_tracking, self.store_source,
@@ -1477,7 +1477,7 @@ def _stmt(self, node, current_klass):
def get_start_line(self, node, lineno):
if node:
- if hasattr(node, "lineno") and node.lineno != None and node.lineno < lineno:
+ if hasattr(node, "lineno") and node.lineno is not None and node.lineno < lineno:
lineno = node.lineno
if hasattr(node, 'getChildren'):
for n in node.getChildren():
@@ -1488,7 +1488,7 @@ def get_line_trace(self, node):
lineNum1 = "Unknown"
srcLine = ""
if hasattr(node, "lineno"):
- if node.lineno != None:
+ if node.lineno is not None:
lineNum2 = node.lineno
lineNum1 = self.get_start_line(node, lineNum2)
srcLine = self.src[min(lineNum1, len(self.src))-1].strip()
@@ -1952,9 +1952,9 @@ def _slice(self, node, current_klass):
if node.flags == "OP_APPLY":
lower = "null"
upper = "null"
- if node.lower != None:
+ if node.lower is not None:
lower = self.expr(node.lower, current_klass)
- if node.upper != None:
+ if node.upper is not None:
upper = self.expr(node.upper, current_klass)
return "pyjslib.slice(" + self.expr(node.expr, current_klass) + ", " + lower + ", " + upper + ")"
else:
View
2  pyjs/tests/test012.py
@@ -7,7 +7,7 @@ def __init__(self):
def setParent(self, parent):
self.parent = parent
- if parent == None:
+ if parent is None:
self.onDetach()
elif parent.attached:
self.onAttach()
Please sign in to comment.
Something went wrong with that request. Please try again.