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

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

项目:Gnome-Authenticator    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def generate_left_box(self):
        left_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)

        remove_icon = Gio.ThemedIcon(name="user-trash-symbolic")
        remove_image = Gtk.Image.new_from_gicon(
            remove_icon, Gtk.IconSize.BUTTON)
        self.remove_button.set_tooltip_text(_("Remove selected accounts"))
        self.remove_button.set_image(remove_image)
        self.remove_button.set_sensitive(False)

        add_icon = Gio.ThemedIcon(name="list-add-symbolic")
        add_image = Gtk.Image.new_from_gicon(add_icon, Gtk.IconSize.BUTTON)
        self.add_button.set_tooltip_text(_("Add a new account"))
        self.add_button.set_image(add_image)

        lock_icon = Gio.ThemedIcon(name="changes-prevent-symbolic")
        lock_image = Gtk.Image.new_from_gicon(lock_icon, Gtk.IconSize.BUTTON)
        self.lock_button.set_tooltip_text(_("Lock the Application"))
        self.lock_button.set_image(lock_image)
        settings.connect('changed', self.bind_status)
        left_box.add(self.remove_button)
        left_box.add(self.add_button)
        left_box.add(self.lock_button)
        return left_box
项目:Gnome-Authenticator    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def generate_right_box(self):
        count = self.app.db.count()
        right_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        select_icon = Gio.ThemedIcon(name="object-select-symbolic")
        select_image = Gtk.Image.new_from_gicon(
            select_icon, Gtk.IconSize.BUTTON)
        self.select_button.set_tooltip_text(_("Selection mode"))
        self.select_button.set_image(select_image)

        search_icon = Gio.ThemedIcon(name="system-search-symbolic")
        search_image = Gtk.Image.new_from_gicon(
            search_icon, Gtk.IconSize.BUTTON)
        self.search_button.set_tooltip_text(_("Search"))
        self.search_button.set_image(search_image)
        self.search_button.set_visible(count > 0)

        self.cancel_button.set_label(_("Cancel"))

        right_box.add(self.search_button)
        right_box.add(self.select_button)
        right_box.add(self.cancel_button)
        return right_box
项目: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)
项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def __init__(self, config=None):
        self.bdisplay = os.path.join(get_config_path(), 'binding-display.svg')
        if not os.path.exists(self.bdisplay):
            # Prefer image in ~/.config/scc, but load default one as fallback
            self.bdisplay = os.path.join(get_share_path(), "images", 'binding-display.svg')

        OSDWindow.__init__(self, "osd-keyboard")
        self.daemon = None
        self.config = config or Config()
        self.group = None
        self.limits = {}
        self.background = None

        self._eh_ids = []
        self._stick = 0, 0

        self.c = Gtk.Box()
        self.c.set_name("osd-keyboard-container")
项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def __init__(self, app, name, use_icon, widget):
        ControllerWidget.__init__(self, app, name, use_icon, widget)

        if use_icon:
            vbox = Gtk.Box(Gtk.Orientation.HORIZONTAL)
            separator = Gtk.Separator(orientation = Gtk.Orientation.VERTICAL)
            vbox.pack_start(self.icon, False, False, 1)
            vbox.pack_start(separator, False, False, 1)
            vbox.pack_start(self.label, False, True, 1)
            self.widget.add(vbox)
        else:
            self.widget.add(self.label)
        self.widget.show_all()
        self.label.set_max_width_chars(12)
        if name == "C":
            self.label.set_max_width_chars(10)
项目:nvim-pygtk3    作者:rliang    | 项目源码 | 文件源码
def update(self, tablist: list, tabcurr: int):
        """Updates the widget's tabs.

        :tablist: list of tab names.
        :tabcurr: the active buffer's number.

        """
        self.props.updating = True
        for _ in range(self.get_n_pages()):
            self.remove_page(-1)
        for name in tablist:
            page = Gtk.Box()
            self.append_page(page, Gtk.Label(name))
            self.child_set_property(page, 'tab-expand', True)
        self.show_all()
        self.set_current_page(tabcurr - 1)
        self.set_show_tabs(self.get_n_pages() > 1)
        self.props.updating = False
项目:nvim-pygtk3    作者:rliang    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        super().__init__(*args,
                         default_width=640,
                         default_height=480,
                         **kwargs)
        self.switcher = NeovimBufferBar()
        self.set_titlebar(Gtk.HeaderBar(show_close_button=True,
                                        custom_title=self.switcher))
        vbox = Gtk.Box(parent=self, orientation=Gtk.Orientation.VERTICAL)
        self.notebook = NeovimTabBar(parent=vbox)
        self.viewport = NeovimViewport(parent=Gtk.ScrolledWindow(parent=vbox))
        self.terminal = NeovimTerminal(parent=self.viewport, expand=True)
        self.terminal.connect('child-exited', lambda *_:
                              self.close())
        self.terminal.connect('nvim-attached', lambda _, nvim:
                              self.emit('nvim-setup', nvim))
