/usr/share/pyshared/provami/LimitChoice.py is in provami 5.18-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | import wx
from provami.Model import ModelListener
from provami.QueryButton import QueryButton
class LimitChoice(wx.Panel, ModelListener):
def __init__(self, parent, model, id=-1):
wx.Panel.__init__(self, parent, id)
self.model = model
self.model.registerUpdateListener(self)
self.checkBox = wx.CheckBox(self, -1, "Limit results", style=wx.ALIGN_RIGHT)
self.moreButton = wx.Button(self, -1, "More")
self.lessButton = wx.Button(self, -1, "Less")
self.queryButton = QueryButton(self, model)
self.info = wx.StaticText(self, -1, "")
self.Bind(wx.EVT_CHECKBOX, self.onCheckBox, self.checkBox)
self.Bind(wx.EVT_BUTTON, self.onClick, self.lessButton)
self.Bind(wx.EVT_BUTTON, self.onClick, self.moreButton)
box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(self.info, 0, wx.ALIGN_CENTER)
box.Add(wx.StaticText(self, -1, ""), 1)
box.Add(self.checkBox, 0, wx.ALIGN_CENTER)
box.Add(self.lessButton)
box.Add(self.moreButton)
box.Add(self.queryButton)
self.SetSizerAndFit(box)
self.invalidate()
self.hasData("data")
def onClick(self, event):
button = event.GetEventObject()
if button == self.lessButton:
if self.model.resultsMax / 2 < self.model.lowerTruncateThreshold:
self.model.setResultLimit(self.model.lowerTruncateThreshold)
else:
self.model.setResultLimit(self.model.resultsMax / 2)
elif button == self.moreButton:
self.model.setResultLimit(self.model.resultsMax * 2)
self.model.update()
def onCheckBox(self, event):
cb = event.GetEventObject()
if cb.GetValue():
self.model.setResultLimit(self.model.resultsMax)
else:
self.model.setResultLimit(None)
self.model.update()
def invalidate(self):
self.checkBox.Enable(False)
self.lessButton.Enable(False)
self.moreButton.Enable(False)
def hasData(self, what):
if what == "data":
self.checkBox.SetValue(self.model.truncateResults)
if self.model.resultsTruncated:
self.info.SetLabel("%d+ results" % self.model.resultsCount)
self.moreButton.Enable()
else:
self.info.SetLabel("%d results" % self.model.resultsCount)
self.moreButton.Disable()
if self.model.resultsCount < self.model.lowerTruncateThreshold:
self.checkBox.Disable()
self.lessButton.Disable()
self.moreButton.Disable()
else:
self.checkBox.Enable()
if self.model.resultsMax <= self.model.lowerTruncateThreshold:
self.lessButton.Disable()
else:
self.lessButton.Enable()
|