Python gi.repository.Gtk.Grid() Examples

The following are 30 code examples of gi.repository.Gtk.Grid(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gi.repository.Gtk , or try the search function .
Example #1
Source File: basedialog.py    From lplayer with MIT License 6 votes vote down vote up
def init_ui(self):
        vbox0 = Gtk.VBox(spacing=5)
        vbox0.set_border_width(5)
        self.get_content_area().add(vbox0)

        frame1 = Gtk.Frame()
        vbox0.add(frame1)

        self.grid = Gtk.Grid()
        self.grid.set_row_spacing(10)
        self.grid.set_column_spacing(10)
        self.grid.set_margin_bottom(10)
        self.grid.set_margin_start(10)
        self.grid.set_margin_end(10)
        self.grid.set_margin_top(10)
        frame1.add(self.grid) 
Example #2
Source File: combinedview.py    From addons-source with GNU General Public License v2.0 6 votes vote down vote up
def config_panel(self, configdialog):
        """
        Function that builds the widget in the configuration dialog
        """
        grid = Gtk.Grid()
        grid.set_border_width(12)
        grid.set_column_spacing(6)
        grid.set_row_spacing(6)

        configdialog.add_checkbox(grid,
                _('Use shading'),
                0, 'preferences.relation-shade')
        configdialog.add_checkbox(grid,
                _('Display edit buttons'),
                1, 'preferences.releditbtn')
        checkbox = Gtk.CheckButton(label=_('View links as website links'))
        theme = self._config.get('preferences.relation-display-theme')
        checkbox.set_active(theme == 'WEBPAGE')
        checkbox.connect('toggled', self._config_update_theme)
        grid.attach(checkbox, 1, 2, 8, 1)

        return _('Layout'), grid 
Example #3
Source File: combinedview.py    From addons-source with GNU General Public License v2.0 6 votes vote down vote up
def get_attribute_grid(self, attrs):
        grid = Gtk.Grid()
        row = 0
        for attr in attrs:
            if str(attr.get_type()) != _('Order'):
                label = widgets.BasicLabel('%s: ' % str(attr.get_type()))
                grid.attach(label, 0, row, 1, 1)
                label = widgets.BasicLabel(attr.get_value())
                grid.attach(label, 1, row, 1, 1)
                row += 1
        grid.show_all()
        return grid

##############################################################################
#
# Citations list
#
############################################################################## 
Example #4
Source File: combinedview.py    From addons-source with GNU General Public License v2.0 6 votes vote down vote up
def write_album(self, person):

        self.vbox2 = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL)

        scroll = Gtk.ScrolledWindow()
        scroll.add(self.vbox2)
        scroll.show_all()
        self.stack.add_titled(scroll, 'album', _('Album'))

        self.write_media(person.get_media_list(), None)

        for event_ref in person.get_event_ref_list():
            event = self.dbstate.db.get_event_from_handle(event_ref.ref)

            self.write_media(event.get_media_list(), event)

        for family_handle in person.get_family_handle_list():
            family = self.dbstate.db.get_family_from_handle(family_handle)

            self.write_media(family.get_media_list(), None)

            for event_ref in family.get_event_ref_list():
                event = self.dbstate.db.get_event_from_handle(event_ref.ref)

                self.write_media(event.get_media_list(), event) 
Example #5
Source File: combinedview.py    From addons-source with GNU General Public License v2.0 6 votes vote down vote up
def content_panel(self, configdialog):
        """
        Function that builds the widget in the configuration dialog
        """
        grid = Gtk.Grid()
        grid.set_border_width(12)
        grid.set_column_spacing(6)
        grid.set_row_spacing(6)
        configdialog.add_checkbox(grid,
                _('Show Details'),
                0, 'preferences.family-details')
        configdialog.add_checkbox(grid,
                _('Vertical Details'),
                1, 'preferences.vertical-details')
        configdialog.add_checkbox(grid,
                _('Show Siblings'),
                2, 'preferences.family-siblings')
        configdialog.add_checkbox(grid,
                _('Show Tags'),
                3, 'preferences.show-tags')

        return _('Content'), grid 