项目: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
项目:btcwidget    作者:rafalh    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Window.__init__(self, title="BTC Widget")

        self._ticker_labels = {}
        self._tickers_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self._create_ticker_labels()

        self._graph = btcwidget.graph.Graph(config['dark_theme'])

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        vbox.pack_start(self._tickers_vbox, False, False, 5)
        vbox.pack_start(self._graph, True, True, 0)

        self.set_icon_from_file(self._ICON_PATH)
        self.connect('delete-event', Gtk.main_quit)
        self.add(vbox)
        self.show_all()

        self._indicator = Indicator(self)

    # self.open_options()
项目:btcwidget    作者:rafalh    | 项目源码 | 文件源码
def _create_ticker_labels(self):
        self._tickers_vbox.forall(lambda w: w.destroy())
        self._ticker_labels = {}

        for i, market_config in enumerate(config['markets']):
            if market_config['ticker']:
                market_id = get_market_id(market_config)
                hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
                exchange, market = market_config['exchange'], market_config['market']
                provider = btcwidget.exchanges.factory.get(exchange)
                market_name = '{} - {}:'.format(provider.get_name(), market)
                name_label = Gtk.Label(market_name)
                color = self._get_color(i)
                name_label.set_markup('<span color="{}">{}</span>'.format(color, market_name))
                name_label.set_size_request(150, 10)
                name_label.set_alignment(0, 0.5)
                hbox.pack_start(name_label, False, False, 10)
                price_label = Gtk.Label()
                hbox.pack_start(price_label, False, False, 10)
                self._ticker_labels[market_id] = price_label
                price_label.get_parent()
                self._tickers_vbox.pack_start(hbox, True, True, 2)

        self._tickers_vbox.show_all()
项目:bracer    作者:deikatsuo    | 项目源码 | 文件源码
def show_version(self):
        self.prefs.add_list_group('bracer', 'version', _('Versions'), Gtk.SelectionMode.NONE, 100)

        # Bracer
        bracerv = Bracer._VERSION
        bracer = self.create_version_view('Bracer', bracerv)
        # Racer
        racerv = Bracer.racer.version()
        racer = self.create_version_view('Racer', racerv)
        racerv2 = Bracer.racer.version()

        bracer_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                             spacing=6, expand=True,
                             visible=True)

        bracer_box.pack_start(bracer, True, True, 0)
        racer_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                            spacing=6,
                            expand=True,
                            visible=True)

        racer_box.pack_start(racer, True, True, 0)

        self.ids.append(self.prefs.add_custom('bracer', 'version', bracer_box, None, 1000))
        self.ids.append(self.prefs.add_custom('bracer', 'version', racer_box, None, 1000))
项目:bracer    作者:deikatsuo    | 项目源码 | 文件源码
def create_version_view(self, label, version):
        custom = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                         spacing=12,
                         expand=True,
                         visible=True)

        title = Gtk.Label(halign='start', expand=True, visible=True, label=label)
        subtitle = Gtk.Label(halign='start', expand=True, visible=True)
        subtitle.get_style_context().add_class('dim-label')
        subtitle.set_markup(version)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, expand=True, visible=True)
        vbox.pack_start(title, True, True, 0)
        vbox.pack_start(subtitle, True, True, 0)

        custom.pack_start(vbox, True, True, 0)

        pack = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                       spacing=6,
                       expand=True,
                       visible=True)

        pack.pack_start(custom, True, True, 0)

        return pack
