LaunchpadRadioWidget ==================== There are two Launchpad radio widgets, one that shows descriptions, and one that doesn't. >>> from lp.app.widgets.itemswidgets import ( ... LaunchpadRadioWidget, LaunchpadRadioWidgetWithDescription) The LaunchpadRadioWidget is mostly used to display items from an enumerated type. >>> from BeautifulSoup import BeautifulSoup >>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest >>> from lp.code.interfaces.branch import IBranch >>> branch = factory.makeAnyBranch() >>> branch_type_field = IBranch['branch_type'].bind(branch) >>> request = LaunchpadTestRequest() >>> radio_widget = LaunchpadRadioWidget( ... branch_type_field, branch_type_field.vocabulary, request) >>> radio_widget.setRenderedValue(branch_type_field.vocabulary.HOSTED) The widget is rendered as a collection of labels with the radio buttons inside. >>> html = BeautifulSoup(radio_widget()) >>> for label in html.findAll('label'): ... print label.renderContents() Hosted Mirrored Imported Remote LaunchpadRadioWidgetWithDescription ----------------------------------- The LaunchpadRadioWidgetWithDescription widget renders the descriptions along with the titles from the enumerated type vocabulary. >>> radio_widget = LaunchpadRadioWidgetWithDescription( ... branch_type_field, branch_type_field.vocabulary, request) >>> radio_widget.setRenderedValue(branch_type_field.vocabulary.HOSTED) The widget is rendered in a table with the descriptions lined up under the labels. The labels are rendered next to the radio buttons, in a different table cell, and use the 'for' attribute of the label to associate the label with the radio button input. >>> print radio_widget()
Launchpad is the primary location of this branch. | |
Primarily hosted elsewhere and is periodically mirrored from the external location into Launchpad. | |
Branches that have been imported from an externally hosted branch in bzr or another VCS and are made available through Launchpad. | |
Registered in Launchpad with an external location, but is not to be mirrored, nor available through Launchpad. |