Example #6
Source File: main.py    From PiHole-Panel with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        Gtk.Window.__init__(self)
        self.assistant = Gtk.Assistant()
        grid = Gtk.Grid(margin=4)
        grid.set_column_homogeneous(True)
        self.add(grid)

        self.grid = grid

        self.status_label, self.status_button = self.draw_status_elements()
        self.statistics_frame = self.draw_statistics_frame()
        self.top_queries_frame = self.draw_top_queries_frame()
        self.top_ads_frame = self.draw_top_ads_frame()
        self.updates_frame = self.draw_updates_frame()
        self.header_bar = self.draw_header_bar()
        self.hosts_combo = self.draw_hosts_combo()
        # Initial data fetch-and-display
        self.fetch_data_and_update_display(
            base_url, web_password)

        # Create a timer --> self.on_timer will be called periodically
        glib.timeout_add_seconds(update_interval_seconds, self.on_timer) 
Example #7
Source File: slider_win.py    From volctl with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, volctl):
        self.volctl = volctl
        self._win = Gtk.Window(type=Gtk.WindowType.POPUP)
        self._win.connect("enter-notify-event", self._cb_enter_notify)
        self._win.connect("leave-notify-event", self._cb_leave_notify)
        self._grid = Gtk.Grid()
        self._grid.set_column_spacing(2)
        self._grid.set_row_spacing(self.SPACING)
        self._frame = Gtk.Frame()
        self._frame.set_shadow_type(Gtk.ShadowType.OUT)
        self._frame.add(self._grid)
        self._win.add(self._frame)

        # gui objects by index
        self._sink_scales = {}
        self._sink_input_scales = {}

        self._create_sliders()
        self._win.show_all()
        self._set_position()

        # timeout
        self._timeout = None
        self._enable_timeout() 
Example #8
Source File: FlatCAMApp.py    From FlatCAM with MIT License 6 votes vote down vote up
def __init__(self):
        Gtk.VBox.__init__(self, spacing=3, margin=5, vexpand=False)

        ## Plot options
        self.plot_options_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
        self.plot_options_label.set_markup("<b>Plot Options:</b>")
        self.pack_start(self.plot_options_label, expand=False, fill=True, padding=2)

        grid0 = Gtk.Grid(column_spacing=3, row_spacing=2)
        self.pack_start(grid0, expand=True, fill=False, padding=2)

        # Plot CB
        self.plot_cb = FCCheckBox(label='Plot')
        grid0.attach(self.plot_cb, 0, 0, 2, 1)

        # Tool dia for plot
        l1 = Gtk.Label('Tool dia:', xalign=1)
        grid0.attach(l1, 0, 1, 1, 1)
        self.tooldia_entry = LengthEntry()
        grid0.attach(self.tooldia_entry, 1, 1, 1, 1) 
Example #9
Source File: infobox.py    From syncthing-gtk with GNU General Public License v2.0 6 votes vote down vote up
def init_grid(self):
		# Create widgets
		self.grid = Gtk.Grid()
		self.rev = RevealerClass()
		align = Gtk.Alignment()
		self.eb = Gtk.EventBox()
		# Set values
		self.grid.set_row_spacing(1)
		self.grid.set_column_spacing(3)
		self.rev.set_reveal_child(False)
		align.set_padding(2, 2, 5, 5)
		self.eb.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(*self.background))
		self.grid.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(*self.background))
		# Connect signals
		self.eb.connect("button-release-event", self.on_grid_release)
		self.eb.connect("button-press-event", self.on_grid_click)
		self.eb.connect('enter-notify-event', self.on_enter_notify)
		self.eb.connect('leave-notify-event', self.on_leave_notify)
		# Pack together
		align.add(self.grid)
		self.eb.add(align)
		self.rev.add(self.eb)
		self.add(self.rev)
	
	### GtkWidget-related stuff 
Example #10
Source File: colour_palette.py    From alienfx with GNU General Public License v3.0 6 votes vote down vote up
def __init__(
            self, colours, max_colour_val, num_rows, num_cols, horizontal, 
            selected_handler):
        Gtk.Grid.__init__(self)
        row = 0
        col = 0
        (ret, width, height) = Gtk.icon_size_lookup(Gtk.IconSize.BUTTON)
        rgba = Gdk.RGBA()
        for c in colours:
            rgba.parse(c)
            colour_square = ColourPaletteSquare(
                rgba, width, height, max_colour_val)
            colour_square.connect("button-release-event", selected_handler)
            self.attach(colour_square, col, row, 1, 1)
            if horizontal:
                col += 1
                if col == num_cols:
                    col = 0
                    row += 1
            else:
                row += 1
                if row == num_rows:
                    row = 0
                    col += 1 
