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

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

项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def __init__(self,  filename, init_hilighted=True):
        Gtk.EventBox.__init__(self)
        self.cache = {}
        self.areas = []

        self.connect("motion-notify-event", self.on_mouse_moved)
        self.connect("button-press-event", self.on_mouse_click)
        self.set_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.BUTTON_PRESS_MASK)

        self.size_override = None
        self.image_width = 1
        self.image_height = 1
        self.set_image(filename)
        self.image = Gtk.Image()
        if init_hilighted:
            self.hilight({})
        self.add(self.image)
        self.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()
项目: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)
项目: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 add_year(self, year_number):
        # Create a new grid for the year 
        year_grid = yearGrid(year_number)
        # Update map of years
        self.year_map[year_number] = year_grid
        label_box = Gtk.EventBox()
        label_box.connect('button-press-event', self.year_clicked)
        label = Gtk.Label(self.nth[year_number] + " Year")
        label_box.add(label)

        left_separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)
        left_separator.set_margin_start(1)
        left_separator.set_margin_end(10)
        self.attach(left_separator, self.new_column(), 0, 1, 3)

        self.attach(year_grid, self.new_column(), 2, 1, 1)
        self.attach(label_box, self.width, 0, 1, 1)

        right_separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)
        right_separator.set_margin_start(10)
        right_separator.set_margin_end(1)
        self.attach(right_separator, self.new_column(), 0, 1, 3)
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def __init__(self, text=None):
        Gtk.EventBox.__init__(self)
        self.text = text 
        self.has_entry = False 

        if text is not None:
            self.label = Gtk.Label(text)
            self.add(self.label)
        else:
            self.entry = Gtk.Entry()
            self.entry.connect('activate', self.enter_key)
            self.add(self.entry)
            self.has_entry = True 

        self.connect('button-press-event', self.double_click)


        self.show_all()
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, size=StarSize.NORMAL):
        Gtk.EventBox.__init__(self)
        StarRenderer.__init__(self)
        self.set_name("featured-star")

        self.label = None
        self.size = size

        self.xalign = 0.5
        self.yalign = 0.5

        self._render_allocation_bbox = False

        self.set_visible_window(False)
        self.connect("draw", self.on_draw)
        self.connect("style-updated", self.on_style_updated)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, size=StarSize.NORMAL):
        Gtk.EventBox.__init__(self)
        StarRenderer.__init__(self)
        self.set_name("featured-star")

        self.label = None
        self.size = size

        self.xalign = 0.5
        self.yalign = 0.5

        self._render_allocation_bbox = False

        self.set_visible_window(False)
        self.connect("draw", self.on_draw)
        self.connect("style-updated", self.on_style_updated)
项目:my-weather-indicator    作者:atareao    | 项目源码 | 文件源码
def __init__(self, adate=None):
        Gtk.EventBox.__init__(self)
        self.set_size_request(100, 70)
        box1 = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
        self.add(box1)
        self.label = Gtk.Label()
        box1.pack_start(self.label, True, True, padding=1)
        self.image = Gtk.Image()
        box1.pack_start(self.image, True, True, padding=1)
        if adate is not None:
            self.set_date(adate)
        self.image.show()
项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def __init__(self, imagepath, config):
        Gtk.EventBox.__init__(self)
        UserDataManager.__init__(self)
        self.imagepath = imagepath
        self.config = config
        self._allow_new = False
        self._first_time = True
        self._current = None
        self._recursing = False
        self._timer = None  # Used to prevent sending too many request
                            # when user scrolls throught combobox
        self._signal = None
        self._controller = None
        self.setup_widgets()
项目:budgie-extras    作者:UbuntuBudgie    | 项目源码 | 文件源码
def __init__(self, uuid):
        Budgie.Applet.__init__(self)
        self.uuid = uuid
        ismuted = os.path.exists(wmt.wmover_ismuted)
        self.box = Gtk.EventBox()
        if not ismuted:
            self.initiate()
