Changeset 206
- Timestamp:
- 04/26/08 13:53:09 (9 months ago)
- Files:
-
- packages/vanilla/trunk/Lib/vanilla/__init__.py (modified) (3 diffs)
- packages/vanilla/trunk/Lib/vanilla/dialogs.py (modified) (5 diffs)
- packages/vanilla/trunk/Lib/vanilla/nsSubclasses.py (modified) (1 diff)
- packages/vanilla/trunk/Lib/vanilla/test/__init__.py (modified) (1 diff)
- packages/vanilla/trunk/Lib/vanilla/test/testAll.py (modified) (14 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaBase.py (modified) (2 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaBox.py (modified) (8 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaButton.py (modified) (20 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaCheckBox.py (modified) (13 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaColorWell.py (modified) (5 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaComboBox.py (modified) (6 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaDrawer.py (modified) (5 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaEditText.py (modified) (7 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaGroup.py (modified) (3 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaImageView.py (modified) (2 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaLevelIndicator.py (modified) (16 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaList.py (modified) (34 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaPopUpButton.py (modified) (5 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaProgressBar.py (modified) (7 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaProgressSpinner.py (modified) (2 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaRadioGroup.py (modified) (5 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaScrollView.py (modified) (3 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaSearchBox.py (modified) (6 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaSlider.py (modified) (9 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaSplitView.py (modified) (1 diff)
- packages/vanilla/trunk/Lib/vanilla/vanillaTabs.py (modified) (8 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaTextBox.py (modified) (6 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaTextEditor.py (modified) (6 diffs)
- packages/vanilla/trunk/Lib/vanilla/vanillaWindows.py (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
packages/vanilla/trunk/Lib/vanilla/__init__.py
r170 r206 25 25 26 26 __all__ = [ 27 'VanillaBaseObject', 'VanillaBaseControl', 'VanillaError',28 'Box', 'HorizontalLine', 'VerticalLine',29 'Button', 'SquareButton', 'ImageButton', 'HelpButton',30 'CheckBox',31 'ColorWell',32 'ComboBox',33 'Drawer',34 'EditText',35 'Group',36 'ImageView',37 'List', 'CheckBoxListCell', 'SliderListCell',38 'PopUpButton',39 'ProgressBar',40 'ProgressSpinner',41 'RadioGroup',42 'ScrollView',43 'SearchBox',44 'SecureEditText',45 'SegmentedButton',46 'Slider',47 'SplitView',48 'Tabs',49 'TextBox',50 'TextEditor',51 'Window', 'FloatingWindow', 'Sheet'27 "VanillaBaseObject", "VanillaBaseControl", "VanillaError", 28 "Box", "HorizontalLine", "VerticalLine", 29 "Button", "SquareButton", "ImageButton", "HelpButton", 30 "CheckBox", 31 "ColorWell", 32 "ComboBox", 33 "Drawer", 34 "EditText", 35 "Group", 36 "ImageView", 37 "List", "CheckBoxListCell", "SliderListCell", 38 "PopUpButton", 39 "ProgressBar", 40 "ProgressSpinner", 41 "RadioGroup", 42 "ScrollView", 43 "SearchBox", 44 "SecureEditText", 45 "SegmentedButton", 46 "Slider", 47 "SplitView", 48 "Tabs", 49 "TextBox", 50 "TextEditor", 51 "Window", "FloatingWindow", "Sheet" 52 52 ] 53 53 … … 55 55 try: 56 56 from vanillaLevelIndicator import LevelIndicator, LevelIndicatorListCell 57 __all__.append( 'LevelIndicator')58 __all__.append( 'LevelIndicatorListCell')57 __all__.append("LevelIndicator") 58 __all__.append("LevelIndicatorListCell") 59 59 except (ImportError, NameError): 60 60 pass … … 63 63 try: 64 64 from vanillaGradientButton import GradientButton 65 __all__.append( 'GradientButton')65 __all__.append("GradientButton") 66 66 except (ImportError, NameError): 67 67 pass packages/vanilla/trunk/Lib/vanilla/dialogs.py
r95 r206 11 11 12 12 def initWithMessageText_informativeText_alertStyle_buttonTitlesValues_window_resultCallback_(self, 13 messageText= '', informativeText='', alertStyle=NSInformationalAlertStyle, buttonTitlesValues=[], parentWindow=None, resultCallback=None):13 messageText="", informativeText="", alertStyle=NSInformationalAlertStyle, buttonTitlesValues=[], parentWindow=None, resultCallback=None): 14 14 15 15 self = super(BaseMessageDialog, self).init() … … 49 49 self._resultCallback(self._value) 50 50 51 alertDidEnd_returnCode_contextInfo_ = selector(alertDidEnd_returnCode_contextInfo_, signature= 'v@:@i@')51 alertDidEnd_returnCode_contextInfo_ = selector(alertDidEnd_returnCode_contextInfo_, signature="v@:@i@") 52 52 53 53 def windowWillClose_(self, notification): … … 169 169 return window 170 170 171 def message(messageText= '', informativeText='', alertStyle=NSInformationalAlertStyle, parentWindow=None, resultCallback=None):171 def message(messageText="", informativeText="", alertStyle=NSInformationalAlertStyle, parentWindow=None, resultCallback=None): 172 172 parentWindow = _unwrapWindow(parentWindow) 173 173 alert = BaseMessageDialog.alloc().initWithMessageText_informativeText_alertStyle_buttonTitlesValues_window_resultCallback_( … … 176 176 return 1 177 177 178 def askYesNoCancel(messageText= '', informativeText='', alertStyle=NSInformationalAlertStyle, parentWindow=None, resultCallback=None):178 def askYesNoCancel(messageText="", informativeText="", alertStyle=NSInformationalAlertStyle, parentWindow=None, resultCallback=None): 179 179 parentWindow = _unwrapWindow(parentWindow) 180 180 alert = BaseMessageDialog.alloc().initWithMessageText_informativeText_alertStyle_buttonTitlesValues_window_resultCallback_( … … 183 183 return alert._value 184 184 185 def askYesNo(messageText= '', informativeText='', alertStyle=NSInformationalAlertStyle, parentWindow=None, resultCallback=None):185 def askYesNo(messageText="", informativeText="", alertStyle=NSInformationalAlertStyle, parentWindow=None, resultCallback=None): 186 186 parentWindow = _unwrapWindow(parentWindow) 187 187 alert = BaseMessageDialog.alloc().initWithMessageText_informativeText_alertStyle_buttonTitlesValues_window_resultCallback_( packages/vanilla/trunk/Lib/vanilla/nsSubclasses.py
r1 r206 23 23 _subclasses = {} 24 24 def getNSSubclass(classOrName=None): 25 """Return a subclass of a given Objective-C class. 25 """ 26 Return a subclass of a given Objective-C class. 26 27 This subclass allows us to store a weakref to a Vanilla wrapper 27 28 object. This way we can always get back at it. Mainly meant to packages/vanilla/trunk/Lib/vanilla/test/__init__.py
r1 r206 1 # dir for vanilla tests.packages/vanilla/trunk/Lib/vanilla/test/testAll.py
r1 r206 10 10 iconPath = os.path.join(vanillaPath, "Data", "testIcon.tif") 11 11 12 sizeStyles = [ 'regular', 'small', 'mini']12 sizeStyles = ["regular", "small", "mini"] 13 13 14 14 listOptions = sys.modules.keys() … … 17 17 18 18 class BaseTest(object): 19 19 20 20 def drawGrid(self): 21 21 w, h = self.w.getPosSize()[2:] … … 24 24 if i == 0: 25 25 continue 26 attrName = 'vline%d'% i26 attrName = "vline%d" % i 27 27 line = VerticalLine((increment*i, 0, 1, h)) 28 28 setattr(self.w, attrName, line) … … 30 30 if i == 0: 31 31 continue 32 attrName = 'hline%d'% i32 attrName = "hline%d" % i 33 33 line = HorizontalLine((0, increment*i, w, 1)) 34 34 setattr(self.w, attrName, line) 35 35 36 36 def basicCallback(self, sender): 37 37 print sender 38 38 39 39 def titleCallback(self, sender): 40 40 print sender, sender.getTitle() 41 41 42 42 def getCallback(self, sender): 43 43 print sender, sender.get() … … 45 45 46 46 class WindowTest(BaseTest): 47 47 48 48 def __init__(self, textured=False): 49 49 self.textured = textured 50 self.w = Window((200, 130), 'Window Test', textured=textured)51 self.w.windowButton = Button((10, 10, -10, 20), 'Window', callback=self.windowCallback)52 self.w.sheetButton = Button((10, 40, -10, 20), 'Sheet', callback=self.sheetCallback)53 self.w.drawerButton = Button((10, 70, -10, 20), 'Drawer', callback=self.drawerCallback)54 self.w.floatButton = Button((10, 100, -10, 20), 'Floating Window', callback=self.floatCallback)55 self.w.open() 56 50 self.w = Window((200, 130), "Window Test", textured=textured) 51 self.w.windowButton = Button((10, 10, -10, 20), "Window", callback=self.windowCallback) 52 self.w.sheetButton = Button((10, 40, -10, 20), "Sheet", callback=self.sheetCallback) 53 self.w.drawerButton = Button((10, 70, -10, 20), "Drawer", callback=self.drawerCallback) 54 self.w.floatButton = Button((10, 100, -10, 20), "Floating Window", callback=self.floatCallback) 55 self.w.open() 56 57 57 def windowCallback(self, sender): 58 58 WindowTest(not self.textured) 59 59 60 60 def sheetCallback(self, sender): 61 61 self.sheet = Sheet((300, 100), self.w) 62 self.sheet.closeButton = Button((10, -30, -10, 20), 'Close', callback=self._closeSheet)62 self.sheet.closeButton = Button((10, -30, -10, 20), "Close", callback=self._closeSheet) 63 63 self.sheet.open() 64 64 65 65 def _closeSheet(self, sender): 66 66 self.sheet.close() 67 67 del self.sheet 68 68 69 69 def drawerCallback(self, sender): 70 if not hasattr(self, 'drawer1'):71 self.drawer1 = Drawer((50, 50), self.w, preferredEdge= 'left')72 self.drawer2 = Drawer((50, 50), self.w, preferredEdge= 'top')73 self.drawer3 = Drawer((50, 50), self.w, preferredEdge= 'right')74 self.drawer4 = Drawer((50, 50), self.w, preferredEdge= 'bottom')70 if not hasattr(self, "drawer1"): 71 self.drawer1 = Drawer((50, 50), self.w, preferredEdge="left") 72 self.drawer2 = Drawer((50, 50), self.w, preferredEdge="top") 73 self.drawer3 = Drawer((50, 50), self.w, preferredEdge="right") 74 self.drawer4 = Drawer((50, 50), self.w, preferredEdge="bottom") 75 75 self.drawer1.toggle() 76 76 self.drawer2.toggle() 77 77 self.drawer3.toggle() 78 78 self.drawer4.toggle() 79 79 80 80 def floatCallback(self, sender): 81 81 floater = FloatingWindow((100, 100)) … … 84 84 85 85 class TextTest(BaseTest): 86 87 def __init__(self, drawGrid=False): 88 self.w = Window((440, 190), 'Text Test')89 # 86 87 def __init__(self, drawGrid=False): 88 self.w = Window((440, 190), "Text Test") 89 90 90 _top = 10 91 91 top = _top 92 # 93 textSizeStyles = [( 'regular', 17), ('small', 14), ('mini', 11)]92 93 textSizeStyles = [("regular", 17), ("small", 14), ("mini", 11)] 94 94 for sizeStyle, height in textSizeStyles: 95 attrName = 'TextBox_%s'% sizeStyle95 attrName = "TextBox_%s" % sizeStyle 96 96 button = TextBox((10, top, 100, height), attrName, sizeStyle=sizeStyle) 97 97 setattr(self.w, attrName, button) 98 98 top += 30 99 # 100 textSizeStyles = [( 'regular', 22), ('small', 19), ('mini', 15)]99 100 textSizeStyles = [("regular", 22), ("small", 19), ("mini", 15)] 101 101 for sizeStyle, height in textSizeStyles: 102 attrName = 'SearchBox_%s'% sizeStyle102 attrName = "SearchBox_%s" % sizeStyle 103 103 button = SearchBox((10, top, 100, height), attrName, callback=self.getCallback, sizeStyle=sizeStyle) 104 104 setattr(self.w, attrName, button) 105 105 top += 30 106 # 106 107 107 top = _top 108 textSizeStyles = [( 'regular', 22), ('small', 19), ('mini', 16)]108 textSizeStyles = [("regular", 22), ("small", 19), ("mini", 16)] 109 109 for sizeStyle, height in textSizeStyles: 110 attrName = 'EditText_%s'% sizeStyle110 attrName = "EditText_%s" % sizeStyle 111 111 button = EditText((120, top, 100, height), attrName, callback=self.getCallback, sizeStyle=sizeStyle) 112 112 setattr(self.w, attrName, button) 113 113 top += 30 114 # 115 textSizeStyles = [( 'regular', 21), ('small', 17), ('mini', 14)]114 115 textSizeStyles = [("regular", 21), ("small", 17), ("mini", 14)] 116 116 for sizeStyle, height in textSizeStyles: 117 attrName = 'ComboBox_%s'% sizeStyle117 attrName = "ComboBox_%s" % sizeStyle 118 118 button = ComboBox((120, top, 100, height), items=listOptions, callback=self.getCallback, sizeStyle=sizeStyle) 119 119 setattr(self.w, attrName, button) 120 120 top += 30 121 # 121 122 122 self.w.TextEditor = TextEditor((240, 10, 190, 170), sys.copyright, callback=self.getCallback) 123 # 123 124 124 if drawGrid: 125 125 self.drawGrid() 126 # 126 127 127 self.w.open() 128 128 129 129 130 130 class ButtonTest(BaseTest): 131 132 def __init__(self, drawGrid=False): 133 self.w = Window((440, 690), 'Button Test')134 # 131 132 def __init__(self, drawGrid=False): 133 self.w = Window((440, 690), "Button Test") 134 135 135 _top = 10 136 136 top = _top 137 # 138 buttonSizeStyles = [( 'regular', 20), ('small', 17), ('mini', 14)]137 138 buttonSizeStyles = [("regular", 20), ("small", 17), ("mini", 14)] 139 139 for sizeStyle, height in buttonSizeStyles: 140 attrName = 'Button_%s'% sizeStyle140 attrName = "Button_%s" % sizeStyle 141 141 button = Button((10, top, 150, height), attrName, callback=self.titleCallback, sizeStyle=sizeStyle) 142 142 setattr(self.w, attrName, button) 143 143 top += 30 144 # 144 145 145 height = 20 146 146 for sizeStyle in sizeStyles: 147 attrName = 'SquareButton_%s'% sizeStyle147 attrName = "SquareButton_%s" % sizeStyle 148 148 button = SquareButton((10, top, 150, height), attrName, callback=self.titleCallback, sizeStyle=sizeStyle) 149 149 setattr(self.w, attrName, button) 150 150 top += 30 151 # 152 settings = [(None, False, 'top'),153 (None, True, 'top'),154 ( 'bop', True, 'top'),155 ( 'bop', True, 'bottom'),156 ( 'bop', True, 'left'),157 ( 'bop', True, 'right'),]151 152 settings = [(None, False, "top"), 153 (None, True, "top"), 154 ("bop", True, "top"), 155 ("bop", True, "bottom"), 156 ("bop", True, "left"), 157 ("bop", True, "right"),] 158 158 for title, bordered, imagePosition in settings: 159 attrName = 'ImageButton_%s_%s_%s'% (title, bordered, imagePosition)159 attrName = "ImageButton_%s_%s_%s" % (title, bordered, imagePosition) 160 160 button = ImageButton((10, top, 150, 50), title=title, imagePath=iconPath, bordered=bordered, imagePosition=imagePosition, callback=self.basicCallback) 161 161 setattr(self.w, attrName, button) 162 162 top += 60 163 # 164 segmentedControlSizeStyles = [( 'regular', 20), ('small', 17), ('mini', 14)]165 descriptions = [{ 'title':'One'}, {'title':'Two'}, {'title':'3', 'enabled':False}]163 164 segmentedControlSizeStyles = [("regular", 20), ("small", 17), ("mini", 14)] 165 descriptions = [{"title":"One"}, {"title":"Two"}, {"title":"3", "enabled":False}] 166 166 for sizeStyle, height in segmentedControlSizeStyles: 167 attrName = 'SegmentedControl_%s'% sizeStyle168 button = Segmented Control((10, top, 150, height), descriptions, callback=None, sizeStyle=sizeStyle)169 setattr(self.w, attrName, button) 170 top += 30 171 # 167 attrName = "SegmentedButton_%s" % sizeStyle 168 button = SegmentedButton((10, top, 150, height), descriptions, callback=None, sizeStyle=sizeStyle) 169 setattr(self.w, attrName, button) 170 top += 30 171 172 172 top = _top 173 173 _left = 170 174 174 left = _left 175 175 height = 100 176 # 177 sliderSizeStyles = [( 'regular', 15), ('small', 11), ('mini', 10)]176 177 sliderSizeStyles = [("regular", 15), ("small", 11), ("mini", 10)] 178 178 for sizeStyle, width in sliderSizeStyles: 179 attrName = 'VSlider_noTicks_%s'% sizeStyle179 attrName = "VSlider_noTicks_%s" % sizeStyle 180 180 button = Slider((left, top, width, height), 0, 100, callback=self.getCallback, sizeStyle=sizeStyle) 181 181 setattr(self.w, attrName, button) 182 182 left += 30 183 sliderSizeStyles = [( 'regular', 23), ('small', 17), ('mini', 16)]183 sliderSizeStyles = [("regular", 23), ("small", 17), ("mini", 16)] 184 184 for sizeStyle, width in sliderSizeStyles: 185 attrName = 'VSlider_rightTicks_%s'% sizeStyle185 attrName = "VSlider_rightTicks_%s" % sizeStyle 186 186 button = Slider((left, top, width, height), 0, 100, tickMarkCount=10, callback=self.getCallback, sizeStyle=sizeStyle) 187 187 setattr(self.w, attrName, button) 188 188 left += 30 189 189 for sizeStyle, width in sliderSizeStyles: 190 attrName = 'VSlider_leftTicks_%s'% sizeStyle190 attrName = "VSlider_leftTicks_%s" % sizeStyle 191 191 button = Slider((left, top, width, height), 0, 100, tickMarkCount=10, callback=self.getCallback, sizeStyle=sizeStyle) 192 button.setTickMarkPosition( 'left')192 button.setTickMarkPosition("left") 193 193 setattr(self.w, attrName, button) 194 194 left += 30 195 # 195 196 196 left = _left 197 197 width = 260 198 198 top = 130 199 sliderSizeStyles = [( 'regular', 15), ('small', 12), ('mini', 10)]199 sliderSizeStyles = [("regular", 15), ("small", 12), ("mini", 10)] 200 200 for sizeStyle, height in sliderSizeStyles: 201 attrName = 'HSlider_noTicks_%s'% sizeStyle201 attrName = "HSlider_noTicks_%s" % sizeStyle 202 202 button = Slider((left, top, width, height), 0, 100, callback=self.getCallback, sizeStyle=sizeStyle) 203 203 setattr(self.w, attrName, button) 204 204 top += 30 205 sliderSizeStyles = [( 'regular', 24), ('small', 17), ('mini', 16)]205 sliderSizeStyles = [("regular", 24), ("small", 17), ("mini", 16)] 206 206 for sizeStyle, height in sliderSizeStyles: 207 attrName = 'HSlider_belowTicks_%s'% sizeStyle207 attrName = "HSlider_belowTicks_%s" % sizeStyle 208 208 button = Slider((left, top, width, height), 0, 100, tickMarkCount=30, callback=self.getCallback, sizeStyle=sizeStyle) 209 209 setattr(self.w, attrName, button) 210 210 top += 30 211 211 for sizeStyle, height in sliderSizeStyles: 212 attrName = 'HSlider_aboveTicks_%s'% sizeStyle212 attrName = "HSlider_aboveTicks_%s" % sizeStyle 213 213 button = Slider((left, top, width, height), 0, 100, tickMarkCount=30, callback=self.getCallback, sizeStyle=sizeStyle) 214 button.setTickMarkPosition( 'top')215 setattr(self.w, attrName, button) 216 top += 30 217 # 214 button.setTickMarkPosition("top") 215 setattr(self.w, attrName, button) 216 top += 30 217 218 218 _top = top 219 # 220 popupSizeStyles = [( 'regular', 20), ('small', 17), ('mini', 15)]219 220 popupSizeStyles = [("regular", 20), ("small", 17), ("mini", 15)] 221 221 width = 120 222 222 for sizeStyle, height in popupSizeStyles: 223 attrName = 'PopUpButton_%s'% sizeStyle223 attrName = "PopUpButton_%s" % sizeStyle 224 224 button = PopUpButton((left, top, width, height), listOptions, callback=self.getCallback, sizeStyle=sizeStyle) 225 225 setattr(self.w, attrName, button) 226 226 top += 30 227 # 227 228 228 top = _top 229 checkboxSizeStyles = [( 'regular', 22), ('small', 18), ('mini', 11)]229 checkboxSizeStyles = [("regular", 22), ("small", 18), ("mini", 11)] 230 230 width = 125 231 231 left = 300 232 232 for sizeStyle, height in popupSizeStyles: 233 attrName = 'CheckBox_%s'% sizeStyle233 attrName = "CheckBox_%s" % sizeStyle 234 234 button = CheckBox((left, top, width, height), attrName, callback=self.getCallback, sizeStyle=sizeStyle) 235 235 setattr(self.w, attrName, button) 236 236 top += 30 237 # 237 238 238 # only add the ListIndicator tests if the controls are available 239 239 try: 240 240 _top = top 241 # 241 242 242 left = _left 243 243 width = 120 244 self.w.DLevelIndicator = LevelIndicator((left, top, width, 18), style= 'discrete',244 self.w.DLevelIndicator = LevelIndicator((left, top, width, 18), style="discrete", 245 245 value=5, warningValue=7, criticalValue=9, 246 246 callback=self.getCallback) 247 247 top += 30 248 self.w.DLevelIndicator_ticksAbove = LevelIndicator((left, top, width, 25), style= 'discrete',248 self.w.DLevelIndicator_ticksAbove = LevelIndicator((left, top, width, 25), style="discrete", 249 249 value=5, warningValue=7, criticalValue=9, 250 tickMarkPosition= 'above', minorTickMarkCount=5, majorTickMarkCount=3, callback=self.getCallback)251 top += 30 252 self.w.DLevelIndicator_ticksBelow = LevelIndicator((left, top, width, 25), style= 'discrete',250 tickMarkPosition="above", minorTickMarkCount=5, majorTickMarkCount=3, callback=self.getCallback) 251 top += 30 252 self.w.DLevelIndicator_ticksBelow = LevelIndicator((left, top, width, 25), style="discrete", 253 253 value=5, warningValue=7, criticalValue=9, 254 tickMarkPosition= 'below', minorTickMarkCount=5, majorTickMarkCount=3, callback=self.getCallback)255 # 254 tickMarkPosition="below", minorTickMarkCount=5, majorTickMarkCount=3, callback=self.getCallback) 255 256 256 left = 300 257 257 top = _top 258 258 width = 120 259 self.w.CLevelIndicator = LevelIndicator((left, top, width, 16), style= 'continuous',259 self.w.CLevelIndicator = LevelIndicator((left, top, width, 16), style="continuous", 260 260 value=5, warningValue=7, criticalValue=9, 261 261 callback=self.getCallback) 262 262 top += 30 263 self.w.CLevelIndicator_ticksAbove = LevelIndicator((left, top, width, 23), style= 'continuous',263 self.w.CLevelIndicator_ticksAbove = LevelIndicator((left, top, width, 23), style="continuous", 264 264 value=5, warningValue=7, criticalValue=9, 265 tickMarkPosition= 'above', minorTickMarkCount=5, majorTickMarkCount=3, callback=self.getCallback)266 top += 30 267 self.w.CLevelIndicator_ticksBelow = LevelIndicator((left, top, width, 23), style= 'continuous',265 tickMarkPosition="above", minorTickMarkCount=5, majorTickMarkCount=3, callback=self.getCallback) 266 top += 30 267 self.w.CLevelIndicator_ticksBelow = LevelIndicator((left, top, width, 23), style="continuous", 268 268 value=5, warningValue=7, criticalValue=9, 269 tickMarkPosition= 'below', minorTickMarkCount=5, majorTickMarkCount=3, callback=self.getCallback)269 tickMarkPosition="below", minorTickMarkCount=5, majorTickMarkCount=3, callback=self.getCallback) 270 270 except NameError: 271 271 pass 272 # 272 273 273 if drawGrid: 274 274 self.drawGrid() 275 # 275 276 276 self.w.open() 277 277 278 278 279 279 class ListTest(BaseTest): 280 281 def __init__(self, drawGrid=False): 282 self.w = Window((440, 500), 'List Test', minSize=(400, 400))283 # 280 281 def __init__(self, drawGrid=False): 282 self.w = Window((440, 500), "List Test", minSize=(400, 400)) 283 284 284 simpleList = List((0, 0, -0, 100), listOptions, enableTypingSensitivity=True) 285 # 285 286 286 multiItems = [ 287 { 'name': name, 'path': os.path.basename(getattr(module, '__file__', 'Unknown'))}287 {"name": name, "path": os.path.basename(getattr(module, "__file__", "Unknown"))} 288 288 for name, module in sys.modules.items() 289 289 ] 290 290 columnDescriptions = [ 291 { 'title': 'Module Name', 'key': 'name'},292 { 'title': 'File Name', 'key': 'path'}291 {"title": "Module Name", "key": "name"}, 292 {"title": "File Name", "key": "path"} 293 293 ] 294 294 multiList = List((0, 110, -0, 100), multiItems, columnDescriptions=columnDescriptions, enableTypingSensitivity=True) 295 295 296 #297 296 miscItems = [ 298 { 'slider': 50, 'checkBox': False},299 { 'slider': 20, 'checkBox': True},300 { 'slider': 70, 'checkBox': False},301 { 'slider': 20, 'checkBox': True},302 { 'slider': 10, 'checkBox': True},303 { 'slider': 90, 'checkBox': False},297 {"slider": 50, "checkBox": False}, 298 {"slider": 20, "checkBox": True}, 299 {"slider": 70, "checkBox": False}, 300 {"slider": 20, "checkBox": True}, 301 {"slider": 10, "checkBox": True}, 302 {"slider": 90, "checkBox": False}, 304 303 ] 305 304 columnDescriptions = [ 306 { 'title': 'SliderListCell', 'key': 'slider',307 'cell': SliderListCell()},308 { 'title': 'CheckBoxListCell', 'key': 'checkBox',309 'cell': CheckBoxListCell()},305 {"title": "SliderListCell", "key": "slider", 306 "cell": SliderListCell()}, 307 {"title": "CheckBoxListCell", "key": "checkBox", 308 "cell": CheckBoxListCell()}, 310 309 ] 311 310 miscCellList = List((0, 330, -0, 100), items=miscItems, columnDescriptions=columnDescriptions) … … 316 315 dict(view=miscCellList), 317 316 ] 318 # 317 319 318 # only add the ListIndicator tests if the controls are available 320 319 try: 321 320 listIndicatorItems = [ 322 { 'discrete': 3, 'continuous': 4, 'rating': 1, 'relevancy': 9},323 { 'discrete': 8, 'continuous': 3, 'rating': 5, 'relevancy': 5},324 { 'discrete': 3, 'continuous': 7, 'rating': 3, 'relevancy': 4},325 { 'discrete': 2, 'continuous': 5, 'rating': 4, 'relevancy': 7},326 { 'discrete': 6, 'continuous': 9, 'rating': 3, 'relevancy': 2},327 { 'discrete': 4, 'continuous': 0, 'rating': 6, 'relevancy': 8},321 {"discrete": 3, "continuous": 4, "rating": 1, "relevancy": 9}, 322 {"discrete": 8, "continuous": 3, "rating": 5, "relevancy": 5}, 323 {"discrete": 3, "continuous": 7, "rating": 3, "relevancy": 4}, 324 {"discrete": 2, "continuous": 5, "rating": 4, "relevancy": 7}, 325 {"discrete": 6, "continuous": 9, "rating": 3, "relevancy": 2}, 326 {"discrete": 4, "continuous": 0, "rating": 6, "relevancy": 8}, 328 327 ] 329 328 columnDescriptions = [ 330 { 'title': 'discrete',331 'cell': LevelIndicatorListCell(style='discrete', warningValue=7, criticalValue=9)},332 { 'title': 'continuous',333 'cell': LevelIndicatorListCell(style='continuous', warningValue=7, criticalValue=9)},334 { 'title': 'rating',335 'cell': LevelIndicatorListCell(style='rating', maxValue=6)},336 { 'title': 'relevancy',337 'cell': LevelIndicatorListCell(style='relevancy')},329 {"title": "discrete", 330 "cell": LevelIndicatorListCell(style="discrete", warningValue=7, criticalValue=9)}, 331 {"title": "continuous", 332 "cell": LevelIndicatorListCell(style="continuous", warningValue=7, criticalValue=9)}, 333 {"title": "rating", 334 "cell": LevelIndicatorListCell(style="rating", maxValue=6)}, 335 {"title": "relevancy", 336 "cell": LevelIndicatorListCell(style="relevancy")}, 338 337 ] 339 338 levelIndicatorList = List((0, 220, -0, 100), items=listIndicatorItems, columnDescriptions=columnDescriptions) … … 343 342 344 343 self.w.splitView = SplitView((0, 0, -0, -0), paneDescriptions) 345 # 346 # 344 347 345 if drawGrid: 348 346 self.drawGrid() 349 # 347 350 348 self.w.open() 351 349 352 350 353 351 class TestCustomNSView(NSView): 354 352 355 353 def viewDidEndLiveResize(self): 356 354 self._recalcSize() 357 355 358 356 def _recalcSize(self): 359 357 # XXX Note that this is specific for embedding in a ScrollView, … … 361 359 w, h = self.superview().visibleRect()[1] 362 360 self.setFrame_(((0, 0), (w, h))) 363 361 364 362 def drawRect_(self, rect): 365 363 if self.inLiveResize(): … … 381 379 382 380 class ViewTest(BaseTest): 383 384 def __init__(self, drawGrid=False): 385 self.w = Window((450, 350), 'View Test', minSize=(350, 300))386 # 387 self.w.tabs = Tabs((10, 10, 220, 120), [ 'Small', 'Mini'])388 self.w.tabs[0].tabs = Tabs((10, 10, -10, -10), [ 'One', 'Two', 'Three'], sizeStyle='small')389 self.w.tabs[1].tabs = Tabs((10, 10, -10, -10), [ 'One', 'Two', 'Three'], sizeStyle='mini')390 # 391 self.w.box = Box((10, 140, 220, 70), 'Box')381 382 def __init__(self, drawGrid=False): 383 self.w = Window((450, 350), "View Test", minSize=(350, 300)) 384 385 self.w.tabs = Tabs((10, 10, 220, 120), ["Small", "Mini"]) 386 self.w.tabs[0].tabs = Tabs((10, 10, -10, -10), ["One", "Two", "Three"], sizeStyle="small") 387 self.w.tabs[1].tabs = Tabs((10, 10, -10, -10), ["One", "Two", "Three"], sizeStyle="mini") 388 389 self.w.box = Box((10, 140, 220, 70), "Box") 392 390 self.w.box.box = Box((10, 10, -10, -10)) 393 # 391 394 392 self.scrollViewNSView = TestCustomNSView.alloc().initWithFrame_(((0, 0), (500, 500))) 395 393 self.w.scrollView = ScrollView((240, 10, 200, 200), self.scrollViewNSView, backgroundColor=NSColor.redColor()) 396 # 394 397 395 self.splitViewNSView1 = TestCustomNSView.alloc().initWithFrame_(((0, 0), (0, 0))) 398 396 self.splitViewNSView2 = TestCustomNSView.alloc().initWithFrame_(((0, 0), (0, 0))) … … 404 402 ] 405 403 self.w.splitView = SplitView((10, 220, -10, -10), paneDescriptions) 406 # 404 407 405 if drawGrid: 408 406 self.drawGrid() 409 # 410 self.w.open() 407 408 self.w.open() 409 411 410 412 411 class ToolbarTest(BaseTest): 413 414 def __init__(self, drawGrid=False): 415 self.w = Window((350, 20), 'Toolbar Test', minSize=(250, 20))416 # 412 413 def __init__(self, drawGrid=False): 414 self.w = Window((350, 20), "Toolbar Test", minSize=(250, 20)) 415 417 416 customView = NSSegmentedControl.alloc().initWithFrame_(((0, 0), (100, 30))) 418 417 cell = customView.cell() … … 424 423 425 424 toolbarItems = [ 426 { 'itemIdentifier': 'Test Item One',427 'label': 'Test One',428 'imagePath': iconPath,429 'callback': self.basicCallback},430 { 'itemIdentifier': 'Test Item Two',431 'label': 'Test Two',432 'imagePath': iconPath,433 'callback': self.basicCallback},434 { 'itemIdentifier': 'Test Item Three',435 'imagePath': iconPath,436 'callback': self.basicCallback},437 { 'itemIdentifier': 'Test Item Four',438 'label': 'Test Four',439 'view': customView,440 'callback': self.basicCallback},441 { 'itemIdentifier': NSToolbarPrintItemIdentifier, 'visibleByDefault': False},442 { 'itemIdentifier': NSToolbarFlexibleSpaceItemIdentifier},443 { 'itemIdentifier': NSToolbarCustomizeToolbarItemIdentifier},444 ] 445 446 self.w.addToolbar( 'Vanilla Test Toolbar', toolbarItems=toolbarItems)447 # 425 {"itemIdentifier": "Test Item One", 426 "label": "Test One", 427 "imagePath": iconPath, 428 "callback": self.basicCallback}, 429 {"itemIdentifier": "Test Item Two", 430 "label": "Test Two", 431 "imagePath": iconPath, 432 "callback": self.basicCallback}, 433 {"itemIdentifier": "Test Item Three", 434 "imagePath": iconPath, 435 "callback": self.basicCallback}, 436 {"itemIdentifier": "Test Item Four", 437 "label": "Test Four", 438 "view": customView, 439 "callback": self.basicCallback}, 440 {"itemIdentifier": NSToolbarPrintItemIdentifier, "visibleByDefault": False}, 441 {"itemIdentifier": NSToolbarFlexibleSpaceItemIdentifier}, 442 {"itemIdentifier": NSToolbarCustomizeToolbarItemIdentifier}, 443 ] 444 445 self.w.addToolbar("Vanilla Test Toolbar", toolbarItems=toolbarItems) 446 448 447 self.w.open() 449 448 450 449 451 450 class MiscTest(BaseTest): 452 453 def __init__(self, drawGrid=False): 454 self.w = Window((150, 180), 'Misc. Test')455 # 456 self.w.spinner1 = ProgressSpinner((10, 10, 32, 32), sizeStyle= 'regular')457 self.w.spinner2 = ProgressSpinner((50, 10, 16, 16), sizeStyle= 'small')458 # 451 452 def __init__(self, drawGrid=False): 453 self.w = Window((150, 180), "Misc. Test") 454 455 self.w.spinner1 = ProgressSpinner((10, 10, 32, 32), sizeStyle="regular") 456 self.w.spinner2 = ProgressSpinner((50, 10, 16, 16), sizeStyle="small") 457 459 458 self.w.bar1 = ProgressBar((10, 50, -10, 16)) 460 self.w.bar2 = ProgressBar((10, 70, -10, 10), isIndeterminate=True, sizeStyle= 'small')461 # 462 self.w.progressStartButton = Button((10, 90, -10, 20), 'Start Progress', callback=self.startProgress)463 # 459 self.w.bar2 = ProgressBar((10, 70, -10, 10), isIndeterminate=True, sizeStyle="small") 460 461 self.w.progressStartButton = Button((10, 90, -10, 20), "Start Progress", callback=self.startProgress) 462 464 463 self.w.colorWell = ColorWell((10, 130, -10, -10), callback=self.getCallback, color=NSColor.redColor()) 465 # 464 466 465 if drawGrid: 467 466 self.drawGrid() 468 # 469 self.w.open() 470 467 468 self.w.open() 469 471 470 def startProgress(self, sender): 472 471 self.w.spinner1.start() … … 515 514 516 515 class Test(object): 517 516 518 517 def __init__(self): 519 518 self.w = FloatingWindow((200, 300, 120, 310)) 520 self.w.drawGrid = CheckBox((10, 10, -10, 22), 'Draw Grid', value=False)521 self.w.windows = Button((10, 40, -10, 20), 'Windows', callback=self.openTestCallback)522 self.w.geometry = Button((10, 70, -10, 20), 'Geometry', callback=self.openTestCallback)523 self.w.text = Button((10, 100, -10, 20), 'Text', callback=self.openTestCallback)524 self.w.buttons = Button((10, 130, -10, 20), 'Buttons', callback=self.openTestCallback)525 self.w.list = Button((10, 160, -10, 20), 'List', callback=self.openTestCallback)526 self.w.view = Button((10, 190, -10, 20), 'Views', callback=self.openTestCallback)527 self.w.toolbar = Button((10, 220, -10, 20), 'Toolbar', callback=self.openTestCallback)528 self.w.misc = Button((10, 250, -10, 20), 'Misc.', callback=self.openTestCallback)529 self.w.split = Button((10, 280, -10, 20), 'SplitView', callback=self.openTestCallback)530 self.w.open() 531 519 self.w.drawGrid = CheckBox((10, 10, -10, 22), "Draw Grid", value=False) 520 self.w.windows = Button((10, 40, -10, 20), "Windows", callback=self.openTestCallback) 521 self.w.geometry = Button((10, 70, -10, 20), "Geometry", callback=self.openTestCallback) 522 self.w.text = Button((10, 100, -10, 20), "Text", callback=self.openTestCallback) 523 self.w.buttons = Button((10, 130, -10, 20), "Buttons", callback=self.openTestCallback) 524 self.w.list = Button((10, 160, -10, 20), "List", callback=self.openTestCallback) 525 self.w.view = Button((10, 190, -10, 20), "Views", callback=self.openTestCallback) 526 self.w.toolbar = Button((10, 220, -10, 20), "Toolbar", callback=self.openTestCallback) 527 self.w.misc = Button((10, 250, -10, 20), "Misc.", callback=self.openTestCallback) 528 self.w.split = Button((10, 280, -10, 20), "SplitView", callback=self.openTestCallback) 529 self.w.open() 530 532 531 def openTestCallback(self, sender): 533 532 title = sender.getTitle() 534 if title == 'Windows':533 if title == "Windows": 535 534 WindowTest() 536 elif title == 'Geometry':535 elif title == "Geometry": 537 536 from vanilla.test.testGeometry import TestGeometry 538 537 TestGeometry() 539 elif title == 'Text':538 elif title == "Text": 540 539 TextTest(self.w.drawGrid.get()) 541 elif title == 'Buttons':540 elif title == "Buttons": 542 541 ButtonTest(self.w.drawGrid.get()) 543 elif title == 'List':542 elif title == "List": 544 543 ListTest(self.w.drawGrid.get()) 545 elif title == 'Views':544 elif title == "Views": 546 545 ViewTest(self.w.drawGrid.get()) 547 elif title == 'Toolbar':546 elif title == "Toolb