项目: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 hig_category_vbox(title, spacing=6):
    """
    spacing  the space to put between children. HIG say is should be 6, but
    while packing Gtk.LinkButtons there is too much space between the links
    when packing with 6 pixels. So I added the spacing parameter.
    Return a tuple of two boxes:
    box1 -- a box containing everything including the title. Useful
            if you have to hide a category.
    box2    The box you should pack your stuff in.
    """
    vbox = Gtk.VBox(False, 0)
    vbox.set_spacing(hig.SPACE_SMALL)
    label = Gtk.Label(label='<span weight="bold">%s</span>' % title)
    label.set_use_markup(True)
    label.set_alignment(0.0, 0.0)
    vbox.pack_start(label, False, False, 0)
    hbox = Gtk.Box(False, 0)
    vbox.pack_start(hbox, False, False, 0)
    fill = Gtk.Label(label="    ")
    hbox.pack_start(fill, False, False, 0)
    category_content_vbox = Gtk.VBox(False, 0)
    hbox.pack_start(category_content_vbox, True, True, 0)
    category_content_vbox.set_spacing(spacing)
    vbox.show_all()
    return vbox, category_content_vbox
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def hig_label_widget(txt, widget, sizegroup, expand=False, fill=False):
    """
    Return a box containing a label and a widget, aligned nice
    as the HIG say we should. widget can also be a list or tuple of
    widgets.
    """
    hbox = Gtk.Box()
    hbox.set_spacing(hig.SPACE_SMALL)
    label = Gtk.Label(label=txt)
    label.set_alignment(0.0, 0.5)
    if sizegroup:
        sizegroup.add_widget(label)
    hbox.pack_start(label, False, False, 0)

    if not isinstance(widget, (list, tuple)):
        widget = [widget]
    for w in widget:
        hbox.pack_start(w, fill, expand, padding=0)
    label.set_use_underline(True)
    label.set_mnemonic_widget(widget[0])
    return hbox
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self, default_value):
        Gtk.Box.__init__(self)
        self.m_value = mpd.notename_to_int(default_value)
        self.g_entry = Gtk.Entry()
        self.g_entry.set_editable(False)
        self.g_entry.set_text(mpd.int_to_user_octave_notename(self.m_value))
        self.pack_start(self.g_entry, False, False, 0)
        # up
        eb1 = Gtk.Button()
        eb1.add(Gtk.Arrow(Gtk.ArrowType.UP, Gtk.ShadowType.OUT))
        eb1.connect('button-press-event', self.on_up_press)
        eb1.connect('button-release-event', self.on_up_release)
        self.pack_start(eb1, True, True, 0)
        # down
        eb2 = Gtk.Button()
        eb2.add(Gtk.Arrow(Gtk.ArrowType.DOWN, Gtk.ShadowType.IN))
        eb2.connect('button-press-event', self.on_down_press)
        eb2.connect('button-release-event', self.on_down_release)
        self.pack_start(eb2, True, True, 0)
        self.m_timeout = None
项目:dell-recovery    作者:dell    | 项目源码 | 文件源码
def __init__(self, title):
        Gtk.Window.__init__(self, title=title)
        self.set_border_width(10)
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        self.add(vbox)
        self.progressbar = Gtk.ProgressBar()
        self.progressbar.pulse()
        self.progressbar.set_show_text(True)
        vbox.pack_start(self.progressbar, True, True, 0)
        self.timeout_id = GObject.timeout_add(50, self.on_timeout, None)
        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        self.set_deletable(False)
        self.set_decorated(False)
        self.set_resizable(False)
        self.set_keep_above(True)
        self.fraction = 0.0
        self.pulse = True
项目:chromecast-player    作者:wa4557    | 项目源码 | 文件源码
def main(self):
        self.win.set_title("Enter URL for network stream")
        self.entry = Gtk.Entry()
        vboxall = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.win.set_size_request(300, 10)
        content_area = self.win.get_content_area()
        content_area.pack_start(self.entry, True, True, 10)
        self.entry.set_margin_left(10)
        self.entry.set_margin_right(10)
        self.entry.show()
        response = self.win.run()

        if response == Gtk.ResponseType.OK:
            self.ret = self.entry.get_text()
        self.win.destroy()
        if self.ret:
            return (self.ret, self.but)
        else:
            return None
项目:apart-gtk    作者:alexheretic    | 项目源码 | 文件源码
def __init__(self, part: Dict[str, Any], core: ApartCore, main_view: 'MainView'):
        Gtk.Box.__init__(self)
        self.part = part
        self.core = core
        self.main_view = main_view

        self.add(key_and_val('Name', self.name()))
        self.add(key_and_val('Type', self.part.get('fstype', 'unknown')))
        self.add(key_and_val('Label', self.part.get('label', 'none')))
        self.add(key_and_val('Size', humanize.naturalsize(self.part['size'], binary=True)))
        self.clone_button = Gtk.Button("Clone", halign=Gtk.Align.END)
        self.restore_button = Gtk.Button("Restore", halign=Gtk.Align.END)
        if self.is_mounted():
            self.clone_button.set_sensitive(False)
            self.clone_button.set_tooltip_text('Partition is currently mounted')
            self.restore_button.set_sensitive(False)
            self.restore_button.set_tooltip_text('Partition is currently mounted')
        else:
            self.clone_button.connect('clicked', lambda b: self.main_view.show_new_clone())
            self.restore_button.connect('clicked', lambda b: self.main_view.show_new_restore())
        buttons = Gtk.Box(hexpand=True, halign=Gtk.Align.END)
        buttons.add(self.clone_button)
        buttons.add(self.restore_button)
        self.add(buttons)
        main_view.connect('notify::visible-child', self.on_main_view_change)