Example #11
Source File: preview_terminal.py    From oomox with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        super().__init__()
        self.set_margin_right(WIDGET_SPACING)
        self.set_margin_left(WIDGET_SPACING)

        self.background = Gtk.Grid(row_spacing=6, column_spacing=6)
        self.background.set_halign(Gtk.Align.CENTER)
        self.background.set_margin_top(WIDGET_SPACING // 2)
        self.background.set_margin_bottom(WIDGET_SPACING)
        self.background.set_margin_right(WIDGET_SPACING * 2)

        self.terminal_widgets = {}
        twi = self.terminal_widgets

        twi["normal"] = Gtk.Label()
        twi["normal"].set_markup("<tt>{}</tt>".format(_("terminal colors:")))
        self.background.attach(twi["normal"], 1, 1, 2, 1)
        previous_row = twi["normal"]
        previous_row.set_margin_left(self.LEFT_MARGIN)
        for color_row in self.COLOR_ROWS:
            color_name, normal_id, highlight_id = color_row
            key1 = "color{}".format(normal_id)
            key2 = "color{}".format(highlight_id)
            twi[key1] = Gtk.Label()
            twi[key2] = Gtk.Label()
            twi[key1].set_markup("<tt>{}</tt>".format(color_name))
            twi[key2].set_markup("<tt>{}</tt>".format(color_name))
            self.background.attach_next_to(
                twi[key1], previous_row,
                Gtk.PositionType.BOTTOM, 1, 1
            )
            self.background.attach_next_to(
                twi[key2], twi[key1],
                Gtk.PositionType.RIGHT, 1, 1
            )
            previous_row = twi[key1]
            previous_row.set_margin_left(self.LEFT_MARGIN)
        self.set_center_widget(self.background) 
Example #12
Source File: helpers.py    From vimiv with MIT License 5 votes vote down vote up
def error_message(message, running_tests=False):
    """Show a GTK Error Pop Up with message.

    Args:
        message: The message to display.
        running_tests: If True running from testsuite. Do not show popup.
    """
    # Always print the error message first
    print("\033[91mError:\033[0m", message)
    # Then display a Gtk Popup
    popup = Gtk.Dialog(title="vimiv - Error", transient_for=Gtk.Window())
    popup.set_default_size(600, 1)
    popup.add_button("Close", Gtk.ResponseType.CLOSE)
    message_label = Gtk.Label()
    # Set up label so it actually follows the default width of 600
    message_label.set_hexpand(True)
    message_label.set_line_wrap(True)
    message_label.set_size_request(600, 1)
    message_label.set_text(message)
    box = popup.get_child()
    box.set_border_width(12)
    grid = Gtk.Grid()
    grid.set_column_spacing(12)
    box.pack_start(grid, False, False, 0)
    icon_size = Gtk.IconSize(5)
    error_icon = Gtk.Image.new_from_icon_name("dialog-error", icon_size)
    grid.attach(error_icon, 0, 0, 1, 1)
    grid.attach(message_label, 1, 0, 1, 1)
    popup.show_all()
    if not running_tests:
        popup.run()
        popup.destroy() 
Example #13
Source File: app.py    From vimiv with MIT License 5 votes vote down vote up
def _create_window_structure(self):
        """Generate the structure of all the widgets and add it to the window.

        There is a large Gtk.Grid() to organize the widgets packed into a
        Gtk.Overlay(). The commandline is added as overlay.
        """
        main_grid = Gtk.Grid()
        main_grid.attach(self["library"].grid, 0, 0, 1, 1)
        main_grid.attach(self["main_window"], 1, 0, 1, 1)
        main_grid.attach(self["manipulate"], 0, 1, 2, 1)
        main_grid.attach(self["statusbar"].separator, 0, 2, 2, 1)

        overlay_grid = Gtk.Grid()
        overlay_grid.attach(self["statusbar"], 0, 0, 1, 1)
        overlay_grid.attach(self["completions"].info, 0, 1, 1, 1)
        overlay_grid.attach(self["commandline"], 0, 2, 1, 1)
        overlay_grid.set_valign(Gtk.Align.END)

        # Make it nice using CSS
        overlay_grid.set_name("OverLay")
        style = Gtk.Window().get_style_context()
        bg = style.get_background_color(Gtk.StateType.NORMAL)
        color_str = "#OverLay { background: " + bg.to_string() + "; }"
        command_provider = Gtk.CssProvider()
        command_css = color_str.encode()
        command_provider.load_from_data(command_css)
        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(), command_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

        # Overlay contains grid mainly and adds commandline as floating
        overlay = Gtk.Overlay()
        overlay.add(main_grid)
        overlay.add_overlay(overlay_grid)
        self["window"].add(overlay) 
Example #14
Source File: gui.py    From pysmt with Apache License 2.0 5 votes vote down vote up
def __init__(self, size=3):
        Gtk.Window.__init__(self, title="Sudoku Example")

        self.size = size

        # This is an instance of a Sudoku solver
        self.sudoku = Sudoku(size)

        # Draw the window
        self.table = [[Gtk.Entry() for _ in xrange(size**2)]
                                   for _ in xrange(size**2)]
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add(vbox)

        grid = Gtk.Grid()
        vbox.add(grid)

        for row,lst in enumerate(self.table):
            for col,entry in enumerate(lst):
                entry.set_max_length(3)
                entry.set_hexpand(True)
                entry.set_vexpand(True)
                entry.set_width_chars(2)
                grid.attach(entry, col, row, 1, 1)

        self.solve_button = Gtk.Button(label="Solve")
        self.solve_button.set_hexpand(True)
        vbox.add(self.solve_button)
        self.solve_button.connect("clicked", self.solve)

        self.clear_button = Gtk.Button(label="Clear")
        self.clear_button.set_hexpand(True)
        vbox.add(self.clear_button)
        self.clear_button.connect("clicked", self.clear) 
Example #15
Source File: FlatCAMApp.py    From FlatCAM with MIT License 5 votes vote down vote up
def __init__(self):
        Gtk.VBox.__init__(self, spacing=3, margin=5, vexpand=False)

        ## Plot options
        self.plot_options_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
        self.plot_options_label.set_markup("<b>Plot Options:</b>")
        self.pack_start(self.plot_options_label, expand=False, fill=True, padding=2)

        grid0 = Gtk.Grid(column_spacing=3, row_spacing=2)
        self.pack_start(grid0, expand=True, fill=False, padding=2)

        self.plot_cb = FCCheckBox(label='Plot')
        grid0.attach(self.plot_cb, 0, 0, 1, 1)

        self.solid_cb = FCCheckBox(label='Solid')
        grid0.attach(self.solid_cb, 1, 0, 1, 1)

        ## Create CNC Job
        self.cncjob_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
        self.cncjob_label.set_markup('<b>Create CNC Job</b>')
        self.pack_start(self.cncjob_label, expand=True, fill=False, padding=2)

        grid1 = Gtk.Grid(column_spacing=3, row_spacing=2)
        self.pack_start(grid1, expand=True, fill=False, padding=2)

        l1 = Gtk.Label('Cut Z:', xalign=1)
        grid1.attach(l1, 0, 0, 1, 1)
        self.cutz_entry = LengthEntry()
        grid1.attach(self.cutz_entry, 1, 0, 1, 1)

        l2 = Gtk.Label('Travel Z:', xalign=1)
        grid1.attach(l2, 0, 1, 1, 1)
        self.travelz_entry = LengthEntry()
        grid1.attach(self.travelz_entry, 1, 1, 1, 1)

        l3 = Gtk.Label('Feed rate:', xalign=1)
        grid1.attach(l3, 0, 2, 1, 1)
        self.feedrate_entry = LengthEntry()
        grid1.attach(self.feedrate_entry, 1, 2, 1, 1) 
Example #16
Source File: preview.py    From oomox with GNU General Public License v3.0 5 votes vote down vote up
def init_widgets(self):
        self.gtk_preview = PreviewWidgets()
        self.background = Gtk.Grid(row_spacing=WIDGET_SPACING, column_spacing=6)
        self.attach(self.background, 1, 1, 3, 1)

        self.gtk_preview.set_margin_bottom(WIDGET_SPACING)
        self.background.attach(self.gtk_preview, 1, 3, 1, 1)

        if self.icons_preview:
            self.icons_preview.destroy()
        self.icons_preview = IconThemePreview()
        self.background.attach_next_to(
            self.icons_preview, self.gtk_preview,
            Gtk.PositionType.BOTTOM, 1, 1
        )

        if self.terminal_preview:
            self.terminal_preview.destroy()
        self.terminal_preview = TerminalThemePreview()
        self.terminal_preview.set_margin_bottom(WIDGET_SPACING)
        self.background.attach_next_to(
            self.terminal_preview, self.icons_preview,
            Gtk.PositionType.BOTTOM, 1, 1
        )
        self.background.set_margin_bottom(WIDGET_SPACING)

        self.gtk_preview.button.connect("style-updated", self._queue_resize) 
Example #17
Source File: SeekListPanel.py    From pychess with GNU General Public License v3.0 5 votes vote down vote up
def onAssessReceived(self, glm, assess):
        if self.assess_sent:
            self.assess_sent = False
            dialog = Gtk.MessageDialog(mainwindow(), type=Gtk.MessageType.INFO,
                                       buttons=Gtk.ButtonsType.OK)
            dialog.set_title(_("Assess"))
            dialog.set_markup(_("Effect on ratings by the possible outcomes"))
            grid = Gtk.Grid()
            grid.set_column_homogeneous(True)
            grid.set_row_spacing(12)
            grid.set_row_spacing(12)
            name0 = Gtk.Label()
            name0.set_markup("<b>%s</b>" % assess["names"][0])
            name1 = Gtk.Label()
            name1.set_markup("<b>%s</b>" % assess["names"][1])
            grid.attach(Gtk.Label(label=""), 0, 0, 1, 1)
            grid.attach(name0, 1, 0, 1, 1)
            grid.attach(name1, 2, 0, 1, 1)
            grid.attach(Gtk.Label(assess["type"]), 0, 1, 1, 1)
            grid.attach(Gtk.Label(assess["oldRD"][0]), 1, 1, 1, 1)
            grid.attach(Gtk.Label(assess["oldRD"][1]), 2, 1, 1, 1)
            grid.attach(Gtk.Label(_("Win:")), 0, 2, 1, 1)
            grid.attach(Gtk.Label(assess["win"][0]), 1, 2, 1, 1)
            grid.attach(Gtk.Label(assess["win"][1]), 2, 2, 1, 1)
            grid.attach(Gtk.Label(_("Draw:")), 0, 3, 1, 1)
            grid.attach(Gtk.Label(assess["draw"][0]), 1, 3, 1, 1)
            grid.attach(Gtk.Label(assess["draw"][1]), 2, 3, 1, 1)
            grid.attach(Gtk.Label(_("Loss:")), 0, 4, 1, 1)
            grid.attach(Gtk.Label(assess["loss"][0]), 1, 4, 1, 1)
            grid.attach(Gtk.Label(assess["loss"][1]), 2, 4, 1, 1)
            grid.attach(Gtk.Label(_("New RD:")), 0, 5, 1, 1)
            grid.attach(Gtk.Label(assess["newRD"][0]), 1, 5, 1, 1)
            grid.attach(Gtk.Label(assess["newRD"][1]), 2, 5, 1, 1)
            grid.show_all()
            dialog.get_message_area().add(grid)
            dialog.run()
            dialog.destroy() 
Example #18
Source File: graphview.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def search_config_panel(self, configdialog):
        """
        Function that builds the widget in the configuration dialog.
        See "gramps/gui/configure.py" for details.
        """
        grid = Gtk.Grid()
        grid.set_border_width(12)
        grid.set_column_spacing(6)
        grid.set_row_spacing(6)

        row = 0
        widget = configdialog.add_checkbox(
            grid, _('Search in all database'), row,
            'interface.graphview-search-all-db')
        widget.set_tooltip_text(_("Also apply search by all database."))
        row += 1
        widget = configdialog.add_checkbox(
            grid, _('Show person images'), row,
            'interface.graphview-search-show-images')
        widget.set_tooltip_text(
            _("Show persons thumbnails in search result list."))
        row += 1
        widget = configdialog.add_checkbox(
            grid, _('Show bookmarked first'), row,
            'interface.graphview-search-marked-first')
        widget.set_tooltip_text(
            _("Show bookmarked persons first in search result list."))

        return _('Search'), grid 
Example #19
Source File: graphview.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def animation_config_panel(self, configdialog):
        """
        Function that builds the widget in the configuration dialog.
        See "gramps/gui/configure.py" for details.
        """
        grid = Gtk.Grid()
        grid.set_border_width(12)
        grid.set_column_spacing(6)
        grid.set_row_spacing(6)

        configdialog.add_checkbox(
            grid, _('Show animation'),
            0, 'interface.graphview-show-animation')
        self.ani_widgets.clear()
        widget = configdialog.add_spinner(
            grid, _('Animation speed (1..5 and 5 is the slower)'),
            1, 'interface.graphview-animation-speed', (1, 5))
        self.ani_widgets.append(widget)
        widget = configdialog.add_spinner(
            grid, _('Animation count (0..8 use 0 to turn off)'),
            2, 'interface.graphview-animation-count', (0, 8))
        self.ani_widgets.append(widget)

        # disable animate options if needed
        if not self.graph_widget.animation.show_animation:
            for widget in self.ani_widgets:
                widget.set_sensitive(False)

        return _('Animation'), grid 
Example #20
Source File: sidebar.py    From Silaty with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, stack = Gtk.Stack()):
		Gtk.Grid.__init__(self)
		self.set_orientation(Gtk.Orientation.VERTICAL)
		color = 70.0/256.0
		self.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA.from_color(Gdk.Color.from_floats(color,color,color)))
		self._childlength = 0
		self.stackchildnames = []
		self.stack = stack
		self.connect("window-shown", self.activate_button) 
