本文整理匯總了Python中crispy_forms.layout.Column方法的典型用法代碼示例。如果您正苦於以下問題:Python layout.Column方法的具體用法?Python layout.Column怎麽用?Python layout.Column使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類crispy_forms.layout
的用法示例。
在下文中一共展示了layout.Column方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: helper
# 需要導入模塊: from crispy_forms import layout [as 別名]
# 或者: from crispy_forms.layout import Column [as 別名]
def helper(self):
# As extra service, auto-adjust the layout based on the project settings.
# This allows defining the top-row, and still get either 2 or 3 columns
compact_fields = [name for name in self.fields.keys() if name in self.top_row_fields]
other_fields = [name for name in self.fields.keys() if name not in self.top_row_fields]
col_size = int(self.top_row_columns / len(compact_fields))
col_class = self.top_column_class.format(size=col_size)
compact_row = Row(*[Column(name, css_class=col_class) for name in compact_fields])
# The fields are already ordered by the AbstractCommentForm.__init__ method.
# See where the compact row should be.
pos = list(self.fields.keys()).index(compact_fields[0])
new_fields = other_fields
new_fields.insert(pos, compact_row)
helper = CompactLabelsCommentFormHelper()
helper.layout = Layout(*new_fields)
helper.add_input(SubmitButton())
helper.add_input(PreviewButton())
return helper