项目:apart-gtk    作者:alexheretic    | 项目源码 | 文件源码
def __init__(self,
                 core: ApartCore,
                 sources: List[Dict[str, Any]],
                 z_options: List[str]):
        Gtk.Box.__init__(self)
        self.core = core

        right_panes = Gtk.VPaned(expand=True)
        self.main_view = MainView(core, z_options)
        self.info_view = ClonePartInfo(sources, core, self.main_view)
        right_panes.pack1(self.info_view, shrink=False)
        right_panes.pack2(self.main_view, shrink=False)

        self.side_bar_box = Gtk.EventBox()
        self.side_bar_box.add(Gtk.StackSidebar(stack=self.info_view))
        self.side_bar_box.connect('button-press-event', self.side_bar_click)

        self.paned = Gtk.Paned(expand=True)
        self.paned.pack1(self.side_bar_box, shrink=False)
        self.paned.pack2(right_panes, shrink=False)

        self.add(self.paned)
项目:apart-gtk    作者:alexheretic    | 项目源码 | 文件源码
def __init__(self, root: Gtk.Window, text: str,
                 ok_button_text: str = Gtk.STOCK_OK,
                 cancel_button_text: str = Gtk.STOCK_CANCEL,
                 header: str = '',
                 message_type: Gtk.MessageType = Gtk.MessageType.WARNING):
        Gtk.MessageDialog.__init__(self, root, 0, message_type=message_type)
        self.set_title(header)
        self.icon = Gtk.Image()
        self.icon.set_from_icon_name(appropriate_icon(message_type), Gtk.IconSize.LARGE_TOOLBAR)
        self.text = Gtk.Label(text)
        heading = Gtk.Box()
        heading.add(self.icon)
        heading.add(self.text)

        self.get_message_area().add(heading)
        self.get_message_area().set_spacing(0)
        self.add_button(cancel_button_text, Gtk.ResponseType.CANCEL)
        self.add_button(ok_button_text, Gtk.ResponseType.OK)
        self.show_all()
项目:apart-gtk    作者:alexheretic    | 项目源码 | 文件源码
def __init__(self, root: Gtk.Window, text: str,
                 ok_button_text: str = Gtk.STOCK_OK,
                 header: str = '',
                 message_type: Gtk.MessageType = Gtk.MessageType.ERROR):
        Gtk.MessageDialog.__init__(self, root, 0, message_type=message_type)
        self.set_title(header)
        self.icon = Gtk.Image()
        self.icon.set_from_icon_name(appropriate_icon(message_type), Gtk.IconSize.LARGE_TOOLBAR)
        self.text = Gtk.Label(text)
        heading = Gtk.Box()
        heading.add(self.icon)
        heading.add(self.text)

        self.get_message_area().add(heading)
        self.get_message_area().set_spacing(0)
        self.add_button(ok_button_text, Gtk.ResponseType.OK)
        self.show_all()
项目:AncestryCitations    作者:tecknicaltom    | 项目源码 | 文件源码
def __create_gui(self):
        """
        Create and display the GUI components of the gramplet.
        """
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self.model = Gtk.ListStore(object, str, int)
        view = Gtk.TreeView(self.model)
        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(_("Person"), renderer, text=1)
        view.append_column(column)
        renderer = Gtk.CellRendererText()
        renderer.set_property('editable', True)
        renderer.connect('edited', self.__cell_edited)
        column = Gtk.TreeViewColumn(_("ID"), renderer, text=2)
        view.append_column(column)

        vbox.pack_start(view, expand=True, fill=True, padding=0)
        return vbox
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def __init__(self, year, quarter):
        Gtk.EventBox.__init__(self)

        self.year = year
        self.quarter = quarter

        self.set_hexpand(True)
        self.set_vexpand(True)
        self.set_valign(Gtk.Align.FILL)

        self.box = Gtk.Box(
                orientation=Gtk.Orientation.VERTICAL,spacing=10
                )
        self.box.set_hexpand(True)
        self.box.set_vexpand(True)
        self.box.set_valign(Gtk.Align.START)
        self.add(self.box)

        self.drag_dest_set(Gtk.DestDefaults.ALL, [], DRAG_ACTION)

        self.show_all()
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def create_change_box(self, button_type="prereq"):
        change_box = Gtk.Box() 
        add_button = Gtk.Button.new_from_icon_name('list-add', ICON_SIZE)
        if button_type == "prereq":
            add_button.connect('clicked', self.add_prereq)
        elif button_type == "ge":
            add_button.connect('clicked', self.add_ge)

        remove_button = Gtk.Button.new_from_icon_name('list-remove', ICON_SIZE)

        if button_type == "prereq":
            remove_button.connect('clicked', self.remove_prereq)
        elif button_type == "ge":
            remove_button.connect('clicked', self.remove_ge)

        change_box.pack_start(add_button, True, True, 0)
        change_box.pack_end(remove_button, True, True, 0)
        return change_box
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def __init__(self, year, quarter):
        Gtk.EventBox.__init__(self)

        self.year = year
        self.quarter = quarter.capitalize()

        self.set_hexpand(True)
        self.set_vexpand(True)
        self.set_valign(Gtk.Align.FILL)

        self.box = Gtk.Box(
                orientation=Gtk.Orientation.VERTICAL,spacing=10
                )
        self.box.set_hexpand(True)
        self.box.set_vexpand(True)
        self.box.set_valign(Gtk.Align.START)
        self.add(self.box)

        self.drag_dest_set(Gtk.DestDefaults.ALL, [], DRAG_ACTION)
