self._buffer.set(me.x, me.y, " ", bg=color) else: self._buffer.line(self.oldme.x, self.oldme.y, me.x, me.y, bg=color) if me.released: self.oldme = None else: self.oldme = me self.update() def recalc(self): if not self._buffer or self._buffer.width != self.canvas.width or self._buffer.height != self.canvas.height: self._buffer = canvas.BufferCanvas(self.canvas) def render(self): self._buffer.flush() @property def size(self): return (1, 1) with w: board = DrawingBoard() w.root.bind("key", lambda _: w.exit(), key="q") with builder.Builder(w.root) as b: h = b.vertical().horizontal() for c in colors.c256[:16]: h.add(ColorButton(c, board)) h.end().add(board)
# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. from wytch import builder, colors, view, Wytch w = Wytch(debug = False) with w: ttgt = view.TextInput() lbl = view.Label("Target", fg = colors.BLUE) with builder.Builder(w.root) as b: def onvalue(_): ttgt.display = not ttgt.display lbl.display = not lbl.display b.align().box("Login").grid(3, 4) \ (lbl).spacer(width = 2)(ttgt) \ (view.Checkbox("Hide", onvalue = onvalue), colspan = 3)()() \ (view.Button("Quit", onpress = lambda _: w.exit()), colspan = 3)
self.canvas.set(me.x, me.y, " ", bg = color) else: self.canvas.line(self.oldme.x, self.oldme.y, me.x, me.y, bg = color) if me.released: self.oldme = None else: self.oldme = me def render(self): if not self.canvas: return for x, col in enumerate(self.grid): for y, v in enumerate(col): self.canvas.set(x, y, " ") @property def size(self): return (1, 1) with w: board = DrawingBoard() w.root.handlers.append(("q", lambda _: w.exit())) with builder.Builder(w.root) as b: h = b.vertical() \ .horizontal() for c in colors.c256[:16]: h.add(ColorButton(c, board)) h.end().add(board)
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. from wytch import builder, colors, view, Wytch w = Wytch() with w: popup = builder.Popup(w.root) label = view.Label("-", fg=colors.GREEN) def ongroup(ve): label.text = ve.new.label group = view.Radio.Group(onvalue=ongroup) with popup: x = popup.align().box("Popup").vertical() for s in ["alpha", "beta", "gamma", "delta", "epsilon"]: r = view.Radio(s) r.group = group x.align(halign=view.HOR_LEFT).add(r) x.add(view.Button("Ok", onpress=lambda _: popup.close())) with builder.Builder(w.root) as b: b.align().box("Popup demo").vertical()(label).hline()(view.Button("Open", onpress=lambda _: popup.open()))( view.Button("Exit", onpress=lambda _: w.exit()) )
# # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. import time from wytch import builder, colors, view, Wytch w = Wytch(debug=True) with w: with builder.Builder(w.root) as b: b.align().box("Debug console demo").vertical() \ (view.Button("Greet", onpress = lambda _: print("Hello!"))) \ (view.Button("Time", onpress = lambda _: print(time.time()))) \ (view.Button("Exit", onpress = lambda _: w.exit()))
else: self._buffer.line(self.oldme.x, self.oldme.y, me.x, me.y, bg = color) if me.released: self.oldme = None else: self.oldme = me self.update() def recalc(self): if not self._buffer or self._buffer.width != self.canvas.width \ or self._buffer.height != self.canvas.height: self._buffer = canvas.BufferCanvas(self.canvas) def render(self): self._buffer.flush() @property def size(self): return (1, 1) with w: board = DrawingBoard() w.root.bind("key", lambda _: w.exit(), key = "q") with builder.Builder(w.root) as b: h = b.vertical() \ .horizontal() for c in colors.c256[:16]: h.add(ColorButton(c, board)) h.end().add(board)
# furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. from wytch import builder, colors, view, Wytch w = Wytch(debug=False) with w: ttgt = view.TextInput() lbl = view.Label("Target", fg=colors.BLUE) with builder.Builder(w.root) as b: def onvalue(_): ttgt.display = not ttgt.display lbl.display = not lbl.display b.align().box("Login").grid(3, 4) \ (lbl).spacer(width = 2)(ttgt) \ (view.Checkbox("Hide", onvalue = onvalue), colspan = 3)()() \ (view.Button("Quit", onpress = lambda _: w.exit()), colspan = 3)