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

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

项目:Gnome-Authenticator    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def __init__(self, parent, window, account):
        # Read default values
        self.window = window
        self.parent = parent
        self.account = account
        # Create needed widgets
        self.code_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        self.revealer = Gtk.Revealer()
        self.checkbox = Gtk.CheckButton()
        self.application_name = Gtk.Label(xalign=0)
        self.code_label = Gtk.Label(xalign=0)
        self.timer_label = Gtk.Label(xalign=0)
        self.accel = Gtk.AccelGroup()
        self.window.add_accel_group(self.accel)
        self.accel.connect(Gdk.keyval_from_name('C'), Gdk.ModifierType.CONTROL_MASK, 0, self.copy_code)
        self.accel.connect(Gdk.keyval_from_name("Enter"), Gdk.ModifierType.META_MASK, 0, self.toggle_code)
项目:sbrick-controller    作者:wintersandroid    | 项目源码 | 文件源码
def __init__(self, sbrick_configuration, sbrick_communications_store):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL, spacing=10, margin=5)
        self.set_homogeneous(False)
        self.sbrick_configuration = sbrick_configuration
        self.sbrick_communications_store = sbrick_communications_store
        self.sbrick_communications_store.add_observer(self)

        label = Gtk.Label(sbrick_configuration["name"])
        label.set_width_chars(20)
        label.set_justify(Gtk.Justification.LEFT)
        self.pack_start(label, False, True, 0)

        self.handler_ids = []
        self.sequence_player_handler_id = None

        self.button_play = Gtk.Button.new()
        self.button_play.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_MEDIA_PLAY, Gtk.IconSize.BUTTON))
        self.button_play.connect("clicked", self.on_play_clicked)
        self.pack_start(self.button_play, False, True, 0)

        self.checkPause = Gtk.CheckButton("Pause in Play All")
        self.checkPause.connect("toggled", self.on_pause_changed)
        self.pack_start(self.checkPause, False, True, 0)
        self.sbrick_communications = None
        self.sequence_player = None
项目:gedit-jshint    作者:Meseira    | 项目源码 | 文件源码
def __init__(self):
        #self._widget = Gtk.Notebook()
        self._widget = Gtk.Label("Configuration panel for JSHint Plugin")

        #grid = Gtk.Grid()
        #for i in range(30):
        #    button = Gtk.CheckButton("Button {}".format(i))
        #    button.set_tooltip_text("This is the button {}".format(i))
        #    grid.attach(button, i // 10, i % 10, 1, 1)
        #self._widget.append_page(grid, Gtk.Label("Enforcing"))

        #page = Gtk.Box()
        #page.add(Gtk.Label("Relaxing options"))
        #self._widget.append_page(page, Gtk.Label("Relaxing"))

        #page = Gtk.Box()
        #page.add(Gtk.Label("Environments options"))
        #self._widget.append_page(page, Gtk.Label("Environments"))
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self, exname, name, label=None, default_value=0, callback=None):
        Gtk.CheckButton.__init__(self, label)
        #cfg.ConfigUtils.__init__(self, exname)
        cfg.ConfigUtils.__dict__['__init__'](self, exname)
        self.set_use_underline(True)
        self.m_name = name
        self.m_callback = callback
        self.show()
        if default_value:
            s = "true"

        else:
            s = "false"
        self.set_bool(self.m_name, self.get_bool(self.m_name+"="+s))

        if self.get_bool(self.m_name):
            self.set_active(1)
        self._clicked_id = self.connect('toggled', self.on_clicked)
        self._watch_id = self.add_watch(self.m_name, self._watch_cb)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def add(self, question):
        """add a button and set up callback function.
        there should not be created more than one button with the same
        (c locale) name.
        return the button created.
        """
        if 'newline' in question and question.newline:
            self.newline()
        b = Gtk.CheckButton()

        if question.name.cval in self.m_button_dict:
            print >> sys.stderr, "Warning: The lessonfile contain several questions with the same name:", question.name.cval
            print >> sys.stderr, "         Things will not work as normal after this."
        self.m_button_dict[question.name.cval] = b
        self.m_name_list.append(question.name.cval)
        b.set_active(question.active)
        b.connect('toggled', self.on_checkbutton_toggled)
        b.m_cname = question.name.cval
        b.add(lessonfilegui.new_labelobject(question.name))
        b.show_all()
        self.attach(b, self.m_x, self.m_x+1, self.m_y, self.m_y+1)
        self.conditional_newline()
        return b
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def __init__(self, app, multiple_files):
        if multiple_files:
            text = _('Do you want to remove unfinished tasks?')
        else:
            text = _('Do you want to remove unfinished task?')
        super().__init__(app.window, Gtk.DialogFlags.MODAL,
                         Gtk.MessageType.WARNING, Gtk.ButtonsType.YES_NO,
                         text)
        self.app = app
        box = self.get_message_area()
        remember_button = Gtk.CheckButton(_('Do not ask again'))
        remember_button.set_active(
                not self.app.profile['confirm-download-deletion'])
        remember_button.connect('toggled', self.on_remember_button_toggled)
        box.pack_start(remember_button, False, False, 0)
        box.show_all()