项目:draobpilc    作者:awamper    | 项目源码 | 文件源码
def do_activate(self, show_preferences_dialog=False):
        if self._window:
            if show_preferences_dialog: show_preferences()
            else: self.show()
            return None

        right_box = Gtk.Box()
        right_box.set_name('RightBox')
        right_box.set_orientation(Gtk.Orientation.VERTICAL)
        right_box.add(self._search_box)
        right_box.add(self._items_view)

        self._window = Window(self)
        self._window.connect('configure-event', self._resize)
        self._window.connect('key-press-event', self._on_key_press)
        self._window.connect('key-release-event', self._on_key_release)
        self._window.connect(
            'focus-out-event',
            lambda _, __: self._items_view.show_shortcut_hints(False)
        )
        self._window.grid.attach(self._items_processors, 0, 0, 1, 1)
        self._window.grid.attach(self._main_toolbox, 0, 1, 1, 1)
        self._window.grid.attach(right_box, 1, 0, 1, 2)

        if show_preferences_dialog: show_preferences()
项目:gedit-panel-toggler    作者:hardpixel    | 项目源码 | 文件源码
def do_activate(self):
    self.add_icon_path()

    self._header_bar    = self.window.get_titlebar().get_children()[-1]
    self._bottom_panel  = self.window.get_bottom_panel()
    self._side_panel    = self.window.get_side_panel()
    self._panel_sidebar = self._bottom_panel.get_parent().get_parent().get_children()[-1]
    self._button_box    = Gtk.Box()
    self._left_button   = Gtk.Button.new_from_icon_name('left-panel-symbolic', Gtk.IconSize.BUTTON)
    self._bottom_button = Gtk.Button.new_from_icon_name('bottom-panel-symbolic', Gtk.IconSize.BUTTON)

    self._button_box.get_style_context().add_class('linked')
    self._bottom_button.connect('clicked', self.on_bottom_button_activated)
    self._left_button.connect('clicked', self.on_left_button_activated)

    self._header_bar.pack_end(self._button_box)
    self._button_box.pack_end(self._bottom_button, True, True, 0)
    self._button_box.pack_end(self._left_button, True, True, 1)

    self._button_box.show_all()
    self._panel_sidebar.hide()
项目:Simple-User-Input-Sculpture-Generation    作者:ClaireKincaid    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Window.__init__(self, title = "Choose a method of Sculpture Generation")
        self.set_border_width(10)
        self.set_default_size(400, 50)

        #initiates Gtk box window
        self.box = Gtk.Box(spacing = 6)
        self.add(self.box)

        #Initializes Vector Animation Button, places in box
        self.VectorButton = Gtk.Button(label = "Vector Animation")
        self.VectorButton.connect("clicked", self.on_VectorButton_clicked)
        self.VectorButton.connect("clicked", Gtk.main_quit)
        self.box.pack_start(self.VectorButton, True, True, 0)

        #Initializes Perlin Noise Button, places in box
        self.PerlinButton = Gtk.Button(label = "Perlin Noise")
        self.PerlinButton.connect("clicked", self.on_PerlinButton_clicked)
        self.PerlinButton.connect("clicked", Gtk.main_quit)
        self.box.pack_start(self.PerlinButton, True, True, 0)

    #when VectorButton clicked, toggles to new GUI
项目:nautilus-folder-icons    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def _build_widget(self):
        """Build the widgets."""
        container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        container.show()
        theme = Gtk.IconTheme.get_default()
        pixbuf = theme.load_icon(self.name, 64, 0)
        # Force the icon to be 64x64
        pixbuf = pixbuf.scale_simple(64, 64, GdkPixbuf.InterpType.BILINEAR)

        image = Gtk.Image.new_from_pixbuf(pixbuf)
        image.show()
        container.pack_start(image, False, False, 6)

        label = Gtk.Label()
        label.set_text(self.name)
        label.show()
        container.pack_start(label, False, False, 6)
        self.add(container)
