我在使用django-crispy-forms时遇到了一个问题,我无法得到答案.我有一个相当复杂的表单布局,到目前为止,一切都非常好用cripy-forms.
表单的一部分使用通用内联formset.这也是有效的,但我的问题是,我无法弄清楚如何访问delete-checkbox(当can_delete = True时)
相应的代码类似于:
class BaseReleaseReleationFormSet(BaseGenericInlineFormSet):
def __init__(self, *args, **kwargs):
self.instance = kwargs['instance']
super(BaseReleaseReleationFormSet, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = "id_relation_form"
self.helper.form_class = 'form-horizontal'
self.helper.form_method = 'post'
self.helper.form_action = ''
self.helper.form_tag = False
base_layout = Row(
Column(
Field('name', css_class='input-small'),
#Field('delete', css_class='input-small'),
css_class='span3'
),
Column(
Field('url', css_class='input-xlarge'),
css_class='span4'
),
css_class='row relation-row',
)
self.helper.add_layout(base_layout)
Run Code Online (Sandbox Code Playgroud)
name和url字段根据需要使用crispy-forms呈现,但delete-checkbox显示在表单的末尾.我无法在布局中访问它.
有人知道如何解决这个问题吗?有小费吗?提前致谢!
我有一个表格,其中包含一个包含1列和3行的TableLayout,其中包含2个FlowLayoutPanels和一个文本框。所有行均为AutoSize,并且该列设置为Percentage = 100%。
每个FlowLayoutPanel都包含多个TextBox。设置FlowLayoutPanels:LeftToRight,AutoSize = true,GrowAndShrink,Docking = Fill。
大纲是:
Form
TableLayout (Dock=Fill)
FlowLayoutPanel(Dock=Fill, AutoSize=True, GrowShrink)
More controls
FlowLayoutPanel(Dock=Fill, AutoSize=True, GrowShrink)
More controls
TextBox(Dock=Fill, MultiLine=true)
Run Code Online (Sandbox Code Playgroud)
问题是如果我将FlowLayoutPanel放置在也设置为AutoSize = true的GroupBox内,则FlowLayoutPanel Height设置不正确,并且它在1行中显示了TextBoxes,从而从窗体中切出了一些TextBoxes。
大纲是:
Form
TableLayout (Dock=Fill)
GroupBox (Dock=Fill, AutoSize=True, GrowShrink)
FlowLayoutPanel(Dock=Fill, AutoSize=True, GrowShrink)
More controls
GroupBox (Dock=Fill, AutoSize=True, GrowShrink)
FlowLayoutPanel(Dock=Fill, AutoSize=True, GrowShrink)
More controls
TextBox(Dock=Fill, MultiLine=true)
Run Code Online (Sandbox Code Playgroud)
顺便说一句,如果我使用而不是GroupBox,Panel甚至UserControl来保存FlowLayoutPanel,也会发生同样的事情。
顺便说一句2,即使没有TableLayout,也会发生这种情况。我尝试将GroupBox(与FlowLayoutPanel一起)放置在AutoSized窗体上,并且得到相同的行为。
我认为问题是,当FlowLayoutPanel处于另一个也具有AutoSized大小的容器中时,它无法传递给它的容器是首选大小。
有什么办法可以覆盖此错误?
请帮助谢谢,约兰
ps:我必须使用GroupBox在TextBoxes周围有一个漂亮的框架。
我正在使用联系表7来设计酒店的预订表。
我不知道如何自定义布局。我希望某些文本字段显示在同一行上,但是我找不到元素的正确标识和/或用于实现此非常简单目标的CSS样式。
这是代码:
<div id="responsive-form" class="clearfix">
<label> Your Name (required)
[text* your-name] </label>
<label> Your Email (required)
[email* your-email] </label>
<label> Arrival date
[date date-79 id:Arrivaldate date-format:mm/dd/yy] </label>
<label> Departure date
[date date-80 id:Departuredate date-format:mm/dd/yy] </label>
<label> How many guests?
[text your-guests] </label>
<div class="form-row">
<p>Number of adults [text your-adults]</p>
<p>Number of children under 6 years old [text your-little-children]</p>
<p>Number of children under 12 years old [text your-big-children]</p>
</div>
Select your preferred accomodation
[checkbox your-accomodation use_label_element "Wayan (Two-story villa)" …Run Code Online (Sandbox Code Playgroud)有没有办法使用JGoodies FormLayout来更改组件设置后的对齐方式?
例如,
CellConstraints cc = new CellCosntraints();
panel.add(component,cc.xy(1,1,CellConstraints.DEFAULT,CellConstraints.FILL));
Run Code Online (Sandbox Code Playgroud)
如果我想更改component为具有DEFAULT的行约束而不是FILL,是否有一种方法可以更改它,因为它已设置而不删除并重新添加组件?
一个业务目标要求我在屏幕上制作一个像素完美的表单.如果用户打印此表单,它将与表单的美国政府印刷局版本完全匹配; 打印机将生成该文档的(合理)可扫描副本.以前的解决方案是PDF,它只对我们有用.
我倾向于HTML/CSS,并希望提供有关工具的建议来提供帮助.
对于工具,Firefox中的PixelPerfect似乎是一个良好的开端.目标平台是(鼓)IE6,如果有帮助的话.该文件看起来像这样.
如果HTML/CSS完全禁止,Adobe Flex是我的下一个选择.
我使用了FormLayout,我想将所有组件(JLabel和JtextField)设置在JFrame的中心。
我尝试使用panel.setAlignmentX和panel.setAlignmentY,但是它不起作用。
panel.setAlignmentX(Component.CENTER_ALIGNMENT);
panel.setAlignmentY(Component.CENTER_ALIGNMENT);
Run Code Online (Sandbox Code Playgroud)
下面显示的是我的代码,请帮助谢谢。
import java.awt.Component;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
@SuppressWarnings("serial")
public class UI extends JFrame {
private JPanel panel = new JPanel();
public UI() {
FormLayout layout = new FormLayout(
"pref, pref, pref, pref",
"pref, pref, pref, pref");
panel.setLayout(layout);
CellConstraints cc = new CellConstraints();
panel = new JPanel (layout);
panel.add(new JLabel("L1 "), cc.xy(2, 2));
panel.add(new JTextField(15), cc.xy(3, 2));
panel.add(new JLabel("L2 "), cc.xy(2, 3));
panel.add(new JTextField(15), cc.xy(3, 3));
panel.setAlignmentX(Component.CENTER_ALIGNMENT);
panel.setAlignmentY(Component.CENTER_ALIGNMENT);
add(panel); …Run Code Online (Sandbox Code Playgroud) 我正在使用FormLayout作为Composite容器.当我添加两个孩子标签和clientArea,其中clientArea要看标签上-在clientArea才会出现,当我第一次添加标签.
在添加子项后调用容器上的layout()没有帮助 - clientArea不会显示.
如何将子项添加到FormLayout控制的容器中,与彼此的依赖项无关?
MyLabel label;
Composite clientArea;
public MyContainer(Composite parent, int style) {
super(parent,style);
//choose the container Layout
FormLayout layout = new FormLayout();
this.setLayout(layout);
clientArea = new Composite(this, SWT.NONE);
FormData formData4ClientArea = new FormData();
formData4ClientArea.left = new FormAttachment(0,0);
formData4ClientArea.top = new FormAttachment(0,5);
formData4ClientArea.right = new FormAttachment(label,-5);
formData4ClientArea.bottom = new FormAttachment(100,-5);
//set the Formdata
clientArea.setLayoutData(formData4ClientArea);
clientArea.setBackground(getDisplay().getSystemColor(SWT.COLOR_GREEN));
//create the label
label = new MyLabel(this, SWT.NONE);
FormData formData4Label = new FormData();
formData4Label.top = new FormAttachment(0,5);
formData4Label.right = …Run Code Online (Sandbox Code Playgroud) 我想知道如何使用 Java 网格布局组合或合并两个网格位置。我正在使用带有 JFrame 和 Java 表单组件(如 JLabel 和 JButton)的 java grid layout(0, 2) 创建一个基本的 java 应用程序。我想组合顶部的两个单元格以在应用程序的中心显示我的标题。