python类FlowBox()的实例源码

emoji_picker.py 文件源码 项目:ibus-typing-booster 作者: mike-fabian 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def on_emoji_selected(self, dummy_flowbox, flowbox_child):
        '''
        Signal handler for selecting an emoji in the flowbox
        via the flowbox selection

        Not called if long press gestures are used to show the
        skin tone popovers. In that case, emoji selection is handled
        in on_flowbox_event_box_button_release() instead.

        :param dummy_flowbox: The flowbox displaying the Emoji
        :type dummy_flowbox: Gtk.FlowBox object
        :param flowbox_child: The child object containing the selected emoji
        :type flowbox_child: Gtk.FlowBoxChild object
        '''
        if _ARGS.debug:
            sys.stdout.write("on_emoji_selected()\n")
        event_box = flowbox_child.get_child()
        self._emoji_event_box_selected(event_box)
        return Gdk.EVENT_PROPAGATE
icons_select.py 文件源码 项目:nautilus-folder-icons 作者: bil-elmoussaoui 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, folders):
        GObject.GObject.__init__(self)
        Thread.__init__(self)
        Gtk.Window.__init__(self)
        # Here i assume that all folders got the same icon...
        self._folders = folders
        self.model = []
        self._flowbox = Gtk.FlowBox()

        # Threading stuff
        self.setDaemon(True)
        self.run()

        # Window configurations
        self.set_default_size(650, 500)
        self.set_size_request(650, 500)
        self.set_resizable(True)
        self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)

        # Widgets & Accelerators
        self._build_header_bar()
        self._build_content()
        self._setup_accels()
SBrickConfigureDialog.py 文件源码 项目:sbrick-controller 作者: wintersandroid 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def create_channel_box(self, channel_number):
        hbox = Gtk.FlowBox()
        hbox.set_max_children_per_line(8)
        hbox.set_min_children_per_line(8)
        hbox.set_selection_mode(Gtk.SelectionMode.NONE)

        hbox.add(Gtk.Label("Channel: %d" % channel_number))

        hbox.add(Gtk.Label("ID:"))
        id_edit = Gtk.Entry()
        id_edit.set_max_length(5)
        hbox.add(id_edit)

        hbox.add(Gtk.Label("Name:"))
        name_edit = Gtk.Entry()
        name_edit.set_max_length(20)
        hbox.add(name_edit)
        hbox.add(Gtk.Label("Type:"))
        combo_type = Gtk.ComboBoxText()
        combo_type.set_id_column(0)
        combo_type.set_model(self.channelTypeStore)
        renderer_text = Gtk.CellRendererText()
        combo_type.clear()
        combo_type.pack_start(renderer_text, True)
        combo_type.add_attribute(renderer_text, "text", 1)
        hbox.add(combo_type)

        self.content.pack_start(hbox, False, True, 0)
        return id_edit, name_edit, combo_type
emoji_picker.py 文件源码 项目:ibus-typing-booster 作者: mike-fabian 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _clear_flowbox(self):
        '''
        Clear the contents of the flowbox
        '''
        for child in self._flowbox_scroll.get_children():
            self._flowbox_scroll.remove(child)
        self._flowbox = Gtk.FlowBox()
        self._flowbox.get_style_context().add_class('view')
        self._flowbox_scroll.add(self._flowbox)
        self._flowbox.set_valign(Gtk.Align.START)
        self._flowbox.set_min_children_per_line(1)
        self._flowbox.set_max_children_per_line(100)
        self._flowbox.set_row_spacing(0)
        self._flowbox.set_column_spacing(0)
        self._flowbox.set_activate_on_single_click(True)
        self._flowbox.set_selection_mode(Gtk.SelectionMode.NONE)
        self._flowbox.set_can_focus(False)
        self._flowbox.set_homogeneous(False)
        self._flowbox.set_hexpand(False)
        self._flowbox.set_vexpand(False)
        self._flowbox.connect('child-activated', self.on_emoji_selected)
        for long_press_gesture in self._long_press_gestures:
            # disconnecting is necessary to avoid warnings to stdout:
            for ids in long_press_gesture[1]:
                long_press_gesture[0].disconnect(ids)
        self._long_press_gestures = []
