def __init__(self, parent, sbrick_configuration):
Gtk.Dialog.__init__(self, "Configure SBrick", parent, 0,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OK, Gtk.ResponseType.OK))
self.sbrickConfiguration = sbrick_configuration
self.set_default_size(150, 100)
self.channelTypeStore = Gtk.ListStore(str, str)
self.channelTypeStore.append(["motor", "Motor"])
self.channelTypeStore.append(["servo", "Servo"])
self.content = self.get_content_area()
hbox = Gtk.FlowBox()
hbox.set_max_children_per_line(2)
hbox.set_min_children_per_line(2)
hbox.set_selection_mode(Gtk.SelectionMode.NONE)
hbox.add(Gtk.Label("Name:"))
self.edit_brick_name = Gtk.Entry()
self.edit_brick_name.set_max_length(20)
hbox.add(self.edit_brick_name)
hbox.add(Gtk.Label("Address:"))
self.edit_brick_address = Gtk.Entry()
self.edit_brick_address.set_max_length(17)
hbox.add(self.edit_brick_address)
self.content.pack_start(hbox, False, True, 0)
self.channel1_id_edit, self.channel1_name_edit, self.channel1_combo_type = self.create_channel_box(1)
self.channel2_id_edit, self.channel2_name_edit, self.channel2_combo_type = self.create_channel_box(2)
self.channel3_id_edit, self.channel3_name_edit, self.channel3_combo_type = self.create_channel_box(3)
self.channel4_id_edit, self.channel4_name_edit, self.channel4_combo_type = self.create_channel_box(4)
if "name" in self.sbrickConfiguration:
self.edit_brick_name.set_text(self.sbrickConfiguration["name"])
if "addr" in self.sbrickConfiguration:
self.edit_brick_address.set_text(self.sbrickConfiguration["addr"])
self.set_from_config(0, self.channel1_id_edit, self.channel1_name_edit, self.channel1_combo_type)
self.set_from_config(1, self.channel2_id_edit, self.channel2_name_edit, self.channel2_combo_type)
self.set_from_config(2, self.channel3_id_edit, self.channel3_name_edit, self.channel3_combo_type)
self.set_from_config(3, self.channel4_id_edit, self.channel4_name_edit, self.channel4_combo_type)
self.show_all()
self.connect('response', self.on_response)
# noinspection PyUnusedLocal
SBrickConfigureDialog.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录