def __init__(self): super().__init__( ['Enter expression:', E('expr'), B('Eval!')], ['Result:', 'result', _], [_, _, Quit]) self.events( [_, do_eval, do_eval], [_, _, _], [_, _, _], )
# -*- coding: utf-8 -*- from guietta import B, E, _, Gui, Quit # Use *args to accept multiple signals # with different arguments. def do_eval(gui, *args): print(gui.foo) gui.bar = eval(gui.foo) gui = Gui(['Enter expression:', E('expr'), B('Eval!')], ['Result:', 'result', _], [_, _, Quit]) gui.events( [_, do_eval, do_eval], [_, _, _], [_, _, _], ) gui.rename( [_, 'foo', _], [_, 'bar', _], [_, _, _], ) gui.run() # GUI widgets are available after window closing,
try: from PySide2.QtWidgets import QDial, QLCDNumber, QTableWidget from PySide2.QtWidgets import QTableWidgetItem, QHeaderView except ImportError: from PyQt5.QtWidgets import QDial, QLCDNumber, QTableWidget from PyQt5.QtWidgets import QTableWidgetItem, QHeaderView gui = Gui( ['<center>A big GUI with all of Guietta' 's widgets</center>'], ['<center>Move the dial!</center>'], [HSeparator], ['Label', 'imagelabel.jpeg', L('another label'), VS('slider1')], [_, ['button'], B('another button'), III], ['__edit__', E('an edit box'), _, VSeparator], [R1('rad1'), R1('rad2'), R1('rad3'), III], [R2('rad4'), R2('rad5'), R2('rad6'), III], [C('ck1'), C('ck2'), C('ck3'), III], [Quit, Ok, Cancel, III], [Yes, No, _, III], [HS('slider2'), ___, ___, _], [(QDial, 'dial'), (QLCDNumber, 'lcd'), ___, _], [(QTableWidget, 'tab1'), ___, ___, ___], [III, III, III, III], [III, III, III, III], [P('progbar'), (QLCDNumber, 'lcd2'), _, _], [L('l1'), L('l2'), L('l3'), L('l4')], )
# -*- coding: utf-8 -*- from guietta import B, C, E, _, Gui, Quit def do_eval(gui, *args): gui.result = eval(gui.expr) def checkbox(gui, state): print('Checkbox state is', state) gui = Gui(['Enter expression:', E('expr'), B('Eval!')], ['Result:', 'result', _], [C('test'), _, Quit]) gui.events( [_, do_eval, do_eval], [_, _, _], [checkbox, _, _], ) gui.run() # GUI widgets are available after window closing, print(gui.result)
from guietta import B, E, _, Gui, Quit from PySide2.QtWidgets import QSlider from PySide2.QtCore import Qt def do_eval(gui, *args): gui.result = eval(gui.expr) def do_slider(gui, state): gui.result = '%d' % state s = QSlider(Qt.Horizontal) gui = Gui( [ 'Enter expression:', E('expr') , B('Eval!') ], [ 'Result:' , 'result' , _ ], [ (s, 'myslider') , _ , Quit ] ) gui.events( [ _ , do_eval , do_eval ], [ _ , _ , _ ], [ do_slider , _ , _ ], ) gui.run() # GUI widgets are available after window closing, print(gui.result)
# -*- coding: utf-8 -*- from guietta import B, _, Gui, Quit, Empty counter = 0 gui = Gui(['Enter expression:', '__expr__', B('Eval!')], ['Result:', 'result', _], ['counter', _, Quit]) while True: try: name, event = gui.get(timeout=0.1) except Empty: counter += 1 gui.counte = counter continue if name == 'Eval': try: gui.result = eval(gui.expr) except Exception as e: gui.result = 'Error: ' + str(e) elif name is None: break
# -*- coding: utf-8 -*- import os.path from guietta import B, L, _, Gui, Quit gui = Gui( [ 'Enter expression:', '__expr__' , B('right.png', 'newname') ], [ L('left.png', 'result') , 'result' , _ ], [ _ , _ , Quit ], images_dir = os.path.dirname(__file__) ) while True: name, event = gui.get() print(name, event) if name == 'newname': try: gui.result = eval(gui.expr) except Exception as e: gui.result = 'Error: ' + str(e) elif name == None: break
# -*- coding: utf-8 -*- from guietta import B, _, Gui, Quit gui = Gui( [ 'Enter expression:', '__expr__' , B('Eval!') ], [ 'Result:' , 'result' , _ ], [ _ , _ , Quit ] ) gui.run()
# -*- coding: utf-8 -*- import os.path from guietta import B, L, _, Gui gui = Gui( [ ['left'] ], # Simple button [ (['left'], 'bb') ], # Simple button, renamed [ B('left') ], # Previous two with explicit B [ (B('left'), 'bb') ], [ ['left.png'] ], # Image button [ ['left.png', 'aa'] ], # Image button + text [ (['left.png'], 'bb') ], # Image button, renamed [ (['left.png', 'aa'], 'bb') ], # Image button + text, renamed [ B('left.png') ], # Previous for with explicit B [ B('left.png', 'aa') ], [ (B('left.png'), 'bb') ], [ (B('left.png', 'aa'), 'bb') ], [ ['leftt.png'] ], # Previous 8 with wrong filename [ ['leftt.png', 'aa'] ], [ (['leftt.png'], 'bb') ], [ (['leftt.png', 'aa'], 'bb') ], [ B('leftt.png') ], [ B('leftt.png', 'aa') ], [ (B('leftt.png'), 'bb') ], [ (B('leftt.png', 'aa'), 'bb') ], images_dir = os.path.dirname(__file__))
# -*- coding: utf-8 -*- import os.path from guietta import B, L, _, Gui gui = Gui([_, L('up.png'), _], [B('left.png'), _, B('right.png')], [ _, L('down.png'), _, ], images_dir=os.path.dirname(__file__)) while True: name, event = gui.get() print(name, event) if name == None: break