从所有行中选择一个单选按钮,单击GTK+python,PyGObj

2024-05-13 01:38:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一张有两个盒子的表格。上框和下框。在上面的盒子里我有两个按钮。一个按钮是addrow,另一个按钮是Select单选按钮A。你知道吗

在下拉框中,我有一个包含多行的列表框。所有的行都是相似的,每行有两个单选按钮,A和B。当您单击Select单选按钮时,所有行上的A单选按钮都应被选中。你知道吗

我该怎么做?你知道吗

因为版权问题,我不想在这里显示我的代码。但我认为应该有某种方法来说明:

def on_button_click(self, button):
   self.Listbox.Row_all.Radio_button_A.checked()

我很感激你的帮助

更新: 这是我代码的一部分。你知道吗

        # Adding new row to the list

    self.row = Gtk.ListBoxRow()
    self.row.set_border_width(5)

    downBox_main = Gtk.HBox()
    downBox_main.set_halign(Gtk.Align.CENTER)

    videoIcon = Gio.ThemedIcon(name="audio-x-generic")
    videoImage = Gtk.Image.new_from_gicon(videoIcon, Gtk.IconSize.DIALOG)

    vbox_link_and_butons = Gtk.VBox()
    vbox_link_and_butons.set_border_width(5)

    link_entry = Gtk.Entry()
    link_entry.set_placeholder_text("Paste the video link here")

    quality_hbox = Gtk.HBox()

    btnsQuality = [("4320p"), ("2160p"), ("1440p"), ("1080p"), ("720p"), ("480p")]
    for buttonNames in btnsQuality:
        btn = Gtk.ToggleButton()
        btn.set_label(buttonNames)
        quality_hbox.pack_start(btn, False, False, 2)

    radiobtn_box = Gtk.VBox()
    radiobtn_box.set_valign(Gtk.Align.CENTER)

    rbVideo = Gtk.RadioButton.new_with_label_from_widget(None, "Video")
    rbAudio = Gtk.RadioButton.new_from_widget(rbVideo)
    rbAudio.set_label("Audio")

    btnDownload = Gtk.Button()
    download_icon = Gio.ThemedIcon(name="down")
    image = Gtk.Image.new_from_gicon(download_icon, Gtk.IconSize.BUTTON)
    btnDownload.add(image)

    downBox_main.pack_start(videoImage, False, False, 0)
    vbox_link_and_butons.pack_start(link_entry, True, True, 0)
    vbox_link_and_butons.pack_start(quality_hbox, True, True, 3)
    radiobtn_box.pack_start(rbVideo, False, True, 0)
    radiobtn_box.pack_start(rbAudio, False, True, 0)
    downBox_main.pack_start(vbox_link_and_butons, True, False, 8)
    downBox_main.pack_start(radiobtn_box, True, True, 0)
    downBox_main.pack_start(btnDownload, True, True, 3)
    self.row.add(downBox_main)
    self.downBox.add(self.row)
    self.downBox.show_all()

我试着按每一排的单选按钮。有许多行具有相同的结构。你知道吗


Tags: andselffalsetruegtknewmainlink