项目:budgie-extras    作者:UbuntuBudgie    | 项目源码 | 文件源码
def __init__(self, uuid):
        Budgie.Applet.__init__(self)
        self.box = Gtk.EventBox()
        self.lockicon = Gtk.Image.new_from_icon_name(
            "budgie-rotation-lock-button",
            Gtk.IconSize.MENU,
        )

        self.unlockicon = Gtk.Image.new_from_icon_name(
            "budgie-rotation-button",
            Gtk.IconSize.MENU,
        )

        if Gtk.get_major_version() == 3 and \
                Gtk.get_minor_version() == 18:
            # GTK+3.18
            schema = "org.gnome.settings-daemon.plugins.orientation"
            self.key = "active"
        else:
            # > GTK+3.18
            schema = "org.gnome.settings-daemon.peripherals.touchscreen"
            self.key = "orientation-lock"

        self.settings = Gio.Settings.new(schema)

        if self.settings.get_boolean(self.key):
            if self.key == "active":
                self.displayicon = self.unlockicon
            else:
                self.displayicon = self.lockicon
        else:
            if self.key == "active":
                self.displayicon = self.lockicon
            else:
                self.displayicon = self.unlockicon

        self.box.add(self.displayicon)
        self.add(self.box)
        self.box.show_all()
        self.show_all()
        self.box.connect("button-press-event", self.on_press)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def sad_face(self):
        l = gu.HarmonicProgressionLabel(_("Wrong"))
        l.show()
        self.g_box.pack_start(l, False, False, 0)
        self.g_face = Gtk.EventBox()
        self.g_face.connect('button_press_event', self.on_sadface_event)
        self.g_face.show()
        im = Gtk.Image()
        im.set_from_stock('solfege-sadface', Gtk.IconSize.LARGE_TOOLBAR)
        im.show()
        self.g_face.add(im)
        self.g_box.pack_start(self.g_face, False, False, 0)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def happy_face(self):
        l = gu.HarmonicProgressionLabel(_("Correct"))
        l.show()
        self.g_box.pack_start(l, False, False, 0)
        self.g_face = Gtk.EventBox()
        self.g_face.connect('button_press_event', self.on_happyface_event)
        self.g_face.show()
        im = Gtk.Image()
        im.set_from_stock('solfege-happyface', Gtk.IconSize.LARGE_TOOLBAR)
        im.show()
        self.g_face.add(im)
        self.g_box.pack_start(self.g_face, False, False, 0)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def sad_face(self):
        l = gu.HarmonicProgressionLabel(_("Wrong"))
        l.show()
        self.g_box.pack_start(l, False, False, 0)
        self.g_face = Gtk.EventBox()
        self.g_face.connect('button_press_event', self.on_sadface_event)
        self.g_face.show()
        im = Gtk.Image()
        im.set_from_stock('solfege-sadface', Gtk.IconSize.LARGE_TOOLBAR)
        im.show()
        self.g_face.add(im)
        self.g_box.pack_start(self.g_face, False, False, 0)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def happy_face(self):
        l = gu.HarmonicProgressionLabel(_("Correct"))
        l.show()
        self.g_box.pack_start(l, False, False, 0)
        self.g_face = Gtk.EventBox()
        self.g_face.connect('button_press_event', self.on_happyface_event)
        self.g_face.show()
        im = Gtk.Image()
        im.set_from_stock('solfege-happyface', Gtk.IconSize.LARGE_TOOLBAR)
        im.show()
        self.g_face.add(im)
        self.g_box.pack_start(self.g_face, False, False, 0)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def get_save_as_dialog(self):
        dialog = gu.EditorDialogBase.get_save_as_dialog(self)
        ev2 = Gtk.EventBox()
        ev2.set_name("DIALOGWARNING2")
        ev = Gtk.EventBox()
        ev.set_border_width(gu.hig.SPACE_SMALL)
        ev2.add(ev)
        ev.set_name("DIALOGWARNING")
        label = Gtk.Label()
        label.set_padding(gu.hig.SPACE_MEDIUM, gu.hig.SPACE_MEDIUM)
        ev.add(label)
        label.set_markup(_("<b>IMPORTANT:</b> Your front page file <b>must</b> be saved in a subdirectory below the directory named exercises. See the user manual for details."))
        dialog.set_extra_widget(ev2)
        ev2.show_all()
        return dialog