项目:pedro    作者:saandial    | 项目源码 | 文件源码
def main():
    win = Gtk.Window()
    win.connect('destroy', Gtk.main_quit)
    win.set_default_size(Width, Height)

    global drawingarea
    drawingarea = Gtk.DrawingArea()
    drawingarea.connect('draw', draw)

    drawing_event_box = Gtk.EventBox()
    drawing_event_box.add(drawingarea)
    drawing_event_box.connect('button-press-event', mouse_pressed)
    drawing_event_box.connect('motion-notify-event', mouse_dragged)

    check_useIk = Gtk.CheckButton("Lock Forearm & Hand")
    check_useIk.set_active(True)
    check_useIk.connect("toggled", check_toggled)

    box = Gtk.VBox()
    box.pack_start(check_useIk, False, True, 0)
    box.pack_start(drawing_event_box, True, True, 0)
    win.add(box)
    win.show_all()
    Gtk.main()
项目:ez_gpg    作者:sgnn7    | 项目源码 | 文件源码
def _refresh_key_list(self):
        for child in self._key_list_box.get_children():
            self._key_list_box.remove(child)
            # child.destroy()
            # TODO: Disconnect notify::active signal

        for key in GpgUtils.get_gpg_keys():
            key_id = key[0]
            key_friendly_name = key[2]

            key_row = Gtk.CheckButton(GObject.markup_escape_text(key_friendly_name))
            key_row.get_children()[0].set_use_markup(True)
            key_row.set_name(key_id)

            key_row.connect('notify::active', self._key_changed_active_state)

            self._key_list_box.add(key_row)

        self._key_list_box.show_all()
项目:ibus-typing-booster    作者:mike-fabian    | 项目源码 | 文件源码
def on_fallback_check_button_toggled(self, check_button):
        '''
        The fallback check button in the header bar has been toggled

        :param toggle_button: The check button used to select whether
                              fallback fonts should be used.
        :type adjustment: Gtk.CheckButton object
        '''
        self._fallback = check_button.get_active()
        if _ARGS.debug:
            sys.stdout.write(
                'on_fallback_check_button_toggled() self._fallback = %s\n'
                %self._fallback)
        self._save_options()
        self._busy_start()
        GLib.idle_add(self._change_flowbox_font)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def pngcheckbutton(self, i):
        btn = Gtk.CheckButton()
        btn.add(gu.create_rhythm_image(const.RHYTHMS[i]))
        btn.show()
        btn.connect('clicked', self.select_element_cb, i)
        return btn
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self, exname, name):
        Gtk.Table.__init__(self)
        cfg.ConfigUtils.__init__(self, exname)
        self.m_varname = name
        self.g_buttons = fill_table(Gtk.CheckButton, self)
        for key, button in self.g_buttons.items():
            button.connect('toggled', self.on_toggled)
        for key in self.get_list('tones'):
            self.g_buttons[key].set_active(True)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def on_start_practise(self):
        self.m_t.start_practise()
        super(Gui, self).on_start_practise()
        if self.m_t.m_custom_mode:
            self.g_tone_selector.show()
            #self.g_random.show()
            self.g_tones_category.show()
            for w in self.g_cadences.get_children():
                w.destroy()
            self.g_cadences_category.show()
            self.g_cadences.show()
            self.m_t.m_cadences = {}
            if 'cadence' in self.m_t.m_P.blocklists:
                for idx, c in enumerate(self.m_t.m_P.blocklists['cadence']):
                    name = c.get('name', _("Unnamed"))
                    btn = Gtk.CheckButton(name)
                    btn.show()
                    btn.set_active(True)
                    self.m_t.m_cadences[idx] = True
                    btn.connect('toggled', self.on_cadences_toggled, idx)
                    self.g_cadences.pack_start(btn, False, False, 0)
        else:
            self.g_tone_selector.hide()
            self.g_tones_category.hide()
            self.g_cadences_category.hide()
            #self.g_random.hide()
        for key, button in self.g_buttons.items():
            button.set_sensitive(False)
        self.set_bool('tone_in_cadence', self.m_t.m_P.header.tone_in_cadence)
        self.std_buttons_start_practise()
        self.g_flashbar.delayed_flash(self.short_delay,
            _("Click 'New' to begin."))
        self.g_flashbar.require_size([
                _("Correct, but you have already solved this question"),
                _("Wrong, but you have already solved this question")])
项目:ez_gpg    作者:sgnn7    | 项目源码 | 文件源码
def __init__(self, app):
        super().__init__(app, 'encrypt_window', "Encrypt")

        builder = self.get_builder()

        self._key_list_box = builder.get_object('lst_key_selection')
        self._file_chooser = builder.get_object('fc_main')
        self._armor_output_check_box = builder.get_object('chk_armor')
        self._encrypt_spinner = builder.get_object('spn_encrypt')
        self._encrypt_button = builder.get_object('btn_do_encrypt')

        self._encryption_type = builder.get_object('ntb_encryption_type')
        self._password_field = builder.get_object('ent_password')
        self._confirm_password_field = builder.get_object('ent_confirm_password')

        # XXX: Armor param doesn't seem to produce armored output so we
        #      disable this for now
        self._armor_output_check_box.set_visible(False)

        for key in GpgUtils.get_gpg_keys():
            key_id = key[0]
            key_friendly_name = key[2]

            key_row = Gtk.CheckButton(key_friendly_name)
            key_row.set_name(key_id)

            self._key_list_box.add(key_row)

        self._key_list_box.show_all()

        builder.connect_signals({'password_changed': self._check_password_matching})

        self.add(builder.get_object('encrypt_window_vbox'))
项目:pomodoroTasks2    作者:liloman    | 项目源码 | 文件源码
def addReminder(self,desc,date):
        row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
        row.add(hbox)
        ldesc = Gtk.Label(desc, xalign=0)
        ldate = Gtk.Label(date, xalign=0)
        cdone = Gtk.CheckButton()
        hbox.pack_start(ldesc, True, True, 0)
        hbox.pack_start(ldate, False, True, 0)
        hbox.pack_start(cdone, False, True, 0)
        self.lsbReminders.add(row)

    #############
    #  Events   #
    #############
项目:ghetto_omr    作者:pohzhiee    | 项目源码 | 文件源码
def create_buttons(self):
        check_editable = Gtk.CheckButton("Editable")
        check_editable.set_active(True)
        check_editable.connect("toggled", self.on_editable_toggled)
        self.grid.attach(check_editable, 0, 2, 1, 1)

        check_cursor = Gtk.CheckButton("Cursor Visible")
        check_cursor.set_active(True)
        check_editable.connect("toggled", self.on_cursor_toggled)
        self.grid.attach_next_to(check_cursor, check_editable,
            Gtk.PositionType.RIGHT, 1, 1)

        radio_wrapnone = Gtk.RadioButton.new_with_label_from_widget(None,
            "No Wrapping")
        self.grid.attach(radio_wrapnone, 0, 3, 1, 1)

        radio_wrapchar = Gtk.RadioButton.new_with_label_from_widget(
            radio_wrapnone, "Character Wrapping")
        self.grid.attach_next_to(radio_wrapchar, radio_wrapnone,
            Gtk.PositionType.RIGHT, 1, 1)

        radio_wrapword = Gtk.RadioButton.new_with_label_from_widget(
            radio_wrapnone, "Word Wrapping")
        self.grid.attach_next_to(radio_wrapword, radio_wrapchar,
            Gtk.PositionType.RIGHT, 1, 1)

        radio_wrapnone.connect("toggled", self.on_wrap_toggled,
            Gtk.WrapMode.NONE)
        radio_wrapchar.connect("toggled", self.on_wrap_toggled,
            Gtk.WrapMode.CHAR)
        radio_wrapword.connect("toggled", self.on_wrap_toggled,
            Gtk.WrapMode.WORD)