impressWriter.py 文件源码 项目:impress-writer 作者: CSEC-NITH 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def create_synonyms_flowbox(self):

        label_Synonyms=Gtk.Label()
        label_Synonyms.set_markup("<u><b>Synonyms</b></u>")
        self.vbox_left2.pack_start(label_Synonyms,False,True,0)
        self.scrolled=Gtk.ScrolledWindow()
        self.scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        self.flowbox=Gtk.FlowBox()
        self.flowbox.set_valign(Gtk.Align.START)
        self.flowbox.set_max_children_per_line(7)
        self.flowbox.set_selection_mode(Gtk.SelectionMode.NONE)

        self.toggle_button_list=[]
        for i in range(100):
            x=Gtk.ToggleButton(label=str(i))
            self.toggle_button_list.append(x)

        for i in range(100):
            self.toggle_button_list[i].connect('clicked',self.toggle_button_clicked)

        for i in self.toggle_button_list:
            self.flowbox.add(i)

        self.scrolled.add(self.flowbox)
        self.add(self.scrolled)
        self.vbox_left2.pack_start(self.scrolled,True,True,0)                           

#########signal callback functions######################
SBrickMotorChannelBox.py 文件源码 项目:sbrick-controller 作者: wintersandroid 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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
SBrickConfigureDialog.py 文件源码 项目:sbrick-controller 作者: wintersandroid 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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
emoji_picker.py 文件源码 项目:ibus-typing-booster 作者: mike-fabian 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def on_skin_tone_selected(self, dummy_flowbox, flowbox_child):
        '''
        Signal handler for selecting a skin tone emoji

        :param dummy_flowbox: The flowbox displaying the skin tone emoji
        :type dummy_flowbox: Gtk.FlowBox object
        :param flowbox_child: The child object containing the selected emoji
        :type flowbox_child: Gtk.FlowBoxChild object
        '''
        # Use .get_label() instead of .get_text() to fetch the text
        # from the label widget including any embedded underlines
        # indicating mnemonics and Pango markup. The emoji is in
        # first <span>...</span>, and we want fetch only the emoji
        # here:
        text = flowbox_child.get_child().get_label()
        if _ARGS.debug:
            sys.stdout.write('on_skin_tone_selected() text = %s\n' %text)
        (emoji, dummy_name) = self._parse_emoji_and_name_from_text(text)
        if not emoji:
            return
        self._set_clipboards(emoji)
        self._add_to_recently_used(emoji)
        self._skin_tone_selected_popover = Gtk.Popover()
        self._skin_tone_selected_popover.set_relative_to(
            flowbox_child.get_child())
        self._skin_tone_selected_popover.set_position(Gtk.PositionType.TOP)
        label = Gtk.Label(_('Copied to clipboard!'))
        self._skin_tone_selected_popover.add(label)
        if GTK_VERSION >= (3, 22, 0):
            self._skin_tone_selected_popover.popup()
        self._skin_tone_selected_popover.show_all()
        # When an emoji with a different skin tone is selected in a
        # skin tone popover opened in a browse flowbox (not a search
        # results flowbox), replace the original emoji which was used
        # to open the popover immediately.
        label = self._skin_tone_popover.get_relative_to().get_child()
        text = label.get_label()
        (old_emoji, old_name) = self._parse_emoji_and_name_from_text(text)
        if old_emoji and not old_name:
            # If the old emoji has a name, this is a line
            # in a search results flowbox and we do *not* want
            # to replace the emoji.
            new_text = (
                '<span font="%s %s" fallback="%s">'
                %(self._font, self._fontsize, str(self._fallback).lower())
                + html.escape(emoji)
                + '</span>')
            label.set_text(new_text)
            label.set_use_markup(True)
        GLib.timeout_add(500, self._skin_tone_selected_popover_popdown)


问题


面经


文章

微信
公众号

扫码关注公众号