简体   繁体   English

没有条目的 GTK3 组合框移动到带有条目的 GTK3 组合框之后。 为什么?

[英]GTK3 combobox without entry moving to after GTK3 combobox with entry. Why?

So, I've been developing this application for work, that essentially allows the user to select their department, building, and floor.所以,我一直在开发这个工作应用程序,它基本上允许用户选择他们的部门、建筑物和楼层。 This brings up a floor plan of the selected location, where they can select different printers on that floor plan.这会显示所选位置的平面图,他们可以在该平面图上选择不同的打印机。 It also brings up another combobox where they can select by name, the printer.它还打开了另一个组合框,他们可以在其中按名称选择打印机。 I've created the comboboxes in order of how I want them to display: Department, Building, Floor, Printer.我已经按照我希望它们显示的顺序创建了组合框:部门、建筑、楼层、打印机。 They don't display that way though.但他们不会那样显示。 This is how they display instead: ComboBox Order .这是它们的显示方式: ComboBox Order I'm guessing this is because the Floor combobox is a Gtk.ComboBoxText object, instead of just Gtk.ComboBox like the rest of them.我猜这是因为 Floor 组合框是一个 Gtk.ComboBoxText 对象,而不是像其他的 Gtk.ComboBox 一样。 Is there a way to fix this or work around it?有没有办法解决这个问题或解决它?

    # Department Combo
    self.department_combo = Gtk.ComboBox.new_with_model_and_entry(self.logic.get_department_store())
    self.department_combo.set_entry_text_column(0)
    self.combo_rowbox.pack_start(self.department_combo, False, False, 0)
    self.department_combo.show()
    # Building Combo
    self.building_combo = Gtk.ComboBox.new_with_entry()
    self.building_combo.set_entry_text_column(0)
    self.combo_rowbox.pack_start(self.building_combo, False, False, 0)
    self.building_combo.hide()
    # Floor Combo
    self.floor_combo = Gtk.ComboBoxText()
    self.floor_combo.set_entry_text_column(0)
    self.combo_rowbox.pack_start(self.floor_combo, False, False, 0)
    self.floor_combo.hide()
    # Printer Combo
    self.printer_combo = Gtk.ComboBox.new_with_entry()
    self.printer_combo.set_entry_text_column(0)
    self.combo_rowbox.pack_start(self.printer_combo, True, True, 0)
    self.printer_combo.hide()

Assuming self.combo_rowbox is Gtk.Box I would suggest changing the pack_start used for self.printer_combo to pack_end .假设self.combo_rowboxGtk.Box我建议将用于self.printer_combopack_start更改为pack_end This means that the widget is added on the right side of the Box instead of the left side.这意味着小部件添加在Box的右侧而不是左侧。

Alternatively you could also try using a Gtk.Grid as the container for your ComboBox 's it is less flexible but helps to get a more predictable result.或者,您也可以尝试使用Gtk.Grid作为ComboBox的容器,它不太灵活,但有助于获得更可预测的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM