Python gi.repository.Gtk 模块,RadioButton() 实例源码

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

项目:mcg    作者:coderkun    | 项目源码 | 文件源码
def __init__(self, builder):
        GObject.GObject.__init__(self)

        self._temp_button = None
        self._stack_switcher = builder.get_object('header-panelswitcher')
        for child in self._stack_switcher.get_children():
            if type(child) is Gtk.RadioButton:
                child.connect('clicked', self.on_clicked)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def create_mainwin_ui(self):
        qbox = gu.hig_dlg_vbox()
        self.g_notebook.append_page(qbox, Gtk.Label(label=_("Questions")))
        gu.bLabel(qbox, _("Enter new chords using the mouse"), False, False)
        hbox = gu.bHBox(qbox, False, False)
        self.g_displayer = mpd.musicdisplayer.ChordEditor()
        self.g_displayer.connect('clicked', self.on_displayer_clicked)
        self.g_displayer.clear(2)
        gu.bLabel(hbox, "")
        hbox.pack_start(self.g_displayer, False)
        gu.bLabel(hbox, "")
        ##
        self.g_question_name = Gtk.Entry()
        qbox.pack_start(gu.hig_label_widget(_("Question title:", True, True, 0), self.g_question_name, None), False)
        self.g_navinfo = Gtk.Label(label="")
        qbox.pack_start(self.g_navinfo, False)

        ##
        self.m_P = EditorLessonfile()
        cvbox = Gtk.VBox()
        self.g_notebook.append_page(cvbox, Gtk.Label(label=_("Lessonfile header")))
        ## Header section
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
        self.g_title = Gtk.Entry()
        cvbox.pack_start(gu.hig_label_widget(_("File title:", True, True, 0), self.g_title,
                        sizegroup))
        self.g_content_chord = Gtk.RadioButton(None, "chord")
        self.g_content_chord_voicing = Gtk.RadioButton(self.g_content_chord, "chord-voicing")
        self.g_content_idbyname = Gtk.RadioButton(self.g_content_chord, "id-by-name")
        box = Gtk.HBox()
        box.pack_start(self.g_content_chord, True, True, 0)
        box.pack_start(self.g_content_chord_voicing, True, True, 0)
        box.pack_start(self.g_content_idbyname, True, True, 0)
        cvbox.pack_start(gu.hig_label_widget(_("Content:", True, True, 0), box, sizegroup))
        self.g_random_transpose = Gtk.Entry()
        cvbox.pack_start(gu.hig_label_widget(_("Random transpose:", True, True, 0),
            self.g_random_transpose, sizegroup))
        #
        #self.g_statusbar = Gtk.Statusbar()
        #self.toplevel_vbox.pack_start(self.g_statusbar, False)
        self.update_appwin()
项目:dell-recovery    作者:dell    | 项目源码 | 文件源码
def translate_widgets(widgets):
    """Translates all widgets to the specified domain"""
    widgets.set_translation_domain(DOMAIN)
    for widget in widgets.get_objects():
        if isinstance(widget, Gtk.Label):
            widget.set_property('can-focus', False)
            widget.set_text(_(widget.get_text()))
        elif isinstance(widget, Gtk.RadioButton):
            widget.set_label(_(widget.get_label()))
        elif isinstance(widget, Gtk.Button):
            widget.set_label(_(widget.get_label()))
        elif isinstance(widget, Gtk.Window):
            title = widget.get_title()
            if title:
                widget.set_title(_(widget.get_title()))
项目:MokaPlayer    作者:vedard    | 项目源码 | 文件源码
def on_sort_radio_toggled(self, widget):
        if widget is None or widget.get_active() or not isinstance(widget, Gtk.RadioButton):
            order = AbstractPlaylist.OrderBy.DEFAULT

            if self.radio_sort_default.get_active():
                order = AbstractPlaylist.OrderBy.DEFAULT
            elif self.radio_sort_artist.get_active():
                order = AbstractPlaylist.OrderBy.ARTIST
            elif self.radio_sort_album.get_active():
                order = AbstractPlaylist.OrderBy.ALBUM
            elif self.radio_sort_title.get_active():
                order = AbstractPlaylist.OrderBy.TITLE
            elif self.radio_sort_length.get_active():
                order = AbstractPlaylist.OrderBy.LENGTH
            elif self.radio_sort_year.get_active():
                order = AbstractPlaylist.OrderBy.YEAR
            elif self.radio_sort_added.get_active():
                order = AbstractPlaylist.OrderBy.ADDED
            elif self.radio_sort_played.get_active():
                order = AbstractPlaylist.OrderBy.PLAYED

            self.userconfig['grid']['sort']['desc'] = self.chk_sort_desc.get_active()
            self.userconfig['grid']['sort']['field'] = order.name

            threading.Thread(target=self.userconfig.save).start()
            self.has_flowbox_album_loaded = False
            self.has_flowbox_artist_loaded = False
            self.__show_current_playlist()