项目:razerCommander    作者:GabMus    | 项目源码 | 文件源码
def build_keyrow_box(row, colors, signal_handler, prof_index):
    box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
    for key in row.keylist:
        if not key.isGhost:
            k_col = Gdk.RGBA(
                colors[prof_index][0],
                colors[prof_index][1],
                colors[prof_index][2]
            )
        else:
            k_col = Gdk.RGBA(0, 0, 0)
        keybox = build_key_box(
            key,
            k_col,
            signal_handler
        )
        if not key.isGhost:
            prof_index += 1
        box.pack_start(keybox, True, True, 0)
    return {'row': box, 'prof_index': prof_index}
项目:razerCommander    作者:GabMus    | 项目源码 | 文件源码
def build_keyboard_box(box, colors, signal_handler, nrkb):
    global rkb
    rkb = nrkb
    # Empty keyboardBox
    if len(box.get_children()) >= 2:
        box.remove(box.get_children()[1])

    prof_index = 0
    kb_inner_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
    for row in rkb.rows:
        rowbox_res = build_keyrow_box(row, colors, signal_handler, prof_index)
        rowbox = rowbox_res['row']
        prof_index = rowbox_res['prof_index']
        kb_inner_box.pack_start(rowbox, True, True, 0)
    box.pack_end(kb_inner_box, True, True, 0)
    kb_inner_box.show_all()
    return box
项目:tmsu-nautilus-python    作者:talklittle    | 项目源码 | 文件源码
def __init__(self, files):
        self.files = files

        Gtk.Window.__init__(self, title="TMSU")
        self.set_size_request(200, 100)
        self.set_border_width(10)
        self.set_type_hint(Gdk.WindowTypeHint.DIALOG)

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

        prompt_text = 'Add (space-separated) tags to %d file%s' % (len(files), '' if len(files)==1 else 's')
        self.prompt_label = Gtk.Label(label=prompt_text)
        vbox.pack_start(self.prompt_label, True, True, 0)

        self.entry = Gtk.Entry()
        self.entry.connect("activate", self.on_entry_activated)
        vbox.pack_start(self.entry, True, True, 0)

        self.button = Gtk.Button(label="Add")
        self.button.connect("clicked", self.on_button_clicked)
        vbox.pack_start(self.button, True, True, 0)
项目:cozy    作者:geigi    | 项目源码 | 文件源码
def __init__(self, on_click, book):
        super().__init__()

        self.on_click = on_click
        self.book = book

        self.connect("enter-notify-event", self._on_enter_notify)
        self.connect("leave-notify-event", self._on_leave_notify)
        if on_click is not None:
            self.connect("button-press-event", self.__on_clicked)

        self.props.margin_top = 2
        self.props.margin_bottom = 2

        # This box contains all content
        self.box = Gtk.Box()
        self.box.set_orientation(Gtk.Orientation.HORIZONTAL)
        self.box.set_spacing(3)
        self.box.set_halign(Gtk.Align.FILL)
        self.box.set_valign(Gtk.Align.CENTER)
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def _build_vumeter(self):
        """
        """
        # TODO: True stereo feed has to be implemented.
        self.vumeter_left = Gtk.ProgressBar()
        self.vumeter_left.set_orientation(Gtk.Orientation.VERTICAL)
        self.vumeter_left.set_inverted(True)
        self.vumeter_right = Gtk.ProgressBar()
        self.vumeter_right.set_orientation(Gtk.Orientation.VERTICAL)
        self.vumeter_right.set_inverted(True)

        vumeter_hbox = Gtk.Box(Gtk.Orientation.HORIZONTAL)
        vumeter_hbox.set_halign(Gtk.Align.END)
        vumeter_hbox.set_margin_top(6)
        vumeter_hbox.set_margin_bottom(6)
        _pack_widgets(vumeter_hbox,
                      self.vumeter_left,
                      self.vumeter_right)

        return vumeter_hbox
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def __init__(self, pipeline, menu_revealer, images,
                 video_menu, audio_menu, stream_menu, store_menu, settings_menu,
                 placeholder_pipeline=None):
        self.images = images

        self._pipeline = pipeline
        self._placeholder_pipeline = placeholder_pipeline
        self._menu_revealer = menu_revealer
        self.abstract_menu = AbstractMenu(
            self._pipeline, self._menu_revealer, self._placeholder_pipeline)  # DEBUG

        self.video_menu = video_menu
        self.audio_menu = audio_menu
        self.stream_menu = stream_menu
        self.store_menu = store_menu
        self.settings_menu = settings_menu

        self.overlay_container = Gtk.Overlay()
        self.controlbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        self.controlbox.set_valign(Gtk.Align.END)
        self.controlbox.set_margin_bottom(6)
        self.controlbox.set_halign(Gtk.Align.CENTER)

        self.toolbar = self._build_toolbar()
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def _build_stream_vbox(self):
        title = Gtk.Label("Streaming server")
        title.set_margin_top(6)

        self.stream_add_button = self._build_add_button(
            callback=self.on_add_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.settings_revealer,
                      separator,
                      self.stream_add_button)
        self._make_scrolled_window(vbox)
        return vbox
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def __init__(self):
        self.placeholder_image = Gtk.Image.new_from_icon_name(
            Gtk.STOCK_NEW, Gtk.IconSize.DIALOG)
        self.new_feed_button = Gtk.Button("New Feed")

        self.new_feed_vbox = Gtk.Box(Gtk.Orientation.VERTICAL)
        self.new_feed_vbox.set_halign(Gtk.Align.CENTER)
        self.new_feed_vbox.set_valign(Gtk.Align.CENTER)
        _pack_widgets(self.new_feed_vbox,
                      self.placeholder_image,
                      self.new_feed_button)

        self._grid = Gtk.Grid()
        self._grid.set_row_homogeneous(True)
        self._grid.set_column_homogeneous(True)
        self._grid.attach(self.new_feed_vbox, 0, 0, 1, 1)
        self._grid.attach(Gtk.Label("FEED ELEMENT DEBUG1"), 1, 0, 1, 1)  # DEBUG
        self._grid.attach(Gtk.Label("FEED ELEMENT DEBUG2"), 0, 1, 1, 1)  # DEBUG
        self._grid.attach(Gtk.Label("FEED ELEMENT DEBUG3"), 1, 1, 1, 1)  # DEBUG
        self._grid.show_all()

        self.container = self._grid
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Box.__init__(self)
        self.set_spacing(StockEms.SMALL)

        self.selector = ReactiveStar()
        self.selector.set_n_stars(self.N_STARS)
        self.selector.set_rating(self.INIT_RATING)
        self.selector.set_size_as_pixel_value(big_em(3))

        text = self.RATING_WORDS[self.INIT_RATING]
        self.caption = Gtk.Label.new(text)

        self.set_orientation(Gtk.Orientation.HORIZONTAL)
        self.pack_start(self.selector, False, False, 0)
        self.pack_start(self.caption, False, False, 0)