项目:pycam    作者:SebKuzminsky    | 项目源码 | 文件源码
def __init__(self, start=False, change_handler=None):
        self.control = gtk.CheckButton()
        self.control.set_active(start)
        self.connect("toggled", change_handler)
项目:impress-writer    作者:CSEC-NITH    | 项目源码 | 文件源码
def create_buttons(self):
        check_editable = Gtk.CheckButton("Editable")
        check_editable.set_active(True)
        check_editable.connect("toggled", self.on_editable_toggled)
        self.text_grid.attach(check_editable, 0, 2, 1, 1)

        check_cursor = Gtk.CheckButton("Cursor Visible")
        check_cursor.set_active(True)
        check_editable.connect("toggled", self.on_cursor_toggled)
        self.text_grid.attach_next_to(check_cursor, check_editable,
                                 Gtk.PositionType.RIGHT, 1, 1)

        radio_wrapnone = Gtk.RadioButton.new_with_label_from_widget(None,
                                                                    "No Wrapping")
        self.text_grid.attach(radio_wrapnone, 0, 3, 1, 1)

        radio_wrapchar = Gtk.RadioButton.new_with_label_from_widget(
            radio_wrapnone, "Character Wrapping")
        self.text_grid.attach_next_to(radio_wrapchar, radio_wrapnone,
                                 Gtk.PositionType.RIGHT, 1, 1)

        radio_wrapword = Gtk.RadioButton.new_with_label_from_widget(
            radio_wrapnone, "Word Wrapping")
        self.text_grid.attach_next_to(radio_wrapword, radio_wrapchar,
                                 Gtk.PositionType.RIGHT, 1, 1)

        radio_wrapnone.connect("toggled", self.on_wrap_toggled,
                               Gtk.WrapMode.NONE)
        radio_wrapchar.connect("toggled", self.on_wrap_toggled,
                               Gtk.WrapMode.CHAR)
        radio_wrapword.connect("toggled", self.on_wrap_toggled,
                               Gtk.WrapMode.WORD)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, db, icons, pkgname):
        Gtk.HBox.__init__(self)
        self.set_spacing(StockEms.SMALL)
        self.set_border_width(2)

        # data
        self.app = Application("", pkgname)
        self.app_details = self.app.get_details(db)

        # checkbutton
        self.checkbutton = Gtk.CheckButton()
        self.checkbutton.pkgname = self.app.pkgname
        self.pack_start(self.checkbutton, False, False, 12)
        self.connect('realize', self._on_realize, icons, pkgname)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, db, icons, pkgname):
        Gtk.HBox.__init__(self)
        self.set_spacing(StockEms.SMALL)
        self.set_border_width(2)

        # data
        self.app = Application("", pkgname)
        self.app_details = self.app.get_details(db)

        # checkbutton
        self.checkbutton = Gtk.CheckButton()
        self.checkbutton.pkgname = self.app.pkgname
        self.pack_start(self.checkbutton, False, False, 12)
        self.connect('realize', self._on_realize, icons, pkgname)
项目:duck-feed    作者:h0m3stuck    | 项目源码 | 文件源码
def on_search_btn_pressed(self, btn):
        ddg_query = self.ddg_query_box.get_text()
        if not ddg_query == "":
            if ddg_query.lower() == "easter eggs?":\
                self.ddg_query_box.set_text("No.")
            if ddg_query.lower() == "philips exeter":
                ddg_query = "Philips Academy, Andover"
                self.ddg_query_box.set_text("Philips Academy, Andover")

            def get_feeds_from_query():
                potential_feed_sites = get_links(ddg_query)

                with concurrent.futures.ProcessPoolExecutor() as executor:
                    feed_tuples = executor.map(process_site, potential_feed_sites)
                    for feed_tuple in feed_tuples:
                        if feed_tuple is not None:
                            GLib.idle_add(add_feed, feed_tuple)
                    GLib.idle_add(reenable_controls)

            def add_feed(feed_tuple):
                feed = feed_tuple[0]
                feed_link = feed_tuple[1]
                sub_btn = Gtk.CheckButton()
                sub_btn.connect("toggled", self.on_sub_btn_clicked, feed_link)

                self.feed_grid.attach(sub_btn, 0, self.current_feed_grid_row, 1, 1)
                sub_btn.show()

                title_label = Gtk.Label(feed["channel"]["title"])
                title_label.set_line_wrap(True)
                self.feed_grid.attach(title_label, 1, self.current_feed_grid_row, 1, 1)
                title_label.show()

                try:
                    feed_desc = feed["channel"]["description"]
                except KeyError:
                    feed_desc = ""

                desc_label = Gtk.Label(feed_desc)
                desc_label.set_line_wrap(True)
                self.feed_grid.attach(desc_label, 2, self.current_feed_grid_row, 1, 1)
                desc_label.show()

                self.current_feed_grid_row += 1

                print("Adding to box: ", feed_link)

            def reenable_controls():
                # Re-enable boxes
                self.ddg_query_box.set_sensitive(True)
                self.search_btn.set_sensitive(True)

            thread = threading.Thread(target=get_feeds_from_query)
            thread.daemon = True
            thread.start()
            # Disable boxes
            self.ddg_query_box.set_sensitive(False)
            self.search_btn.set_sensitive(False)
            print("Starting query async...")
