Python gtk 模块,RadioButton() 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用gtk.RadioButton()

项目:griffith    作者:Strit    | 项目源码 | 文件源码
def _fill_container(container, items, options, id_name):
    for item in items:
        hbox = gtk.HBox()

        label_id = gtk.Label()
        label_id.set_text(str(getattr(item, id_name)))
        hbox.pack_start(label_id, expand=False)

        widget = gtk.RadioButton(label=options[0]) # first widget
        hbox.pack_start(widget, expand=False, padding=4)
        for option in options[1:]: # create rest of the widgets, use first one as a group
            next_widget = gtk.RadioButton(widget, label=option)
            hbox.pack_start(next_widget, expand=False, padding=4)

        label = gtk.Label()
        label.set_text(item.name)
        hbox.pack_start(label, padding=16, expand=False)

        hbox.show_all()
        label_id.hide()
        container.pack_start(hbox)
项目:id_photo    作者:aeifn    | 项目源码 | 文件源码
def delete_format(self, widget, data=None):
    # ???? ???????? gtk.RadioButton
    for format_id in self.format_radio:
      if format_id.get_active():
        # ?????????? ??????, ? ??????? ???????? ???????????? ?????????? ???? ?????
        dialog = gtk.Dialog('???????? ??????? "' + self.data['formats'][self.format_radio.index(format_id)]['name'] + '"', self.window, gtk.DIALOG_NO_SEPARATOR | gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_NO, gtk.RESPONSE_CANCEL, gtk.STOCK_YES, gtk.RESPONSE_OK))
        dialog.set_position(gtk.WIN_POS_CENTER_ALWAYS)
        dialog.set_resizable(False)
        dialog.set_border_width(10)
        self.confirmation_label = gtk.Label('?? ????????????? ?????? ??????? ?????? "' + self.data['formats'][self.format_radio.index(format_id)]['name'] + '"?')
        dialog.vbox.pack_start(self.confirmation_label, True, True, 5)
        dialog.show_all()
        response = dialog.run()
        if response == gtk.RESPONSE_CANCEL:
          dialog.hide()
          dialog.destroy()
        if response == gtk.RESPONSE_OK:
          # ??????? ??????
          name = self.data['formats'][self.format_radio.index(format_id)]['name']
          del self.data['formats'][self.format_radio.index(format_id)]
          config = open(self.path, 'wb')
          json.dump(self.data, config)
          config.close()
          self.format_radio[self.format_radio.index(format_id)].hide()
          if len(self.format_radio) == 1:
            pass
          elif self.format_radio.index(format_id) + 1 <= len(self.format_radio) - 1:
            self.format_radio[self.format_radio.index(format_id) + 1].set_active(True)
          elif self.format_radio.index(format_id) + 1 > len(self.format_radio) - 1:
            self.format_radio[self.format_radio.index(format_id) - 1].set_active(True)
          del self.format_radio[self.format_radio.index(format_id)]
          if len(self.format_radio) < 1:
            self.delete_button.set_sensitive(False)
            self.edit_button.set_sensitive(False)
          self.add_success_label.set_markup('<span foreground="#008600">"' + str(name) + '" ??????? ??????\n</span>')
          dialog.hide()
          dialog.destroy()
        break

  # ??? ??????? ???????????? ?????????? ?????? ???????
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def create_radio_hbox(self, label, value, trace, sensitivity_group, constraints=None):
        hbox_main = gtk.HBox()
        label_text = gtk.Label(label.title())
        label_text.set_alignment(0, 0.5)
        label_text.set_padding(8,8)
        radiobuttons = []
        if constraints is None:
            options = [value]
        else:
            options = constraints
        previous_button = None
        for option in options:
            new_button = gtk.RadioButton(previous_button, option)
            if option == value:
                new_button.set_active(True)
            radiobuttons.append(new_button)
            previous_button = new_button
        hbox_main.pack_start(label_text)
        for radiobutton in radiobuttons:
            hbox_main.pack_start(radiobutton)

        self.plugin_config_widgets.append(radiobuttons)
        self.plugin_config_traces.append(trace)
        sensitivity_group.append(label_text)
        sensitivity_group.append(radiobuttons)

        return hbox_main
项目:id_photo    作者:aeifn    | 项目源码 | 文件源码
def auto_execute(self, widget, data=None):
    # ???????? ????, ???? ?? ??????
    self.window.hide()
    gimp.context_push()
    # ????????? ?????? ?????????? UNDO
    self.image.undo_group_start()
    # ???????? "????-??????"
    if self.autolevels_check.get_active():
      auto_levels = True
    else:
      auto_levels = False
    # ???? ???????? gtk.RadioButton
    for format_id in self.format_radio:
      if format_id.get_active():
        # ????????? ??????? ??????? ? ??????? ? ???????
        tmp_dict = self.data['formats'][self.format_radio.index(format_id)]
        tmp_dict['resolution'] = self.data['properties']['resolution']
        shelf['format'] = tmp_dict

        # ???? gtk.RadioButton ??????? ???????? ???????, ??????? ????????? ????
        # ? ???????? ?????????? ???????? ?? ????????? ?? ???????????
        # ? ?????? ? ??????????? ????????? ???????
        self.create_id_foto(self.image, self.drawable, shelf['format'], auto_levels)
        if data == 'auto_execute':
          # ?????? ???????
          self.image.scale(self.mm_in_px(shelf['format']['width'], shelf['format']['resolution']), self.mm_in_px(shelf['format']['height'], shelf['format']['resolution']))
          if self.data['formats'][self.format_radio.index(format_id)]['angle']:
            self.angle(self.image, self.drawable, self.data['formats'][self.format_radio.index(format_id)]['angle'])
          if self.data['formats'][self.format_radio.index(format_id)]['oval']:
            self.oval(self.image, self.drawable)
          if self.data['formats'][self.format_radio.index(format_id)]['to_grayscale']:
            self.to_grayscale(self.image, self.drawable)
          if self.data['formats'][self.format_radio.index(format_id)]['gray_frame']:
            self.gray_frame(self.image)
          copys = self.data['formats'][self.format_radio.index(format_id)]['copys']
          paper = self.data['formats'][self.format_radio.index(format_id)]['paper']
          print_photo = self.data['formats'][self.format_radio.index(format_id)]['print_photo']
          self.print_functon(self.image, self.drawable, paper, copys, print_photo)
        break
    # ????????? ???????????? ?? ???????
    gimp.displays_flush()
    # ????????? ?????? ?????????? UNDO
    self.image.undo_group_end()
    gimp.context_pop()
    gtk.main_quit()

  # ??? ??????? ?????? ????????? ???????? ?????????
  # ? ??? ??????? ??????????? ?? ????????? ??????? ???? ??????????