项目:ibus-typing-booster    作者:mike-fabian    | 项目源码 | 文件源码
def _emoji_event_box_selected(self, event_box):
        '''
        Called when an event box containing an emoji
        was selected in the flowbox.

        The emoji is then copied to the clipboard and a popover
        pops up for a short time to notify the user that the emoji
        has been copied to the clipboard.

        :param event_box: The event box which contains the emoji
        :type event_box: Gtk.EventBox 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 = event_box.get_child().get_label()
        if _ARGS.debug:
            sys.stdout.write("_emoji_event_box_selected() text = %s\n" %text)
        (emoji, name) = self._parse_emoji_and_name_from_text(text)
        if not emoji:
            return Gdk.EVENT_PROPAGATE
        self._set_clipboards(emoji)
        self._add_to_recently_used(emoji)
        self._emoji_selected_popover = Gtk.Popover()
        self._emoji_selected_popover.set_relative_to(event_box)
        self._emoji_selected_popover.set_position(Gtk.PositionType.TOP)
        if name:
            rectangle = Gdk.Rectangle()
            rectangle.x = 0
            rectangle.y = 0
            rectangle.width = self._fontsize * 1.5
            rectangle.height = self._fontsize * 1.5
            self._emoji_selected_popover.set_pointing_to(rectangle)
        label = Gtk.Label(_('Copied to clipboard!'))
        self._emoji_selected_popover.add(label)
        if GTK_VERSION >= (3, 22, 0):
            self._emoji_selected_popover.popup()
        self._emoji_selected_popover.show_all()
        GLib.timeout_add(500, self._emoji_selected_popover_popdown)
项目:ibus-typing-booster    作者:mike-fabian    | 项目源码 | 文件源码
def on_flowbox_event_box_button_release(
            self, event_box, event_button):
        '''
        Signal handler for button release events on labels in the flowbox

        :param event_box: The event box containing the label with the emoji.
        :type event_box: Gtk.EventBox object
        :param event_button: The event button
        :type event_button: Gdk.EventButton object
        '''
        if _ARGS.debug:
            sys.stdout.write(
                'on_flowbox_event_box_button_release() '
                + 'event_button.type=%s ' %event_button.type
                + 'event_button.window=%s ' %event_button.window
                + 'event_button.button=%s\n' %event_button.button)
        if event_button.button == 1:
            # Call self._emoji_event_box_selected() in the release
            # event because here we know that it has not been a long
            # press, i.e. no request for a skin tone popover.
            self._emoji_event_box_selected(event_box)
        if event_button.button == 2 and self._skin_tone_popover:
            # not used if the popover is modal, in that case this
            # handler for the button release event will not be called.
            if GTK_VERSION >= (3, 22, 0):
                self._skin_tone_popover.popdown()
            self._skin_tone_popover.hide()
        if event_button.button == 3 and self._emoji_info_popover:
            # not used if the popover is modal, in that case this
            # handler for the button release event will not be called.
            if GTK_VERSION >= (3, 22, 0):
                self._emoji_info_popover.popdown()
            self._emoji_info_popover.hide()
        return Gdk.EVENT_PROPAGATE
项目:ghetto_omr    作者:pohzhiee    | 项目源码 | 文件源码
def __init__(self,label_str,parent):
        Gtk.EventBox.__init__(self)
        self.num = -1
        self.stepgrid = parent
        self.label = label_str
        some_label = Gtk.Label(label_str)
        self.add(some_label)
        self.connect("button-press-event",self.on_button_press)
项目:ukui-menu    作者:ukui    | 项目源码 | 文件源码
def __init__( self, keybinder, settings ):
        self.keybinder = keybinder
        self.settings = settings


        self.data_path = os.path.join( '/', 'usr', 'share', 'ukui-menu' )
        self.icon = "/usr/share/ukui-menu/icons/ukui-logo.svg"

        # Load UI file and extract widgets
        builder = Gtk.Builder()
        builder.add_from_file(os.path.join( self.data_path, "ukui-menu.glade" ))
        self.window     = builder.get_object( "mainWindow" )
        self.eventbox   = builder.get_object( "eventbox1" )
        self.paneholder = builder.get_object( "paneholder" )
        self.border     = builder.get_object( "border" )

        builder.connect_signals(self)

        self.borderwidth = 1
        self.border.set_padding( self.borderwidth, self.borderwidth, self.borderwidth, self.borderwidth )
        defaultStyle = self.getDefaultStyle()
        color = defaultStyle.lookup_color('taskbar_applet_border_color')[1]
        if color == Gdk.Color(red=0, green=0, blue=0):
            self.window.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse( "#014276" ))
        else:
            self.window.modify_bg( Gtk.StateType.NORMAL, color )
        self.eventbox.set_name("EventBox")

        self.window.connect( "key-press-event", self.onKeyPress )
        self.window.connect( "focus-in-event", self.onFocusIn )
        self.loseFocusId = self.window.connect( "focus-out-event", self.onFocusOut )
        self.loseFocusBlocked = False

        self.offset = 0

        self.window.stick()

        self.PopulatePlugins()
项目:ukui-menu    作者:ukui    | 项目源码 | 文件源码
def getDefaultStyle( self ):
        widget = Gtk.EventBox()
        widget.show()
        return Gtk.rc_get_style(widget)
项目:razerCommander    作者:GabMus    | 项目源码 | 文件源码
def build_key_box(key, color, signal_handler):
    box = Gtk.EventBox()
    if not key.isGhost:
        box.get_style_context().add_class('keycap')
        key.color = color
        box.override_background_color(
            Gtk.StateType.NORMAL,
            color
        )
        label = Gtk.Label()
        label.set_text(key.label)
        box.add(label)
    box.keyx = key.x
    box.keyy = key.y
    if key.label in ['tab', 'lctrl', 'lalt', 'ralt', 'rctrl', '\\']:
        box.set_size_request(KEYCAP_SIZE * 1.5, KEYCAP_SIZE)
    elif key.label == 'capslk':
        box.set_size_request(KEYCAP_SIZE * 1.75, KEYCAP_SIZE)
    elif key.label == 'lshift':  # in ['lshift', 'ret']:
        box.set_size_request(KEYCAP_SIZE * 2.25, KEYCAP_SIZE)
    elif key.label == 'ret':
        box.set_size_request(KEYCAP_SIZE * 2.10, KEYCAP_SIZE)
    elif key.label == 'rshift':
        box.set_size_request(KEYCAP_SIZE * 2.75, KEYCAP_SIZE)
    elif key.label == 'bck\nspc':
        box.set_size_request(KEYCAP_SIZE * 2, KEYCAP_SIZE)
    elif key.label == 'spacebar':
        box.set_size_request(KEYCAP_SIZE * 6, KEYCAP_SIZE)
    elif key.label == CustomKb.kblayouts.INV_GHOST:
        box.set_size_request(0, 0)
        box.set_no_show_all(True)
        box.set_visible(False)
    elif key.label == CustomKb.kblayouts.GHOST:
        box.set_size_request(KEYCAP_SIZE, KEYCAP_SIZE)
    else:
        box.set_size_request(KEYCAP_SIZE, KEYCAP_SIZE)
    box.connect('button-press-event', signal_handler)
    return box
项目:cozy    作者:geigi    | 项目源码 | 文件源码
def _on_enter_notify(self, widget, event):
        """
        On enter notify change overlay opacity
        :param widget: as Gtk.EventBox
        :param event: as Gdk.Event
        """
        self.overlay.set_opacity(0.8)
        self.play_revealer.set_reveal_child(True)
项目:cozy    作者:geigi    | 项目源码 | 文件源码
def _on_leave_notify(self, widget, event):
        """
        On leave notify change overlay opacity
        :param widget: as Gtk.EventBox (can be None)
        :param event: as Gdk.Event (can be None)
        """
        if not self.selected:
            self.overlay.set_opacity(1.0)
            self.play_revealer.set_reveal_child(False)
项目:cozy    作者:geigi    | 项目源码 | 文件源码
def _on_enter_notify(self, widget, event):
        """
        On enter notify add css hover class
        :param widget: as Gtk.EventBox
        :param event: as Gdk.Event
        """
        if self.ui.current_track_element is not self and not self.selected:
            self.play_img.set_from_icon_name(
                "media-playback-start-symbolic", Gtk.IconSize.SMALL_TOOLBAR)
        self.box.get_style_context().add_class("box_hover")
        self.play_img.get_style_context().add_class("box_hover")
项目:cozy    作者:geigi    | 项目源码 | 文件源码
def _on_leave_notify(self, widget, event):
        """
        On leave notify remove css hover class
        :param widget: as Gtk.EventBox (can be None)
        :param event: as Gdk.Event (can be None)
        """
        self.box.get_style_context().remove_class("box_hover")
        self.play_img.get_style_context().remove_class("box_hover")
        if self.ui.current_track_element is not self and not self.selected:
            self.play_img.clear()
项目:cozy    作者:geigi    | 项目源码 | 文件源码
def _on_leave_notify(self, widget, event):
        """
        On leave notify remove css hover class
        :param widget: as Gtk.EventBox (can be None)
        :param event: as Gdk.Event (can be None)
        """
        self.box.get_style_context().remove_class("box_hover")
项目:mate-menu    作者:ubuntu-mate    | 项目源码 | 文件源码
def getDefaultColors( self ):
        widget = Gtk.EventBox()
        widget.show()

        context = widget.get_style_context()
        context.set_state( Gtk.StateFlags.NORMAL )
        context.add_class( Gtk.STYLE_CLASS_DEFAULT )
        context.add_class( Gtk.STYLE_CLASS_BACKGROUND )

        fgColor = context.get_color( context.get_state() )
        bgColor = context.get_background_color( context.get_state() )
        borderColor = context.get_border_color( context.get_state() )

        return { "fg": fgColor, "bg": bgColor, "border": borderColor }
项目:mate-menu    作者:ubuntu-mate    | 项目源码 | 文件源码
def favoritesBuildSpace( self ):
        space = Gtk.EventBox()
        space.set_size_request( -1, 20 )
        space.set_visible_window(False)
        space.connect( "button-press-event", self.favPopup )
        space.type = "space"

        space.show()

        return space
项目:mate-menu    作者:ubuntu-mate    | 项目源码 | 文件源码
def favoritesBuildSeparator( self ):
        separator = Gtk.Separator( orientation=Gtk.Orientation.HORIZONTAL )
        separator.set_margin_top( 5 )
        separator.set_margin_bottom( 5 )
        separator.type = "separator"

        separator.show_all()
        box = Gtk.EventBox()
        box.type = "separator"
        box.add(separator)
        box.set_visible_window(False)
        box.connect( "button-press-event", self.favPopup )
        box.show_all()
        return box
项目:budgie-extras    作者:UbuntuBudgie    | 项目源码 | 文件源码
def __init__(self, uuid):
        Budgie.Applet.__init__(self)
        self.uuid = uuid
        self.connect("destroy", Gtk.main_quit)
        self.settings = cw.settings
        icon = Gtk.Image.new_from_icon_name(
            "budgie-clockworks-panel", Gtk.IconSize.MENU
        )
        self.provider = Gtk.CssProvider.new()
        self.provider.load_from_data(css_data.encode())
        # maingrid
        self.maingrid = Gtk.Grid()
        self.maingrid.set_row_spacing(2)
        self.maingrid.attach(Gtk.Label(" " * 10), 0, 0, 1, 1)
        self.maingrid.set_column_spacing(5)
        self.clocklist = {}
        # create initial clock if it does not exists
        currcl_data = self.read_datafile()
        if currcl_data:
            for cl in currcl_data:
                off = cl[1]
                clname = cl[2]
                self.create_newclock(offset=off, clockname=clname)
        else:
            self.create_newclock(offset=0)
        self.dashbuttonbox = Gtk.Box()
        self.add_button = Gtk.Button()
        self.add_button.set_relief(Gtk.ReliefStyle.NONE)
        self.add_icon = Gtk.Image.new_from_icon_name(
            "list-add-symbolic", Gtk.IconSize.MENU
        )
        self.add_button.set_image(self.add_icon)
        self.search_button = Gtk.Button()
        self.search_button.set_relief(Gtk.ReliefStyle.NONE)
        self.search_icon = Gtk.Image.new_from_icon_name(
            "system-search-symbolic", Gtk.IconSize.MENU
        )
        self.search_button.set_image(self.search_icon)
        self.add_button.connect("clicked", self.create_newclock)
        self.search_button.connect("clicked", self.run_search)
        self.maingrid.attach(self.add_button, 100, 3, 1, 1)
        self.maingrid.attach(self.search_button, 100, 4, 1, 1)
        # throw it in popover
        self.box = Gtk.EventBox()
        self.box.add(icon)
        self.add(self.box)
        self.popover = Budgie.Popover.new(self.box)
        self.popover.add(self.maingrid)
        self.popover.get_child().show_all()
        self.box.show_all()
        self.show_all()
        self.box.connect("button-press-event", self.on_press)
        self.settings.connect("changed", self.update_clockcolor)
        # thread
        GObject.threads_init()
        self.update = Thread(target=self.update_gmt)
        # daemonize the thread to make the indicator stopable
        self.update.setDaemon(True)
        self.update.start()
项目: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
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def __init__(self, year):
        Gtk.Grid.__init__(self)
        self.year = year
        self.selected_quarter = None 

        self.quarters = {
                0: "Fall",
                1: "Winter",
                2: "Spring",
                3: "Summer"
        }
        self.hidden = {x: False for x in [0,2,4,6]} 

        self.quarter_map = {}

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

        horizontal_separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
        horizontal_separator.set_margin_top(2)
        horizontal_separator.set_margin_bottom(5)
        self.attach(horizontal_separator, 0, 1, 2, 1)

        for x in [0,2,4,6]:
            if x < 6:
                # Don't insert a column if it's at position 0 
                if x: self.insert_column(x)
                # Insert column to expand horizontal separator
                self.insert_column(x+1)

                vertical_separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)
                vertical_separator.set_margin_start(5)
                vertical_separator.set_margin_end(5)
                self.attach(vertical_separator, x+1, 0, 1, 3)

            quarter = quarterColumn(self.year, self.quarters[x/2])

            label_box = Gtk.EventBox()
            label = Gtk.Label(self.quarters[x/2])
            label_box.add(label)
            label_box.connect('button-press-event', self.quarter_clicked) 
            self.attach(label_box, x, 0, 1, 1)

            self.quarter_map[x/2] = quarter 
            self.attach(quarter, x, 2, 1, 1)

        self.hide_menu = Gtk.Menu()
        hide_button = Gtk.MenuItem.new_with_label('Hide')
        self.hide_menu.append(hide_button)
        hide_button.show()
        hide_button.connect('activate', self.toggle_quarter)


        self.show_all()
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def __init__(self, title, catalog, units, prereqs, time, course_type, ge_type, course_id, notes):
        Gtk.EventBox.__init__(self)
        Course.__init__(
                self, title, catalog, units, prereqs, time, course_type, ge_type, course_id, notes)

        self.course_class = self.course_type.lower().replace(" ", "-")
        self.get_style_context().add_class(self.course_class)

        self.set_size_request(200, -1)

        self.frame = Gtk.Frame()
        self.add(self.frame) 

        self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
        self.box.set_margin_top(10)
        self.box.set_margin_bottom(10)
        self.box.set_margin_start(5)
        self.box.set_margin_end(5)
        self.frame.add(self.box)

        if self.notes is not None:
            self.title_text = Gtk.Label(self.title + "*")
        else:
            self.title_text = Gtk.Label(self.title)

        self.catalog_text = Gtk.Label(self.catalog)
        self.credits_text = Gtk.Label("(" + str(self.credits) + ")")

        if self.prereqs and self.prereqs != ['']:
            self.prereqs_text = Gtk.Label("(" + ', '.join(self.prereqs) + ")")
            self.prereqs_text.get_style_context().add_class('prereq-text')
            self.prereqs_text.set_justify(Gtk.Justification.CENTER)
            self.prereqs_text.set_line_wrap(True)
            self.box.pack_end(self.prereqs_text, True, True, 0)

        if self.ge_type != [None] and self.ge_type != []:
            self.ge_text = Gtk.Label("[" + '/'.join(self.ge_type) + "]")
            self.ge_text.get_style_context().add_class('ge-text')
            self.box.pack_end(self.ge_text, True, True, 0)

        self.title_text.set_line_wrap(True)

        self.title_text.set_justify(Gtk.Justification.CENTER)
        self.catalog_text.set_justify(Gtk.Justification.CENTER)
        self.credits_text.set_justify(Gtk.Justification.CENTER)

        self.box.pack_start(self.title_text, True, True, 0)
        self.box.pack_start(self.catalog_text, True, True, 0)
        self.box.pack_start(self.credits_text, True, True, 0)

        self.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, [],
            DRAG_ACTION)

        self.set_tooltip_text(self.notes)

        self.show_all()
项目:draobpilc    作者:awamper    | 项目源码 | 文件源码
def __init__(self):
        super().__init__(_('Preview'), ItemsProcessorPriority.HIGH)

        self._thumb_max_width = Previewer.THUMB_MAX_WIDTH
        self._thumb_max_height = Previewer.THUMB_MAX_HEIGHT

        self._thumb = ItemThumb()
        self._thumb.set_vexpand(True)
        self._thumb.set_hexpand(True)
        self._thumb.set_valign(Gtk.Align.CENTER)
        self._thumb.set_halign(Gtk.Align.CENTER)
        self._thumb.props.margin = ItemsProcessorBase.MARGIN
        self._thumb.show()

        self._thumb_eventbox = Gtk.EventBox()
        self._thumb_eventbox.set_no_show_all(True)
        self._thumb_eventbox.add(self._thumb)
        self._thumb_eventbox.connect(
            'realize',
            self._change_cursor
        )
        self._thumb_eventbox.connect(
            'button-release-event',
            self._on_thumb_button_release
        )
        self._thumb_eventbox.set_tooltip_text(
            _('Click to locate the file on disk')
        )
        self._thumb_eventbox.hide()

        self._path_entry = Gtk.Entry()
        self._path_entry.set_editable(False)
        self._path_entry.set_hexpand(True)
        self._path_entry.set_icon_from_icon_name(
            Gtk.EntryIconPosition.PRIMARY,
            'system-file-manager-symbolic'
        )
        self._path_entry.props.margin = ItemsProcessorBase.MARGIN

        self._text_window = TextWindow()
        self._text_window.set_no_show_all(True)
        self._text_window.textview.set_name('EditorTextView')
        self._text_window.textview.set_editable(False)
        self._text_window.hide()

        self.grid.set_name('PreviwerGrid')
        self.grid.attach(self._path_entry, 0, 0, 2, 1)
        self.grid.attach(self._thumb_eventbox, 0, 1, 2, 1)
        self.grid.attach(self._text_window, 0, 1, 2, 1)
项目:ukui-menu    作者:ukui    | 项目源码 | 文件源码
def PopulatePlugins( self ):
        PluginPane = Gtk.EventBox()
        PluginPane.show()
        PaneLadder = Gtk.Box( orientation=Gtk.Orientation.VERTICAL )
        PluginPane.add( PaneLadder )
        ImageBox = Gtk.EventBox()
        ImageBox.show()

        self.pluginlist           = self.settings.get_strv( "plugins-list" )
        self.plugins = {}

        self.showCategoryMenu = self.settings.get_boolean("show-category-menu")

        try:
            MyPlugin = pluginclass(self, self.showCategoryMenu)
        except Exception as e:
            print (e)
        MyPlugin.content_holder.show()

        VBox1 = Gtk.Box( orientation=Gtk.Orientation.VERTICAL )
        VBox1.show()
        #Add plugin to Plugin Box under heading button
        MyPlugin.content_holder.reparent( VBox1 )

        #Add plugin to main window
        PaneLadder.pack_start( VBox1 , True, True, 0)
        PaneLadder.show()

        if MyPlugin.window:
            MyPlugin.window.destroy()

        try:
            if hasattr( MyPlugin, 'do_plugin' ):
                MyPlugin.do_plugin()

            heightPath = os.path.join(GLib.get_home_dir(), ".windowHeight")
            if os.path.exists(heightPath):
                f = open(heightPath, "r")
                lines = f.readlines()
                length = lines[0]
                MyPlugin.windowHeight = int(length)
                f.close()
            MyPlugin.content_holder.set_size_request(345, MyPlugin.windowHeight )
        except Exception as e:
            print (e)

        self.plugins["menu"] = MyPlugin

        self.paneholder.pack_start( ImageBox, False, False, 0 )
        self.paneholder.pack_start( PluginPane, False, False, 0 )
项目:cozy    作者:geigi    | 项目源码 | 文件源码
def __init__(self, t, ui):
        self.track = t
        self.ui = ui

        super(Gtk.EventBox, self).__init__()
        self.connect("enter-notify-event", self._on_enter_notify)
        self.connect("leave-notify-event", self._on_leave_notify)
        self.connect("button-press-event", self.__on_button_press)
        self.set_tooltip_text(_("Play this part"))

        # 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)

        # These are the widgets that contain data
        self.play_img = Gtk.Image()
        no_label = Gtk.Label()
        title_label = Gtk.Label()
        dur_label = Gtk.Label()

        self.play_img.set_margin_right(5)
        self.play_img.props.width_request = 16

        no_label.set_text(str(self.track.number))
        no_label.props.margin = 4
        no_label.set_margin_right(7)
        no_label.set_margin_left(0)
        no_label.set_size_request(30, -1)
        no_label.set_xalign(1)

        title_label.set_text((self.track.name[:MAX_TRACK_LENGTH] + '...') if len(
            self.track.name) > MAX_TRACK_LENGTH else self.track.name)
        title_label.set_halign(Gtk.Align.START)
        title_label.props.margin = 4
        title_label.props.hexpand = True
        title_label.props.hexpand_set = True
        title_label.set_margin_right(7)
        title_label.props.width_request = 100
        title_label.props.xalign = 0.0

        dur_label.set_text(seconds_to_str(self.track.length))
        dur_label.set_halign(Gtk.Align.END)
        dur_label.props.margin = 4

        self.box.add(self.play_img)
        self.box.add(no_label)
        self.box.pack_start(title_label, True, True, 0)
        self.box.pack_end(dur_label, False, False, 0)

        self.add(self.box)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self):
        Gtk.EventBox.__init__(self)
        vbox = Gtk.VBox()
        vbox.set_margin_bottom(StockEms.SMALL)
        vbox.set_margin_left(StockEms.LARGE)
        vbox.set_margin_right(StockEms.LARGE)
        self.add(vbox)

        # defined to make overriding softwarecenter.paths.datadir possible
        self.NORTHERN_DROPSHADOW = os.path.join(
            softwarecenter.paths.datadir,
            "ui/gtk3/art/exhibit-dropshadow-n.png")
        self.SOUTHERN_DROPSHADOW = os.path.join(
            softwarecenter.paths.datadir,
            "ui/gtk3/art/exhibit-dropshadow-s.png")
        self.FALLBACK = os.path.join(
            softwarecenter.paths.datadir,
            "default_banner/fallback.png")

        hbox = Gtk.HBox(spacing=StockEms.SMALL)
        vbox.pack_end(hbox, False, False, 0)

        next = ExhibitArrowButton(Gtk.ArrowType.RIGHT)
        previous = ExhibitArrowButton(Gtk.ArrowType.LEFT)
        self.nextprev_hbox = Gtk.HBox()
        self.nextprev_hbox.pack_start(previous, False, False, 0)
        self.nextprev_hbox.pack_start(next, False, False, 0)
        hbox.pack_end(self.nextprev_hbox, False, False, 0)

        self.index_hbox = Gtk.HBox(spacing=StockEms.SMALL)
        alignment = Gtk.Alignment.new(1.0, 1.0, 0.0, 1.0)
        alignment.add(self.index_hbox)
        hbox.pack_end(alignment, False, False, 0)

        self.cursor = 0
        self._timeout = 0
        self.pressed = False

        self.alpha = 1.0
        self.image = None
        self.old_image = None
        self.renderer = _HtmlRenderer()
        self.renderer.connect("render-finished", self.on_banner_rendered)

        self.set_visible_window(False)
        self.set_size_request(-1, self.MAX_HEIGHT)
        self.exhibits = []

        next.connect('clicked', self.on_next_clicked)
        previous.connect('clicked', self.on_previous_clicked)

        self._dotsigs = []

        self._cache_art_assets()
        self._init_event_handling()
        # fill this in later
        self._toplevel_window = None
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self):
        Gtk.EventBox.__init__(self)
        self.set_visible_window(False)
        self.set_size_request(200, -1)

        self.set_can_focus(True)
        self.set_events(Gdk.EventMask.KEY_PRESS_MASK |
                        Gdk.EventMask.ENTER_NOTIFY_MASK |
                        Gdk.EventMask.LEAVE_NOTIFY_MASK |
                        Gdk.EventMask.BUTTON_RELEASE_MASK |
                        Gdk.EventMask.POINTER_MOTION_MASK)

        self._is_new = False

        self.order = []
        self.cursor = cur = PrimaryCursor(self)
        self.selection = sel = SelectionCursor(self.cursor)
        self.clipboard = None

        #~ event_helper = EventHelper()
        self._update_cached_layouts()
        self._test_layout = self.create_pango_layout('')

        #self._xterm = Gdk.Cursor.new(Gdk.XTERM)

        # popup menu and menuitem's
        self.copy_menuitem = Gtk.ImageMenuItem.new_from_stock(
                                            Gtk.STOCK_COPY, None)
        self.select_all_menuitem = Gtk.ImageMenuItem.new_from_stock(
                                            Gtk.STOCK_SELECT_ALL, None)
        self.menu = Gtk.Menu()
        self.menu.attach_to_widget(self, None)
        self.menu.append(self.copy_menuitem)
        self.menu.append(self.select_all_menuitem)
        self.menu.show_all()
        self.copy_menuitem.connect('select', self._menu_do_copy, sel)
        self.select_all_menuitem.connect('select', self._menu_do_select_all,
            cur, sel)

        #~ Gtk.drag_source_set(self, Gdk.ModifierType.BUTTON1_MASK,
                            #~ None, Gdk.DragAction.COPY)
        #~ Gtk.drag_source_add_text_targets(self)
        #~ self.connect('drag-begin', self._on_drag_begin)
        #~ self.connect('drag-data-get', self._on_drag_data_get, sel)

        event_helper = EventHelper()

        self.connect('button-press-event', self._on_press, event_helper, cur,
            sel)
        self.connect('button-release-event', self._on_release, event_helper,
            cur, sel)
        self.connect('motion-notify-event', self._on_motion, event_helper,
            cur, sel)
        self.connect('key-press-event', self._on_key_press, cur, sel)
        self.connect('key-release-event', self._on_key_release, cur, sel)
        self.connect('focus-in-event', self._on_focus_in)
        self.connect('focus-out-event', self._on_focus_out)

        self.connect("size-allocate", self.on_size_allocate)
        self.connect('style-updated', self._on_style_updated)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self):
        Gtk.EventBox.__init__(self)
        vbox = Gtk.VBox()
        vbox.set_margin_bottom(StockEms.SMALL)
        vbox.set_margin_left(StockEms.LARGE)
        vbox.set_margin_right(StockEms.LARGE)
        self.add(vbox)

        # defined to make overriding softwarecenter.paths.datadir possible
        self.NORTHERN_DROPSHADOW = os.path.join(
            softwarecenter.paths.datadir,
            "ui/gtk3/art/exhibit-dropshadow-n.png")
        self.SOUTHERN_DROPSHADOW = os.path.join(
            softwarecenter.paths.datadir,
            "ui/gtk3/art/exhibit-dropshadow-s.png")
        self.FALLBACK = os.path.join(
            softwarecenter.paths.datadir,
            "default_banner/fallback.png")

        hbox = Gtk.HBox(spacing=StockEms.SMALL)
        vbox.pack_end(hbox, False, False, 0)

        next = ExhibitArrowButton(Gtk.ArrowType.RIGHT)
        previous = ExhibitArrowButton(Gtk.ArrowType.LEFT)
        self.nextprev_hbox = Gtk.HBox()
        self.nextprev_hbox.pack_start(previous, False, False, 0)
        self.nextprev_hbox.pack_start(next, False, False, 0)
        hbox.pack_end(self.nextprev_hbox, False, False, 0)

        self.index_hbox = Gtk.HBox(spacing=StockEms.SMALL)
        alignment = Gtk.Alignment.new(1.0, 1.0, 0.0, 1.0)
        alignment.add(self.index_hbox)
        hbox.pack_end(alignment, False, False, 0)

        self.cursor = 0
        self._timeout = 0
        self.pressed = False

        self.alpha = 1.0
        self.image = None
        self.old_image = None
        self.renderer = _HtmlRenderer()
        self.renderer.connect("render-finished", self.on_banner_rendered)

        self.set_visible_window(False)
        self.set_size_request(-1, self.MAX_HEIGHT)
        self.exhibits = []

        next.connect('clicked', self.on_next_clicked)
        previous.connect('clicked', self.on_previous_clicked)

        self._dotsigs = []

        self._cache_art_assets()
        self._init_event_handling()
        # fill this in later
        self._toplevel_window = None