本文整理汇总了Python中gi.repository.Gtk.EventBox方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.EventBox方法的具体用法?Python Gtk.EventBox怎么用?Python Gtk.EventBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.EventBox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __colour_dialog_background
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import EventBox [as 别名]
def __colour_dialog_background(self):
content_area = self.dialog.get_content_area()
self.content_background = Gtk.EventBox()
self.add_style(self.content_background, 'white')
self.content_background.set_size_request(140, 140)
content_area.reparent(self.content_background)
action_area = self.dialog.get_action_area()
self.action_background = Gtk.EventBox()
self.add_style(self.action_background, 'white')
action_area.reparent(self.action_background)
action_area.set_layout(Gtk.ButtonBoxStyle.CENTER)
# Set area around the buttons grey by default
self.set_action_background('grey')
container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
container.add(self.content_background)
container.add(self.action_background)
self.dialog.add(container)
return content_area, action_area
示例2: _add_border_to_widget
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import EventBox [as 别名]
def _add_border_to_widget(self, widget):
'''Add a grey border to the widget that is entered as an argument.
This is done by creating a grey event box and packing a white box with
a margin in it.
'''
white_foreground = Gtk.EventBox()
white_foreground.get_style_context().add_class('white')
white_foreground.set_margin_left(3)
white_foreground.set_margin_bottom(3)
white_foreground.set_margin_top(3)
white_foreground.set_margin_right(3)
# Pack the scrolled window into an event box to give the illusion of a
# border
grey_border = Gtk.EventBox()
grey_border.get_style_context().add_class('grey')
grey_border.add(white_foreground)
white_foreground.add(widget)
return grey_border
示例3: create_tab_header_label
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import EventBox [as 别名]
def create_tab_header_label(tab_name, icons):
"""Create the tab header labels for notebook tabs. If USE_ICONS_AS_TAB_LABELS is set to True in the gui_config,
icons are used as headers. Otherwise, the titles of the tabs are rotated by 90 degrees.
:param tab_name: The label text of the tab, written in small letters and separated by underscores, e.g. states_tree
:param icons: A dict mapping each tab_name to its corresponding icon
:return: The GTK Eventbox holding the tab label
"""
tooltip_event_box = Gtk.EventBox()
tooltip_event_box.set_tooltip_text(tab_name)
tab_label = Gtk.Label()
if global_gui_config.get_config_value('USE_ICONS_AS_TAB_LABELS', True):
set_label_markup(tab_label, icons[tab_name], is_icon=True, size=constants.FONT_SIZE_BIG)
else:
tab_label.set_text(get_widget_title(tab_name))
tab_label.set_angle(90)
tab_label.show()
tooltip_event_box.add(tab_label)
tooltip_event_box.set_visible_window(False)
tooltip_event_box.show()
return tooltip_event_box
示例4: create_tab_header
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import EventBox [as 别名]
def create_tab_header(title, close_callback, right_click_callback, *additional_parameters):
def handle_click(widget, event, *additional_parameters):
"""Calls `callback` in case the mouse button was pressed"""
if event.get_button()[1] == 2 and close_callback:
close_callback(event, *additional_parameters)
if event.get_button()[1] == 3 and right_click_callback:
right_click_callback(event, *additional_parameters)
label = Gtk.Label(label=title)
close_button = create_tab_close_button(close_callback, *additional_parameters)
hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
hbox.pack_start(label, expand=True, fill=True, padding=constants.GRID_SIZE)
hbox.pack_start(close_button, expand=False, fill=False, padding=0)
event_box = Gtk.EventBox()
event_box.set_name("tab_label") # required for gtkrc
event_box.connect('button-press-event', handle_click, *additional_parameters)
event_box.tab_label = label
event_box.add(hbox)
event_box.show_all()
return event_box, label
示例5: init_grid
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import EventBox [as 别名]
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
示例6: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import EventBox [as 别名]
def __init__(self, inactive_icon, active_icon, on_press_callback = None):
Gtk.EventBox.__init__(self)
self.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)
if on_press_callback is None:
self.connect("button-press-event", self.on_icon_pressed)
else:
self.connect("button-press-event", on_press_callback)
self.inactive_icon = inactive_icon
self.active_icon = active_icon
self._position = 0
self._state = SideBarButtonState.OFF
self.iconstack = Gtk.Stack(margin_left=12, margin_right=12, margin_top=6, margin_bottom=6)
self.iconstack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
self.iconstack.set_transition_duration(300)
icon = self.set_image_from_file(self.inactive_icon)
self.iconstack.add_named(icon, 'inactive')
icon = self.set_image_from_file(self.active_icon)
self.iconstack.add_named(icon, 'active')
self.add(self.iconstack)
示例7: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import EventBox [as 别名]
def __init__(self, gday, hday, gcolor, hcolor):
Gtk.EventBox.__init__(self)
self.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)
self.connect("button-press-event", self.on_day_pressed)
self._state = CalendarState.Gregorian
# Set up the stack for the labels
self.labelstack = Gtk.Stack()
self.labelstack.set_transition_type(Gtk.StackTransitionType.SLIDE_UP_DOWN)
self.labelstack.set_transition_duration(300)
# Make the inactive label
self.labelstack.add_named(CalEntryLabel(gday, gcolor), 'Gregorian')
# Make the active label
self.labelstack.add_named(CalEntryLabel(hday, hcolor), 'Hijri')
self.add(self.labelstack)
self.show_all()
示例8: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import EventBox [as 别名]
def __init__(self, main_win, apps_obj):
Gtk.EventBox.__init__(self, hexpand=True, vexpand=True)
style = self.get_style_context()
style.add_class('app-grid')
self._win = main_win
self._apps = apps_obj
self._num_apps = 0
self._sw = ScrolledWindow(hexpand=True, vexpand=True,
wide_scrollbar=True)
self._sw.props.margin_top = 7
self._sw.props.margin_bottom = 0
self._sw.props.margin_left = 0
self._sw.props.margin_right = 0
self._sw.props.border_width = 0
self._sw.set_shadow_type(Gtk.ShadowType.NONE)
self._box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self._sw.add_with_viewport(self._box)
self.add(self._sw)
示例9: build_tab_widget
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import EventBox [as 别名]
def build_tab_widget(self):
"""Build the GTK widget displayed as the tab title."""
# The tab can be closed with a button.
btn = Gtk.Button.new_from_icon_name('window-close-symbolic', Gtk.IconSize.BUTTON)
btn.set_relief(Gtk.ReliefStyle.NONE)
btn.connect('clicked', self.try_close_tab)
# The title is a label. Middle-clicking on it closes the tab too.
self.tab_label = Gtk.Label(label=self.get_filename_for_display())
self.tab_label.set_ellipsize(Pango.EllipsizeMode.END)
event_box = Gtk.EventBox()
event_box.add(self.tab_label)
event_box.connect('button-press-event', self.on_tab_title_clicked)
# These widgets are packed in a regular box, which is returned.
tab_title = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, expand=True)
if self.window.deco_layout == 'he':
tab_title.pack_start(btn, expand=False, fill=False, padding=0)
tab_title.pack_end(event_box, expand=True, fill=True, padding=0)
else:
tab_title.pack_start(event_box, expand=True, fill=True, padding=0)
tab_title.pack_end(btn, expand=False, fill=False, padding=0)
tab_title.show_all()
return tab_title
示例10: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import EventBox [as 别名]
def __init__(self, label, sub_label=None):
Gtk.EventBox.__init__(self)
# cursor = Gdk.Cursor(Gdk.CursorType.WATCH)
# self.get_window().set_cursor(cursor)
self._build_widgets(label, sub_label)
示例11: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import EventBox [as 别名]
def __init__(self, rgba, width, height, max_colour_val):
Gtk.EventBox.__init__(self)
self.max_colour_val = max_colour_val
self.set_property("margin", 1)
self.add_events(Gdk.EventMask.BUTTON_RELEASE_MASK)
# Draw the contents.
self.colour = (rgba.red, rgba.green, rgba.blue)
(red, green, blue) = self.colour
surface = cairo.ImageSurface(cairo.FORMAT_RGB24, width, height)
cr = cairo.Context(surface)
cr.rectangle(0, 0, width, height)
cr.set_source_rgb(red, green, blue)
cr.fill()
cr.rectangle(0, 0, width, height)
cr.set_line_width(2)
cr.set_source_rgb(0x0, 0x0, 0x0)
cr.stroke()
pb = Gdk.pixbuf_get_from_surface(surface, 0, 0, width, height)
self.active_image = Gtk.Image()
self.active_image.set_from_pixbuf(pb)
self.add(self.active_image)
# Make the inactive version
y = 0.2126*red + 0.7152*green + 0.0722*blue
surface = cairo.ImageSurface(cairo.FORMAT_RGB24, width, height)
cr = cairo.Context(surface)
cr.rectangle(0, 0, width, height)
cr.set_source_rgb(y, y, y)
cr.fill()
pb = Gdk.pixbuf_get_from_surface(surface, 0, 0, width, height)
self.inactive_image = Gtk.Image()
self.inactive_image.set_from_pixbuf(pb)
示例12: set_active
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import EventBox [as 别名]
def set_active(self, active):
""" Override Gtk.EventBox.set_active()."""
if active:
self.remove(self.inactive_image)
self.add(self.active_image)
else:
self.remove(self.active_image)
self.add(self.inactive_image)
self.get_child().show()
示例13: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import EventBox [as 别名]
def __init__(self):
Gtk.Overlay.__init__(self)
self._loading = False
self._blur = Gtk.EventBox()
self._blur.get_style_context().add_class('blur')
self._spinner = Gtk.Spinner()
self._spinner.props.active = True
apply_styling_to_widget(self._spinner, KanoButton.SPINNER_CSS)
示例14: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import EventBox [as 别名]
def __init__(self, title="Application", width=None, height=None):
Gtk.Window.__init__(self, title=title)
self.set_decorated(False)
self.set_resizable(False)
screen = Gdk.Screen.get_default()
self._win_width = width
if width <= 1:
self._win_width = int(screen.get_width() * width)
self._win_height = height
if height <= 1:
self._win_height = int(screen.get_height() * height)
self.set_size_request(self._win_width, self._win_height)
self.set_position(Gtk.WindowPosition.CENTER)
self.connect('delete-event', Gtk.main_quit)
apply_common_to_screen()
self._overlay = Gtk.Overlay()
self.add(self._overlay)
self._blur = Gtk.EventBox()
self._blur.get_style_context().add_class('blur')
self._blurred = False
# TODO: Maybe handle the taskbar here to avoid even more code duplication?
示例15: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import EventBox [as 别名]
def __init__(self, win):
Gtk.Notebook.__init__(self)
background = Gtk.EventBox()
background.add(self)
self.win = win
self.win.set_main_widget(background)
self.win.top_bar.enable_prev()
self.win.change_prev_callback(self.win.go_to_home)
# Modify set_wallpaper so it doesn't add itself to the window
wallpaper_widget = SetWallpaper(self.win)
screensaver_widget = SetScreensaver(self.win)
reset_widget = SetResetDesktop(self.win)
wallpaper_label = Gtk.Label(_("BACKGROUND"))
wallpaper_label_ebox = Gtk.EventBox()
wallpaper_label_ebox.add(wallpaper_label)
wallpaper_label_ebox.connect('realize', self._set_cursor_to_hand_cb)
wallpaper_label_ebox.show_all()
screensaver_label = Gtk.Label(_("SCREENSAVER"))
screensaver_label_ebox = Gtk.EventBox()
screensaver_label_ebox.add(screensaver_label)
screensaver_label_ebox.connect('realize', self._set_cursor_to_hand_cb)
screensaver_label_ebox.show_all()
general_label = Gtk.Label(_("GENERAL"))
general_label_ebox = Gtk.EventBox()
general_label_ebox.add(general_label)
general_label_ebox.connect('realize', self._set_cursor_to_hand_cb)
general_label_ebox.show_all()
# Add the screensaver and wallpaper tabs
self.append_page(wallpaper_widget, wallpaper_label_ebox)
self.append_page(screensaver_widget, screensaver_label_ebox)
self.append_page(reset_widget, general_label_ebox)
self.win.show_all()