Home | Trees | Indices | Help |
|
---|
|
1 2 from muntjac.api \ 3 import Application, Window, VerticalLayout, HorizontalLayout, \ 4 NativeButton, TextField, Alignment, Label 5 6 from muntjac.ui.button \ 7 import IClickListener 8 9 from muntjac.addon.weelayout.wee_layout \ 10 import WeeLayout, Direction 11 1214 20 21186 187 195 196 201 202 203 if __name__ == '__main__': 204 from muntjac.main import muntjac 205 muntjac(WeelayoutApplication, nogui=True, forever=True, debug=True) 20623 mainWindow = Window('Weelayout Application') 24 self.setMainWindow(mainWindow) 25 26 # mainWindow.setContent(self.splitRecursive(2)) 27 # mainWindow.setContent(self.undefinedWithRelativeSizes()) 28 # mainWindow.setContent(self.splitView()) 29 # mainWindow.setContent(self.createVertical(2)) 30 # mainWindow.setContent(self.createCoreVertical(2)) 31 # mainWindow.setContent(self.createHorizontal(2)) 32 mainWindow.setContent(self.createCoreHorizontal(2)) 33 34 self.setTheme('test')35 3638 l = None 39 if self._core: 40 l = VerticalLayout() if self._vertical else HorizontalLayout() 41 else: 42 if self._vertical: 43 l = WeeLayout(Direction.VERTICAL) 44 else: 45 l = WeeLayout(Direction.HORIZONTAL) 46 47 l.setSizeFull() 48 if self._core: 49 c = l 50 b = NativeButton('One') 51 b.setSizeFull() 52 c.addComponent(b) 53 c.setExpandRatio(b, 1) 54 if deep > 0: 55 deep -= 1 56 c2 = self.splitRecursive(deep) 57 c.addComponent(c2) 58 c.setExpandRatio(c2, 9) 59 else: 60 wl = l 61 wl.setClipping(True) 62 b = NativeButton('Button') 63 b.setSizeFull() 64 if self._vertical: 65 b.setHeight('10%') 66 else: 67 b.setWidth('10%') 68 69 l.addComponent(b) 70 if deep > 0: 71 deep -= 1 72 w = self.splitRecursive(deep) 73 if self._vertical: 74 w.setHeight('90%') 75 else: 76 w.setWidth('90%') 77 78 l.addComponent(w) 79 else: 80 b.setSizeFull() 81 82 return l83 8486 wl = WeeLayout(Direction.VERTICAL) 87 wl.setHeight('100%') 88 89 wlong = NativeButton('With long caption', LongClickListener()) 90 wl.addComponent(wlong, '100%', '30px', Alignment.TOP_LEFT) 91 92 b = NativeButton('Two') 93 b.addStyleName('test') 94 wl.addComponent(b, '100%', '100%', Alignment.TOP_LEFT) 95 wl.setSmartRelativeSizes(True) 96 return wl97 98100 wl = WeeLayout(Direction.HORIZONTAL) 101 wl.setSizeFull() 102 103 one = NativeButton('One', OneClickListener()) 104 wl.addComponent(one, '100px', '30px', Alignment.TOP_RIGHT) 105 106 wl.addComponent(Label(''), '14px', '14px', Alignment.TOP_CENTER) 107 wl.addComponent(NativeButton('Two'), '100%', '100%', 108 Alignment.TOP_CENTER) 109 # wl.setClipping(true) 110 111 return wl112 113115 wl = WeeLayout(Direction.VERTICAL) 116 wl.setSizeFull() 117 # wl.setWidth("100%") 118 # wl.setHeight("50%") 119 wl.addComponent(TextField('Left'), Alignment.TOP_LEFT) 120 wl.addComponent(TextField('Center'), Alignment.TOP_CENTER) 121 tf = TextField('Right') 122 tf.setWidth('50%') 123 wl.addComponent(tf, Alignment.TOP_RIGHT) 124 if recurse > 0: 125 recurse -= 1 126 wl.addComponent(self.createHorizontal(recurse)) 127 return wl128 129131 wl = WeeLayout(Direction.HORIZONTAL) 132 wl.setSizeFull() 133 # wl.setHeight("100%"); 134 wl.addComponent(TextField('Top'), Alignment.TOP_LEFT) 135 wl.addComponent(TextField('Middle'), Alignment.MIDDLE_LEFT) 136 tf = TextField('Bottom') 137 tf.setHeight('50%') 138 wl.addComponent(tf, Alignment.BOTTOM_LEFT) 139 if recurse > 0: 140 recurse -= 1 141 wl.addComponent(self.createVertical(recurse)) 142 return wl143 144146 """Same with core layouts""" 147 l = VerticalLayout() 148 l.setSizeFull() 149 tf = TextField('Left') 150 l.addComponent(tf) 151 l.setComponentAlignment(tf, Alignment.TOP_LEFT) 152 tf = TextField('Center') 153 l.addComponent(tf) 154 l.setComponentAlignment(tf, Alignment.TOP_CENTER) 155 tf = TextField('Right') 156 l.addComponent(tf) 157 tf.setWidth('50%') 158 l.setComponentAlignment(tf, Alignment.TOP_RIGHT) 159 if recurse > 0: 160 recurse -= 1 161 createCoreHorizontal = self.createCoreHorizontal(recurse) 162 l.addComponent(createCoreHorizontal) 163 l.setExpandRatio(createCoreHorizontal, 1) 164 return l165 166168 l = HorizontalLayout() 169 l.setSizeFull() 170 tf = TextField('Top') 171 l.addComponent(tf) 172 l.setComponentAlignment(tf, Alignment.TOP_LEFT) 173 tf = TextField('Middle') 174 l.addComponent(tf) 175 l.setComponentAlignment(tf, Alignment.MIDDLE_LEFT) 176 tf = TextField('Bottom') 177 l.addComponent(tf) 178 tf.setWidth('50%') 179 l.setComponentAlignment(tf, Alignment.BOTTOM_LEFT) 180 if recurse > 0: 181 recurse -= 1 182 createCoreVertical = self.createCoreVertical(recurse) 183 l.addComponent(createCoreVertical) 184 l.setExpandRatio(createCoreVertical, 1) 185 return l
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Apr 20 16:53:03 2013 | http://epydoc.sourceforge.net |