项目:ghetto_omr    作者:pohzhiee    | 项目源码 | 文件源码
def __init__(self, name):
        Gtk.RadioButton.__init__(self)
        self.name = name
        self.set_mode(False)
        self.connect("toggled", self.tool_btn_toggled)
        self.set_mode(False)
        self.set_relief(Gtk.ReliefStyle.NONE)

        file_path = "icons/" +name + ".svg"
        pix = GdkPixbuf.Pixbuf.new_from_file(file_path)
        pix1=pix.scale_simple(35,35,GdkPixbuf.InterpType.BILINEAR)
        img = Gtk.Image.new_from_pixbuf(pix1)
        self.set_image(img)
项目:ghetto_omr    作者:pohzhiee    | 项目源码 | 文件源码
def __init__(self, name):
        Gtk.RadioButton.__init__(self)
        self.name = name
        self.set_mode(False)
        self.connect("toggled", self.tool_btn_toggled)
        self.set_mode(False)
        self.set_relief(Gtk.ReliefStyle.NONE)

        file_path = "../icons/" +name + ".svg"
        pix = GdkPixbuf.Pixbuf.new_from_file(file_path)
        pix1=pix.scale_simple(35,35,GdkPixbuf.InterpType.BILINEAR)
        img = Gtk.Image.new_from_pixbuf(pix1)
        self.set_image(img)
项目:draobpilc    作者:awamper    | 项目源码 | 文件源码
def _update_switcher(self):
        for button in self._switcher.get_children():
            if not isinstance(button, Gtk.RadioButton): continue

            for label in button.get_children():
                if not isinstance(label, Gtk.Label): continue
                processor = self._get_for_title(label.get_text())
                if not processor: continue

                button.set_sensitive(processor.get_sensitive())
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def _build_format_section(self, radio_button_label, format_labels,
                              callback_radio=None, callback_combo=None,
                              radio_group=None):
        """
        """
        radio_button = Gtk.RadioButton(
            radio_button_label, group=radio_group)
        if callback_radio:
            radio_button.connect("toggled", callback_radio)

        text_label = Gtk.Label("Format : ")
        combo_box = Gtk.ComboBoxText()
        for label in format_labels:
            combo_box.append_text(label)
            combo_box.set_active(0)
        # This version accept only one format for each stream type.
        # There is not point to allow user to use this combo box.
        # That way the format is displayed as information.
        combo_box.set_sensitive(False)
        if callback_combo:
            combo_box.connect("changed", callback_combo)

        hbox = Gtk.Box(Gtk.Orientation.HORIZONTAL)
        hbox.set_margin_left(24)
        _pack_widgets(hbox, text_label, combo_box)

        return (radio_button, hbox, combo_box)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self):
        Gtk.RadioButton.__init__(self)
        self.set_mode(False)
        _Tile.__init__(self)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self):
        Gtk.RadioButton.__init__(self)
        self.set_mode(False)
        _Tile.__init__(self)
项目:funky    作者:giannitedesco    | 项目源码 | 文件源码
def __init__(self, p, prev = None):
        super(PlayerRow, self).__init__()

        vbox = Gtk.Box(orientation = Gtk.Orientation.VERTICAL,
                    spacing = 5)
        self.add(vbox)

        hbox = Gtk.Box(orientation = Gtk.Orientation.HORIZONTAL,
                    spacing = 20)

        self.rb = Gtk.RadioButton.new_from_widget(prev)
        self.rb.set_sensitive(False)

        self.col = Gtk.ColorButton.new_with_rgba(colors[p.seat_nr])
        self.col.set_sensitive(False)
        self.col.props.title = 'hi'

        self.name = Gtk.Label(xalign = 0)

        self.m = Gtk.Label()

        self.cities = Gtk.Label()

        hbox.pack_start(self.rb, False, False, 0)
        hbox.pack_start(self.col, False, False, 0)
        hbox.pack_start(self.name, True, True, 5)
        hbox.pack_start(self.cities, False, True, 5)
        hbox.pack_start(self.m, False, True, 5)
        vbox.pack_start(hbox, True, True, 5)

        self.plants = PlantList(selectable = False, show_text = True)
        vbox.pack_start(self.plants, True, True, 0)

        self.show_money = True
        self.update_name(p.name)
        self.update_cities(p.nr_cities, p.capacity)
        self.update_money(p.money)
        self.update_plants(p.plants)
        self.update_stock(p.stock)

        self.seat_nr = p.seat_nr
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def create_list(self, options_list):

        message_dialog = Gtk.MessageDialog(
            None,
            0,
            Gtk.MessageType.QUESTION,
            Gtk.ButtonsType.OK,
            _("Choose version:")
            )
        message_dialog.set_default_size(360, 0)

        content_area = message_dialog.get_content_area()
        content_area.set_property('margin_top', 10)
        content_area.set_property('margin_bottom', 10)
        content_area.set_property('margin_left', 10)
        content_area.set_property('margin_right', 10)

        options_list = options_list.split(', ')

        def cb_radiobutton(radiobutton):
            self.option = radiobutton.get_label()

        box = Gtk.Box(
            orientation=Gtk.Orientation.VERTICAL,
            spacing = 10
            )

        radiobutton1 = Gtk.RadioButton(
            label = options_list[0]
            )
        radiobutton1.connect('clicked', cb_radiobutton)
        box.pack_start(radiobutton1, True, True, 0)

        for i in range(1, len(options_list)):
            radiobutton = Gtk.RadioButton(
                label = options_list[i]
                )
            radiobutton.connect('clicked', cb_radiobutton)
            radiobutton.join_group(radiobutton1)
            box.pack_start(radiobutton, True, True, 0)

        content_area.pack_start(box, True, True, 0)

        self.option = options_list[0]

        message_dialog.show_all()
        response = message_dialog.run()
        message_dialog.destroy()

        return self.option