Example #21
Source File: wizard.py    From syncthing-gtk with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, dialog=None):
		Gtk.Grid.__init__(self)
		self.dialog = dialog
		self.parent = None
		self.init_page()
		self.show_all() 
Example #22
Source File: alttoolbar_type.py    From alternative-toolbar with GNU General Public License v3.0 5 votes vote down vote up
def cleanup(self):
        """
          extend
        :return:
        """

        super(AltToolbarShared, self).cleanup()

        if self.sidebar:
            self.sidebar.cleanup()

        self.display_tree_parent.remove(self.stack)
        self.display_tree_parent.pack1(self.shell.props.display_page_tree)
        if self.sidebar:
            self.rbtreeparent.remove(self.sidebar)  # remove our sidebar
            self.rbtreeparent.add(self.rbtree)  # add the original GtkTree view

        print("####")
        # child, new-parent, old-parent
        for child, new_parent, old_parent in reversed(self._moved_controls):
            if new_parent:
                new_parent.remove(child)
            print(child)
            print(new_parent)
            print(old_parent)
            if isinstance(old_parent, Gtk.Grid):
                print("attaching to grid")
                old_parent.attach(child, 0, 0, 1, 1)
            else:
                print("adding to parent")
                old_parent.add(child) 
Example #23
Source File: HtreePedigreeView.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def build_widget(self):
        """
        Builds the interface and returns a Gtk.Container type that
        contains the interface. This containter will be inserted into
        a Gtk.ScrolledWindow page.
        """
        self.scrolledwindow = Gtk.ScrolledWindow(hadjustment=None,
                                                    vadjustment=None)
        self.scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC,
                                       Gtk.PolicyType.AUTOMATIC)
        self.scrolledwindow.add_events(Gdk.EventMask.SCROLL_MASK)
        self.scrolledwindow.connect("scroll-event", self.cb_bg_scroll_event)
        event_box = Gtk.EventBox()
        # Required for drag-scroll events and popup menu
        event_box.add_events(Gdk.EventMask.BUTTON_PRESS_MASK
                             | Gdk.EventMask.BUTTON_RELEASE_MASK
                             | Gdk.EventMask.BUTTON1_MOTION_MASK)
        # Signal begin drag-scroll
        event_box.connect("button-press-event", self.cb_bg_button_press)
        # Signal end drag-scroll and popup menu
        event_box.connect("button-release-event", self.cb_bg_button_release)
        #Signal for controll motion-notify when left mouse button pressed
        event_box.connect("motion-notify-event", self.cb_bg_motion_notify_event)
        self.scrolledwindow.add(event_box)

        self.table = Gtk.Grid()
        # force LTR layout of the tree, even though the text might be RTL!
        # this way the horizontal scroll preferences will be correct always
        if self.table.get_direction() == Gtk.TextDirection.RTL:
            self.table.set_direction(Gtk.TextDirection.LTR)
            self.table.set_halign(Gtk.Align.END)
        event_box.add(self.table)
        event_box.get_parent().set_shadow_type(Gtk.ShadowType.NONE)
        self.table.set_row_spacing(1)
        self.table.set_column_spacing(0)

        return self.scrolledwindow 