# test helper also used in the unit tests
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, menu, icon=None, label=None):
        super(MenuButton, self).__init__()

        box = Gtk.Box()
        self.add(box)

        if icon:
            box.pack_start(icon, False, True, 1)
        if label:
            box.pack_start(Gtk.Label(label), True, True, 0)

        arrow = Gtk.Arrow.new(Gtk.ArrowType.DOWN, Gtk.ShadowType.OUT)
        box.pack_start(arrow, False, False, 1)

        self.menu = menu

        self.connect("button-press-event", self.on_button_pressed, menu)
        self.connect("clicked", self.on_keyboard_clicked, menu)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Box.__init__(self)
        self.set_spacing(StockEms.SMALL)

        self.selector = ReactiveStar()
        self.selector.set_n_stars(self.N_STARS)
        self.selector.set_rating(self.INIT_RATING)
        self.selector.set_size_as_pixel_value(big_em(3))

        text = self.RATING_WORDS[self.INIT_RATING]
        self.caption = Gtk.Label.new(text)

        self.set_orientation(Gtk.Orientation.HORIZONTAL)
        self.pack_start(self.selector, False, False, 0)
        self.pack_start(self.caption, False, False, 0)


# test helper also used in the unit tests
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, menu, icon=None, label=None):
        super(MenuButton, self).__init__()

        box = Gtk.Box()
        self.add(box)

        if icon:
            box.pack_start(icon, False, True, 1)
        if label:
            box.pack_start(Gtk.Label(label), True, True, 0)

        arrow = Gtk.Arrow.new(Gtk.ArrowType.DOWN, Gtk.ShadowType.OUT)
        box.pack_start(arrow, False, False, 1)

        self.menu = menu

        self.connect("button-press-event", self.on_button_pressed, menu)
        self.connect("clicked", self.on_keyboard_clicked, menu)
项目:kickoff-player    作者:jonian    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
    Gtk.Box.__init__(self, *args, **kwargs)

    self.channel          = self.get_property('channel')
    self.channel_logo     = self.do_channel_logo()
    self.channel_name     = self.do_channel_name()
    self.channel_language = self.do_channel_language()

    self.set_orientation(Gtk.Orientation.VERTICAL)
    self.set_margin_top(10)
    self.set_margin_bottom(10)
    self.set_margin_left(10)
    self.set_margin_right(10)
    self.set_spacing(10)

    self.connect('realize', self.on_channel_updated)
    self.connect('realize', self.on_realize)
    self.connect('notify::channel', self.on_channel_updated)

    self.show()