项目:games_nebula_goglib_scripts    作者:yancharkin    | 项目源码 | 文件源码
def create_main_window(self):

        self.main_window = Gtk.Window(
            title = _("Eador: Genesis"),
            type = Gtk.WindowType.TOPLEVEL,
            window_position = Gtk.WindowPosition.CENTER_ALWAYS,
            resizable = False,
            default_width = 360,
            default_height = 180
            )
        self.main_window.connect('delete-event', self.quit_app)

        label = Gtk.Label(
            halign = Gtk.Align.FILL,
            label = _("Mode:"),
            )

        radiobutton_windowed = Gtk.RadioButton(
            label = _("Windowed"),
            name = 'windowed'
            )
        radiobutton_windowed.connect('toggled', self.cb_radiobuttons)

        radiobutton_fullscreen = Gtk.RadioButton(
            label = _("Fullscreen"),
            name = 'fullscreen'
            )
        radiobutton_fullscreen.join_group(radiobutton_windowed)
        radiobutton_fullscreen.connect('toggled', self.cb_radiobuttons)

        if not self.fullscreen:
            radiobutton_windowed.set_active(True)
        else:
            radiobutton_fullscreen.set_active(True)

        button_save = Gtk.Button(
            label = _("Save and quit"),
            )
        button_save.connect('clicked', self.cb_button_save)

        box = Gtk.Box(
            margin_top = 10,
            margin_bottom = 10,
            margin_left = 10,
            margin_right = 10,
            spacing = 10,
            orientation = Gtk.Orientation.VERTICAL
            )

        box.pack_start(label, True, True, 0)
        box.pack_start(radiobutton_windowed, True, True, 0)
        box.pack_start(radiobutton_fullscreen, True, True, 0)
        box.pack_start(button_save, True, True, 0)

        self.main_window.add(box)
        self.main_window.show_all()
项目:funky    作者:giannitedesco    | 项目源码 | 文件源码
def __init__(self, game):
        def update_cb(game, p):
            r = self.get_row_for_seat_nr(p.seat_nr)
            r.update_money(p.money)
            r.update_name(p.name)
            r.update_cities(p.nr_cities, p.capacity)
            r.update_plants(p.plants)
            r.update_stock(p.stock)

        def join_cb(game, p):
            r = PlayerRow(p, prev = self.prev)
            self.prev = r.rb
            self.insert(r, -1)
            self.show_all()

        def leave_cb(game, p):
            r = self.get_row_for_seat_nr(p.seat_nr)
            self.remove(r)

        def current_player_cb(game, cp, iam):
            if cp < 0:
                self.null.set_active(True)
                return

            r = self.get_row_for_seat_nr(cp)
            r.rb.set_active(True)

        def seq_cb(game, seq):
            self.mf = dict(enumerate(seq[:self.game.nr_players]))
            self.rf = dict(map(lambda x:reversed(x),
                enumerate(seq[:self.game.nr_players])))
            self.invalidate_sort()

        def i_am_cb(game, i_am):
            for idx in xrange(self.game.nr_players):
                r = self.get_row_for_seat_nr(idx)
                r.set_show_money(idx == i_am)

        def sort_cb(a, b):
            if not self.rf:
                return cmp(a.seat_nr, b.seat_nr)
            return cmp(self.rf[a.seat_nr], self.rf[b.seat_nr])

        super(PlayerList, self).__init__()
        self.game = game

        self.set_can_focus(False)
        self.set_selection_mode(Gtk.SelectionMode.NONE)
        self.null = Gtk.RadioButton()
        self.prev = self.null
        self.mf = None
        self.rf = None

        self.game.connect('update_current_player', current_player_cb)
        self.game.connect('player_join', join_cb)
        self.game.connect('player_update', update_cb)
        self.game.connect('player_leave', leave_cb)
        self.game.connect('update_player_sequence', seq_cb)
        self.game.connect('update_i_am', i_am_cb)

        self.set_sort_func(sort_cb)