Example #24
Source File: colour_palette.py    From alienfx with GNU General Public License v3.0 5 votes vote down vote up
def set_sensitive(self, sensitive):
        """ Override Gtk.Grid.set_sensitive()."""
        if self.get_parent().get_sensitive() == sensitive:
            return
        self.get_parent().set_sensitive(sensitive)
        for c in self.get_children():
            c.set_active(sensitive) 
Example #25
Source File: configuration.py    From king-phisher with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, application, plugin_klass):
		super(PluginsConfigurationFrame, self).__init__()
		self.application = application
		self.config = application.config
		self.plugin_klass = plugin_klass
		self.option_widgets = {}
		self.logger = logging.getLogger('KingPhisher.Client.' + self.__class__.__name__)
		plugin_config = self.config['plugins'].get(plugin_klass.name) or {}  # use or instead of get incase the value is actually None

		grid = Gtk.Grid()
		self.add(grid)
		grid.set_property('margin-start', 12)
		grid.set_property('column-spacing', 3)
		grid.set_property('hexpand', True)
		grid.set_property('row-spacing', 3)
		grid.insert_column(0)
		grid.insert_column(0)
		grid.attach(self._get_title_box(), 0, 0, 2, 1)
		for row, opt in enumerate(plugin_klass.options, 1):
			grid.insert_row(row)

			name_label = Gtk.Label()
			name_label.set_property('tooltip-text', opt.description)
			name_label.set_property('width-request', 175)
			name_label.set_text(opt.display_name)
			grid.attach(name_label, 0, row, 1, 1)

			try:
				widget = opt.get_widget(self.application, plugin_config.get(opt.name, opt.default))
			except Exception:
				self.logger.error("can not build configuration widget for plugin: {}, option: {}".format(plugin_klass.name, opt.name))
				continue
			widget.set_property('tooltip-text', opt.description)
			grid.attach(widget, 1, row, 1, 1)
			self.option_widgets[opt.name] = OptionWidget(opt, widget)
		self.show_all() 