项目:sbrick-controller    作者:wintersandroid    | 项目源码 | 文件源码
def __init__(self, channel, sbrick_channel):
        Gtk.Frame.__init__(self)

        self.sbrickChannel = sbrick_channel
        self.channel = channel
        self.sbrick = None
        self.set_label("Channel: %d - %s" % ((channel + 1), self.sbrickChannel["name"]))

        self.vbox = Gtk.FlowBox()  # , orientation=Gtk.Orientation.HORIZONTAL, spacing=3)
        self.vbox.set_border_width(2)
        self.vbox.set_max_children_per_line(7)
        self.vbox.set_min_children_per_line(7)
        self.vbox.set_selection_mode(Gtk.SelectionMode.NONE)
        self.add(self.vbox)

        # self.vbox.pack_start(Gtk.Label("PWM: "), True, False, 0)
        self.vbox.add(Gtk.Label("PWM: "))
        self.pwmAdjustment = Gtk.Adjustment(255, 0, 255, 5, 10, 0.0)
        self.spinPWM = Gtk.SpinButton.new(self.pwmAdjustment, 5, 0)
        # self.vbox.pack_start(self.spinPWM, True, False, 0)
        self.vbox.add(self.spinPWM)
        self.pwmAdjustment.connect("value-changed", self.on_pwm_changed)

        self.checkReverse = Gtk.CheckButton("Reverse")
        self.checkReverse.connect("toggled", self.on_reverse_changed)
        self.vbox.add(self.checkReverse)
        # self.vbox.pack_start(self.checkReverse, True, False, 0)

        self.checkTime = Gtk.CheckButton("Time MS:")
        # self.vbox.pack_start(self.checkTime, True, False, 0)
        self.vbox.add(self.checkTime)
        self.checkTime.connect("toggled", self.on_time_toggled)

        self.timeAdjustment = Gtk.Adjustment(1000, -1, 30000, 100, 1000, 0.0)
        self.spinTime = Gtk.SpinButton.new(self.timeAdjustment, 10, 0)
        # self.vbox.pack_start(self.spinTime, True, False, 0)
        self.vbox.add(self.spinTime)
        self.spinTime.set_sensitive(False)

        self.checkBrake = Gtk.CheckButton("Break Stop")
        # self.vbox.pack_start(self.checkBrake, True, False, 0)
        self.vbox.add(self.checkBrake)

        self.buttonGo = Gtk.Button("Start")
        self.buttonGo.connect("clicked", self.on_switch_go_clicked)
        # self.vbox.pack_start(self.buttonGo, True, False, 0)
        self.vbox.add(self.buttonGo)

        self.set_sensitive(False)
        self.on = False
        self.pwm = 0
        self.reverse = False

    # noinspection PyUnusedLocal
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def _build_search(self, widget):
        '''Builds the search bar.'''
        self.srchtab = Gtk.HBox()
        # close button
        close = Gtk.Image()
        close.set_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU)
        eventbox = Gtk.EventBox()
        eventbox.add(close)
        eventbox.connect("button-release-event", self._close)
        self.srchtab.pack_start(eventbox, False, False, 3)
        # label
        label = Gtk.Label(label="Find:")
        self.srchtab.pack_start(label, False, False, 3)
        # entry
        self.search_entry = Gtk.Entry()
        self.search_entry.set_tooltip_text("Type here the phrase you want to find")
        self.search_entry.connect("activate", self._find, "next")
        self.search_entry.connect("changed", self._find_cb, "find")
        self.srchtab.pack_start(self.search_entry, False, False, 3)
        # find next button
        if self.small:
            but_text = ''
        else:
            but_text = 'Next'
        butn = SemiStockButton(but_text, Gtk.STOCK_GO_DOWN)
        butn.set_relief(Gtk.ReliefStyle.NONE)
        butn.connect("clicked", self._find, "next")
        butn.set_tooltip_text("Find the next ocurrence of the phrase")
        self.srchtab.pack_start(butn, False, False, 3)
        # find previous button
        if self.small:
            but_text = ''
        else:
            but_text = ('Previous')
        butp = SemiStockButton(but_text, Gtk.STOCK_GO_UP)
        butp.set_relief(Gtk.ReliefStyle.NONE)
        butp.connect("clicked", self._find, "previous")
        butp.set_tooltip_text("Find the previous ocurrence of the phrase")
        self.srchtab.pack_start(butp, False, False, 3)
        # make last two buttons equally width
        # MEOW
        wn,hn = butn.get_preferred_size()
        wp,hp = butp.get_preferred_size()
        newwidth = max(wn.width, wp.width)
        butn.set_size_request(newwidth, hn.height)
        butp.set_size_request(newwidth, hp.height)
        # Match case CheckButton
        butCase = Gtk.CheckButton(('Match case'))
        butCase.set_active(self._matchCaseValue)
        butCase.connect("clicked", self._matchCase)
        # FIXME
        # current version of Gtk.TextIter doesn't support SEARCH_CASE_INSENSITIVE
        #butCase.show()
        #self.srchtab.pack_start(butCase, expand=False, fill=False, padding=3)
        self.pack_start(self.srchtab, False, False, 0)
        # Results
        self._resultsLabel = Gtk.Label(label="")
        self.srchtab.pack_start(self._resultsLabel, False, False, 3)
        self.searching = False
