def view_factory(self): """ Invoked to return the default view factory. """ from dip.ui import (Form, HBox, ListEditor, StorageLocationEditor, PushButton, Stretch, TextEditor, VBox) return Form( 'name', TextEditor('description'), HBox( ListEditor('contents', editor_factory=StorageLocationEditor( filter_hints="Python source files (*.py *.pyw)", format='myorganization.formats.python_code', title="Choose project contents")), VBox(PushButton(id='add_file'), PushButton(id='remove_file', enabled=False), Stretch())), MessageArea())
from dip.ui import Application, Form # Every application needs an Application. app = Application() # Create the model. model = dict(name='Joe User', age=30) # Define the view. view_factory = Form('name', 'age', title="Extended Model") # Create an instance of the view bound to the model. view = view_factory(model) # Make the instance of the view visible. view.visible = True # Enter the event loop. app.execute() # Show the value of the model. print("Name:", model['name']) print("Age:", model['age'])
action.enabled = not action.enabled # Every application needs an Application. app = Application() # Create the model. model = ExampleModel(name="Joe User", male=True) # Define the view. view_factory = VBox(MenuBar( Menu(QuitAction(id='quit'), title="&File"), Menu(Action(id='toggle_quit'), Menu(Action('male'), title="Sub-menu"), title="&Examples")), Form('name'), ToolButton(action='quit'), controller_factory=ExampleController) # Create an instance of the view bound to the model. view = view_factory(model) # Make the instance of the view visible. view.visible = True # Enter the event loop. app.execute() # Show the value of the model. print("Name:", model.name) print("Male?:", model.male)
from dip.automate import Robot from dip.ui import Application, Form # Every application needs an Application. app = Application() # Create the model. model = dict(name='') # Define the view. view_factory = Form(title="Simple Example") # Create an instance of the view bound to the model. view = view_factory(model) # Make the instance of the view visible. view.visible = True # Simulate the events to set the name. Robot.simulate('name', 'set', "Joe User", delay=200) # Show the value of the model. print("Name:", model['name'])
from dip.ui import Application, Form, SpinBox # Every application needs an Application. app = Application() # Create the model. model = dict(name="Joe User", age=30) # Define the view. view_factory = Form('name', SpinBox('age', suffix=" years"), title="Configure Views") # Create an instance of the view for the model. view = view_factory(model) # Make the instance of the view visible. view.visible = True # Enter the event loop. app.execute() # Show the value of the model. print("Name:", model['name']) print("Age:", model['age'])
from dip.ui import Application, Form # Every application needs an Application. app = Application() # Create the model. model = dict(name="Joe User") # Define the view. view_factory = Form() # Create an instance of the view bound to the model. view = view_factory(model) # Make the instance of the view visible. view.visible = True # Enter the event loop. app.execute() # Show the value of the model. print("Name:", model['name'])
# The name. name = Str(tool_tip="The person's full name") # The age in years. age = Int(minimum=0, maximum=120) # Every application needs an Application. app = Application() # Create the model. model = ExampleModel() # Define the sub-view. subview_factory = Form('name', SpinBox('age', suffix=" years")) # Create two instances of the sub-view bound to the same model. subview_left = subview_factory(model, top_level=False) subview_right = subview_factory(model, top_level=False) # Create a regular PyQt widget showing the two sub-views side by side. layout = QHBoxLayout() layout.addLayout(unadapted(subview_left)) layout.addLayout(unadapted(subview_right)) view = QWidget(windowTitle="Real Model") view.setLayout(layout) view.show() # Enter the event loop.