Example #26
Source File: message.py    From epoptes with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, text, title="Epoptes", markup=True,
                 icon_name="dialog-information"):
        super().__init__(title=title, icon_name=icon_name)
        self.set_position(Gtk.WindowPosition.CENTER)

        grid = Gtk.Grid(column_spacing=10, row_spacing=10, margin=10)
        self.add(grid)

        image = Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.DIALOG)
        grid.add(image)

        # Always load the plain text first in case the markup parsing fails
        label = Gtk.Label(
            label=text, selectable=True, hexpand=True, vexpand=True,
            halign=Gtk.Align.START, valign=Gtk.Align.START)
        if markup:
            label.set_markup(text)
        grid.add(label)

        button = Gtk.Button.new_from_stock(Gtk.STOCK_CLOSE)
        button.set_hexpand(False)
        button.set_halign(Gtk.Align.END)
        button.connect("clicked", Gtk.main_quit)
        grid.attach(button, 1, 1, 2, 1)
        self.set_focus_child(button)

        accelgroup = Gtk.AccelGroup()
        key, modifier = Gtk.accelerator_parse('Escape')
        accelgroup.connect(
            key, modifier, Gtk.AccelFlags.VISIBLE, Gtk.main_quit)
        self.add_accel_group(accelgroup) 
Example #27
Source File: dialog.py    From ImEditor with GNU General Public License v3.0 5 votes vote down vote up
def details_dialog(parent, infos):
    dialog = Dialog(parent, _("Image details"))

    grid = Gtk.Grid(row_spacing=12, column_spacing=12, column_homogeneous=True)
    grid.attach(Gtk.Label('<b>' + _("Name") + '</b>',
        use_markup=True, xalign=0.0), 0, 0, 1, 1)
    grid.attach(Gtk.Label(infos['name'], xalign=0.0), 1, 0, 1, 1)
    grid.attach(Gtk.Label('<b>' + _("Mode") + '</b>',
        use_markup=True, xalign=0.0), 0, 1, 1, 1)
    grid.attach(Gtk.Label(infos['mode'], xalign=0.0), 1,1, 1, 1)
    grid.attach(Gtk.Label('<b>' + _("Size") + '</b>',
        use_markup=True, xalign=0.0), 0, 2, 1, 1)
    grid.attach(Gtk.Label(infos['size'], xalign=0.0), 1, 2, 1, 1)

    if len(infos) > 3:
        grid.attach(Gtk.Label('<b>' + _("Weight") + '</b>',
            use_markup=True, xalign=0.0), 0, 3, 1, 1)
        grid.attach(Gtk.Label(infos['weight'], xalign=0.0), 1, 3, 1, 1)
        grid.attach(Gtk.Label('<b>' + _("Last change") + '</b>',
            use_markup=True, xalign=0.0), 0, 4, 1, 1)
        grid.attach(Gtk.Label(infos['last_change'], xalign=0.0), 1, 4, 1, 1)

    close_button = Gtk.Button.new_with_label(_("Close"))
    close_button.connect('clicked', dialog.close)
    close_button.get_style_context().add_class(Gtk.STYLE_CLASS_SUGGESTED_ACTION)

    grid.attach(close_button, 0, 5, 2, 1)

    dialog.dialog_box.add(grid)
    dialog.launch() 