项目:luminance    作者:craigcabrey    | 项目源码 | 文件源码
def __init__(self, lights, initial_selection, *args, **kwargs):
        super().__init__(
            *args,
            can_focus=False,
            shadow_type=Gtk.ShadowType.NONE,
            visible=True,
            **kwargs
        )

        builder = Gtk.Builder()
        builder.add_from_resource(get_resource_path('ui/group-detail.ui'))
        builder.connect_signals(self)

        content = builder.get_object('content-wrapper')
        lights_list = builder.get_object('light-list')

        self.lights = lights
        self._selected_lights = initial_selection

        for light in self.lights:
            row = Gtk.ListBoxRow(
                activatable=False,
                can_focus=False,
                visible=True
            )

            box = Gtk.Box(
                can_focus=False,
                visible=True,
                margin_start=12,
                margin_end=6,
                margin_top=8,
                margin_bottom=8
            )

            check_box = Gtk.CheckButton(
                active=light.light_id in self.selected_lights,
                border_width=6,
                can_focus=True,
                draw_indicator=True,
                label=light.name,
                receives_default=False,
                visible=True
            )

            check_box.connect('toggled', self._on_light_toggle, light)

            box.add(check_box)
            row.add(box)
            lights_list.add(row)

        self.add(content)
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def _build_audio_vbox(self):
        """
        """
        title = Gtk.Label("Audio Source")
        title.set_margin_top(6)

        self.mic_sources = Gtk.ComboBoxText()
        for source in self.pipeline.audio_sources:
            self.mic_sources.append_text(source.description)
            self.sources_list.append(source.description)
        self.mic_sources.connect("changed", self.on_input_change)
        self.mic_sources.set_margin_left(24)

        self.mute_checkbutton = Gtk.CheckButton("Mute (soon)")
        self.mute_checkbutton.connect("toggled", self.on_mute_toggle)
        self.mute_checkbutton.set_sensitive(False)

        self.output_sinks = Gtk.ComboBoxText()
        index = 0
        for description, device in self.pipeline.speaker_sinks.items():
            self.output_sinks.append_text(description)
            self.sinks_list.append(description)
            if device == self.pipeline.speaker_sink.get_property("device"):
                self.output_sinks.set_active(index)
            index += 1
        self.output_sinks.connect("changed", self.on_output_change)
        self.output_sinks.set_margin_left(24)

        self.audio_confirm_button = self._build_confirm_changes_button(
            callback=self.on_confirm_clicked)

        separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
        separator.set_margin_top(6)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        vbox.set_margin_right(6)
        _pack_widgets(vbox,
                      title,
                      self.mic_sources,
                      self.mute_checkbutton,
                      self.output_sinks,
                      self.audio_confirm_button,
                      separator)
        self._make_scrolled_window(vbox)
        return vbox
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def _build_newfile_vbox(self):
            """
            """
            self.folder_chooser_button = Gtk.FileChooserButton(
                action=Gtk.FileChooserAction.SELECT_FOLDER)
            self.folder_chooser_button.set_title("Select a folder")
            self.folder_chooser_button.connect("file-set", self.on_folder_selected)
            self.folder_chooser_button.set_margin_top(6)

            name_label = Gtk.Label("Name ")
            self.name_entry = Gtk.Entry()
            self.name_entry.set_width_chars(25)
            self.name_entry.set_input_purpose(Gtk.InputPurpose.ALPHA)
            self.name_entry.set_placeholder_text("Type a filename")
            self.name_entry.connect("changed", self.on_entry_change)
            name_hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
            _pack_widgets(name_hbox, name_label, self.name_entry)

            self.automatic_naming_checkbutton = Gtk.CheckButton()
            self.automatic_naming_checkbutton.set_active(True)
            self.automatic_naming_checkbutton.set_sensitive(False)  # DEV
            automatic_naming_label = Gtk.Label("Make Unique filename")
            automatic_naming_hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
            _pack_widgets(automatic_naming_hbox,
                          self.automatic_naming_checkbutton,
                          automatic_naming_label)

            radiobutton_hbox = self._build_format_group()

            self.store_confirm_button = self._build_confirm_changes_button(
                callback=self.on_confirm_clicked)
            # Label only used at initialization
            self.store_confirm_button.set_label("Create")

            vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
            _pack_widgets(vbox,
                          self.folder_chooser_button,
                          name_hbox,
                          automatic_naming_hbox,
                          radiobutton_hbox,
                          self._audiovideo_format_hbox,
                          self.store_confirm_button)
            return vbox
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def _build_settings_vbox(self):
        title = Gtk.Label("Settings")
        title.set_margin_bottom(6)

        self.text_overlay_entry = Gtk.Entry()
        self.text_overlay_entry.set_placeholder_text("Text displayed on screen")
        self.text_overlay_entry.set_width_chars(30)
        self.text_overlay_entry.connect("changed", self.on_text_change)
        self.text_overlay_entry.set_sensitive(True)  # DEV

        self.text_position_combobox = Gtk.ComboBoxText()
        for position in self.positions:
            self.text_position_combobox.append_text(position)
        self.text_position_combobox.set_active(0)
        self.text_position_combobox.set_margin_left(24)
        self.text_position_combobox.set_sensitive(False)  # DEV

        self.hide_text_checkbutton = Gtk.CheckButton("Hide Text")
        self.hide_text_checkbutton.connect("toggled", self.on_hide_text_toggle)

        self.image_chooser_button = Gtk.FileChooserButton()
        self.image_chooser_button.set_title("Select an image to display")
        self.image_chooser_button.connect("file-set", self.on_image_selected)
        self.image_chooser_button.set_sensitive(True)  # DEV

        self.image_position_combobox = Gtk.ComboBoxText()
        for position in self.positions:
            self.image_position_combobox.append_text(position)
        self.image_position_combobox.set_active(1)
        self.image_position_combobox.set_margin_left(24)
        self.image_position_combobox.set_sensitive(False)  # DEV

        self.hide_image_checkbutton = Gtk.CheckButton("Hide Image")
        self.hide_image_checkbutton.connect(
            "toggled", self.on_hide_image_toggle)

        self.settings_confirm_button = self._build_confirm_changes_button(
                callback=self.on_confirm_clicked)
        self.settings_confirm_button.set_label("Confirm")
        self.settings_confirm_button.set_size_request(250, 20)

        separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
        separator.set_margin_top(6)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        vbox.set_margin_right(6)
        _pack_widgets(vbox,
                      title,
                      self.text_overlay_entry,
                      self.text_position_combobox,
                      self.hide_text_checkbutton,
                      self.image_chooser_button,
                      self.image_position_combobox,
                      self.hide_image_checkbutton,
                      self.settings_confirm_button,
                      separator)
        self._make_scrolled_window(vbox)
        return vbox