# 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)
# 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, ctrlc=False) def clicked(user, pwd): if pwd == "pass": w.exit() with w: tusr = view.TextInput() tpwd = view.TextInput(password=True) rem = view.Checkbox("Remember me") with builder.Builder(w.root) as b: b.align().box("Login").grid(3, 4) \ (view.Label("Username", fg = colors.BLUE)).spacer(width = 2)(tusr) \ (view.Label("Password", fg = colors.BLUE))()(tpwd) \
#! /usr/bin/env python3 from wytch import builder, colors, view, input, Wytch w = Wytch(buffer = True) class ColorButton(view.Widget): def __init__(self, color, board): super(ColorButton, self).__init__() self.color = color self.board = board self.focusable = False self.hstretch = False self.vstretch = False def render(self): if not self.canvas: return self.canvas.square(0, 0, self.canvas.width, self.canvas.height, bordercolor = self.color) def onmouse(self, me): if not me.pressed: return self.board.colors[me.button] = self.color @property def size(self): return (5, 2)
# 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, canvas, event, Wytch w = Wytch() class ColorButton(view.Widget): def __init__(self, color, board): super(ColorButton, self).__init__() self.color = color self.board = board self.focusable = False self.hstretch = False self.vstretch = False @event.handler("mouse", pressed=True) def _onmouse(self, me): self.board.colors[me.button] = self.color
# 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() 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)
# # 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()))
# 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, canvas, event, Wytch w = Wytch() class ColorButton(view.Widget): def __init__(self, color, board): super(ColorButton, self).__init__() self.color = color self.board = board self.focusable = False self.hstretch = False self.vstretch = False @event.handler("mouse", pressed = True) def _onmouse(self, me): self.board.colors[me.button] = self.color
# 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)