Example #28
Source File: set_advanced.py    From kano-settings with GNU General Public License v2.0 5 votes vote down vote up
def _labelled_list_helper(self, desc, box):
        grid = Gtk.Grid()
        grid.attach(box, 0, 0, 1, 1)

        i = 1

        for text in desc[1:]:
            label = Gtk.Label(text)
            label.set_alignment(xalign=0, yalign=0.5)
            label.set_padding(xpad=25, ypad=0)
            label.get_style_context().add_class('normal_label')
            grid.attach(label, 0, i, 1, 1)
            i = i + 1

        return grid 
Example #29
Source File: templates.py    From kano-settings with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, size_x=400, size_y=150):
        Gtk.Grid.__init__(self)

        self.set_row_spacing(10)
        self.set_column_spacing(10)

        scroll = ScrolledWindow()
        scroll.set_size_request(size_x, size_y)
        scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)

        self.edit_list_store = Gtk.ListStore(str)
        self.edit_list = Gtk.TreeView(self.edit_list_store)
        self.edit_list.set_headers_visible(False)

        renderer = Gtk.CellRendererText()
        renderer.set_property('editable', True)
        renderer.connect('edited', self._item_edited_handler)
        renderer.connect('editing-started', self._item_edit_started)
        renderer.connect('editing-canceled', self._item_edit_canceled)
        column = Gtk.TreeViewColumn(cell_renderer=renderer, text=0)
        self.edit_list.append_column(column)

        self._add_btn = KanoButton(_("ADD"))
        self._add_btn.connect('button-release-event', self.add)
        self._rm_btn = KanoButton(_("REMOVE"))
        self._set_rm_btn_state()
        self._rm_btn.connect('button-release-event', self.rm)

        scroll.add_with_viewport(self.edit_list)

        self.attach(scroll, 0, 0, 2, 1)
        self.attach(self._add_btn, 0, 1, 1, 1)
        self.attach(self._rm_btn, 1, 1, 1, 1) 