项目:kickoff-player    作者:jonian    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
    Gtk.Box.__init__(self, *args, **kwargs)

    self.channel  = self.get_property('channel')
    self.callback = self.get_property('callback')
    self.streams  = None

    self.set_orientation(Gtk.Orientation.HORIZONTAL)
    self.set_homogeneous(True)

    self.connect('realize', self.on_channel_updated)
    self.connect('notify::channel', self.on_channel_updated)

    add_widget_class(self, 'channel-streams')

    self.show()
项目:kickoff-player    作者:jonian    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
    Gtk.Box.__init__(self, *args, **kwargs)

    self.timeout = None
    self.gtksink = Gst.ElementFactory.make('gtksink')
    self.swidget = self.gtksink.props.widget
    self.pack_start(self.swidget, True, True, 0)

    self.playbin = Gst.ElementFactory.make('playbin')
    self.playbin.set_property('video-sink', self.gtksink)
    self.playbin.set_property('force-aspect-ratio', True)

    self.dbus = self.playbin.get_bus()
    self.dbus.add_signal_watch()
    self.dbus.connect('message', self.on_dbus_message)

    add_widget_class(self, 'player-video')
项目:kickoff-player    作者:jonian    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
    Gtk.Box.__init__(self, *args, **kwargs)

    self.fixture  = self.get_property('fixture')
    self.callback = self.get_property('callback')

    self.event_count     = 0
    self.count_label     = self.do_count_label()
    self.available_label = self.do_available_label()
    self.more_button     = self.do_more_button()

    self.set_orientation(Gtk.Orientation.HORIZONTAL)
    self.connect('realize', self.on_fixture_updated)
    self.connect('realize', self.on_realize)
    self.connect('notify::fixture', self.on_fixture_updated)

    add_widget_class(self, 'event-item-streams')

    self.show()
项目:kickoff-player    作者:jonian    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
    Gtk.Box.__init__(self, *args, **kwargs)

    self.stream   = self.get_property('stream')
    self.callback = self.get_property('callback')
    self.compact  = self.get_property('compact')

    self.stream_name = self.do_stream_name()
    self.stream_rate = self.do_stream_rate()
    self.stream_logo = self.do_stream_logo()
    self.stream_lang = self.do_stream_language()
    self.play_button = self.do_play_button()

    self.set_orientation(Gtk.Orientation.HORIZONTAL)
    self.connect('realize', self.on_realized)
    self.connect('notify::stream', self.on_stream_updated)

    self.show()
项目:funky    作者:giannitedesco    | 项目源码 | 文件源码
def __init__(self, buy_cb):
        def cb_shim(*_):
            buy_cb(*self.totals)
        super(ButtonRow, self).__init__()

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

        self.name = Gtk.Label(xalign = 0)
        self.name.set_markup('<b>Purchase</b>')

        self.d = Gtk.Label()#xalign = 0)
        self.update_stock(0, 0, 0, 0)
        self.update_totals(0, 0, 0, 0)

        b = Gtk.Button.new_with_label('buy')
        b.connect('clicked', cb_shim)

        hbox.pack_start(self.name, True, True, 0)
        hbox.pack_start(self.d, False, True, 0)
        hbox.pack_start(b, False, True, 0)
        self.add(hbox)

        self.set_can_focus(False)
项目:batterym    作者:maks-a    | 项目源码 | 文件源码
def battery_monitor(self, _):
        if self.window is None:
            self.window = gtk.Window()
            self.window.connect('delete-event', self.close_window)
            self.window.set_title('Battery Monitor')
            self.window.set_border_width(10)
            self.window.set_size_request(700, 500)
            self.window.set_resizable(False)
            self.window.set_position(gtk.WindowPosition.CENTER)
            self.window.set_icon_from_file(BATTERY_MONITOR_ICON)
            self.window.vbox = gtk.Box()
            self.window.vbox.set_spacing(5)
            self.window.vbox.set_orientation(gtk.Orientation.VERTICAL)
            self.window.add(self.window.vbox)
            self.image = gtk.Image()
            self.image.set_from_file(CAPACITY_HISTORY_CHART)
            self.window.vbox.pack_start(self.image, False, False, 0)
        if not self.window.props.visible:
            self.window.show_all()
项目:duck-feed    作者:h0m3stuck    | 项目源码 | 文件源码
def create_feed_entry(title, url, description):
    container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
    title_label = Gtk.Label(title)
    link_button = Gtk.LinkButton(url, url)
    description_view = WebKit2.WebView()
    description_view.set_size_request(400, 400)
    description_view.load_html(description)
    container.add(title_label)
    container.add(link_button)
    container.add(description_view)
    container.show()
    title_label.show()
    link_button.show()
    description_view.show()
    return container