Example #30
Source File: menu_button.py    From kano-settings with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, name, description=''):

        # Contains the info about the level and the image
        self.container = Gtk.Grid()
        self.container.set_hexpand(True)
        self.container.props.margin = 20

        # Info about the different settings
        self.title = Gtk.Label(_(name))
        self.title.get_style_context().add_class('menu_intro_label')
        self.title.set_alignment(xalign=0, yalign=0)
        self.title.props.margin_top = 10

        self.description = Gtk.Label(description)
        self.description.get_style_context().add_class('menu_custom_label')
        self.description.set_ellipsize(Pango.EllipsizeMode.END)
        self.description.set_size_request(130, 10)
        self.description.set_alignment(xalign=0, yalign=0)
        self.description.props.margin_bottom = 8

        self.button = Gtk.Button()
        self.button.set_can_focus(False)
        cursor.attach_cursor_events(self.button)
        self.img = Gtk.Image()
        self.img.set_from_file(common.media + "/Icons/Icon-" + name + ".png")

        self.container.attach(self.title, 2, 0, 1, 1)
        self.container.attach(self.description, 2, 1, 1, 1)
        self.container.attach(self.img, 0, 0, 2, 2)
        self.container.set_row_spacing(2)
        self.container.set_column_spacing(20)
        self.container.props.valign = Gtk.Align.CENTER

        self.button.add(self.container)