Python gi.repository.Gdk.Event() Examples
The following are 30
code examples of gi.repository.Gdk.Event().
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.Gdk
, or try the search function
.
Example #1
Source File: ui.py From pympress with GNU General Public License v2.0 | 6 votes |
def on_scroll(self, widget, event): """ Manage scroll events. Args: widget (:class:`~Gtk.Widget`): the widget in which the event occurred (ignored) event (:class:`~Gdk.Event`): the event that occurred Returns: `bool`: whether the event was consumed """ if event.type != Gdk.EventType.SCROLL: return False # send to spinner if it is active elif self.page_number.on_scroll(widget, event): return True elif self.annotations.on_scroll(widget, event): return True else: return False
Example #2
Source File: scribble.py From pympress with GNU General Public License v2.0 | 6 votes |
def track_scribble(self, widget, event): """ Draw the scribble following the mouse's moves. Args: widget (:class:`~Gtk.Widget`): the widget which has received the event. event (:class:`~Gdk.Event`): the GTK event. Returns: `bool`: whether the event was consumed """ if self.scribble_drawing: self.scribble_list[-1][2].append(self.get_slide_point(widget, event)) self.redraw_current_slide() return True else: return False
Example #3
Source File: scribble.py From pympress with GNU General Public License v2.0 | 6 votes |
def toggle_scribble(self, widget, event): """ Start/stop drawing scribbles. Args: widget (:class:`~Gtk.Widget`): the widget which has received the event. event (:class:`~Gdk.Event`): the GTK event. Returns: `bool`: whether the event was consumed """ if not self.scribbling_mode: return False if event.get_event_type() == Gdk.EventType.BUTTON_PRESS: self.scribble_list.append((self.scribble_color, self.scribble_width, [])) self.scribble_drawing = True return self.track_scribble(widget, event) elif event.get_event_type() == Gdk.EventType.BUTTON_RELEASE: self.scribble_drawing = False return True return False
Example #4
Source File: eventhandler_test.py From vimiv with MIT License | 6 votes |
def test_button_click(self): """Click mouse button.""" self.vimiv["library"].file_select(None, Gtk.TreePath(1), None, True) image_before = self.vimiv.get_path() event = Gdk.Event().new(Gdk.EventType.BUTTON_PRESS) event.button = 1 self.vimiv["window"].emit("button_press_event", event) image_after = self.vimiv.get_path() self.assertNotEqual(image_before, image_after) # Double click should not work event = Gdk.Event().new(Gdk.EventType.DOUBLE_BUTTON_PRESS) event.button = 1 self.vimiv["window"].emit("button_press_event", event) self.assertEqual(image_after, self.vimiv.get_path()) # Focus library via mouse click event = Gdk.Event().new(Gdk.EventType.BUTTON_PRESS) event.button = 2 self.vimiv["window"].emit("button_press_event", event) self.assertTrue(self.vimiv["library"].is_focus())
Example #5
Source File: Main.py From pychess with GNU General Public License v3.0 | 6 votes |
def on_quit1_activate(self, widget, *args): perspective = perspective_manager.get_perspective("games") if isinstance(widget, Gdk.Event): if len(perspective.gamewidgets) == 1 and conf.get("hideTabs"): gmwidg = perspective.cur_gmwidg() perspective.closeGame(gmwidg, gmwidg.gamemodel) return True elif len(perspective.gamewidgets) >= 1 and conf.get("closeAll"): perspective.closeAllGames(perspective.gamewidgets) return True if perspective.closeAllGames(perspective.gamewidgets) in ( Gtk.ResponseType.OK, Gtk.ResponseType.YES): ICLogon.stop() self.app.loop.stop() self.app.quit() else: return True # View Menu
Example #6
Source File: ui.py From pympress with GNU General Public License v2.0 | 6 votes |
def on_configure_da(self, widget, event): """ Manage "configure" events for all drawing areas, e.g. resizes. We tell the local :class:`~pympress.surfacecache.SurfaceCache` cache about it, so that it can invalidate its internal cache for the specified widget and pre-render next pages at a correct size. Warning: Some not-explicitly sent signals contain wrong values! Just don't resize in that case, since these always seem to happen after a correct signal that was sent explicitly. Args: widget (:class:`~Gtk.Widget`): the widget which has been resized event (:class:`~Gdk.Event`): the GTK event, which contains the new dimensions of the widget """ # Don't trust those if not event.send_event: return self.cache.resize_widget(widget.get_name(), event.width, event.height) if widget is self.c_da: self.medias.resize('content') elif widget is self.p_da_cur: self.medias.resize('presenter')
Example #7
Source File: ui.py From pympress with GNU General Public License v2.0 | 6 votes |
def on_configure_win(self, widget, event): """ Manage "configure" events for both window widgets. Args: widget (:class:`~Gtk.Widget`): the window which has been moved or resized event (:class:`~Gdk.Event`): the GTK event, which contains the new dimensions of the widget """ if widget is self.p_win: p_monitor = self.p_win.get_screen().get_monitor_at_window(self.p_central.get_parent_window()) self.config.set('presenter', 'monitor', str(p_monitor)) cw = self.p_central.get_allocated_width() ch = self.p_central.get_allocated_height() self.scribbler.off_render.set_size_request(cw, ch) elif widget is self.c_win: c_monitor = self.c_win.get_screen().get_monitor_at_window(self.c_frame.get_parent_window()) self.config.set('content', 'monitor', str(c_monitor))
Example #8
Source File: ui.py From pympress with GNU General Public License v2.0 | 6 votes |
def on_pane_event(self, widget, evt): """ Signal handler for gtk.paned events. This function allows one to delay drawing events when resizing, and to speed up redrawing when moving the middle pane is done (which happens at the end of a mouse resize) Args: widget (:class:`~Gtk.Widget`): the widget in which the event occurred (ignored) evt (:class:`~Gdk.Event`): the event that occurred """ if type(evt) == Gdk.EventButton and evt.type == Gdk.EventType.BUTTON_RELEASE: self.redraw_panes() elif type(evt) == GObject.GParamSpec and evt.name == "position": self.resize_panes = True if self.redraw_timeout: GLib.Source.remove(self.redraw_timeout) self.redraw_timeout = GLib.timeout_add(200, self.redraw_panes) ############################################################################ ############################ Program lifetime ############################ ############################################################################
Example #9
Source File: extras.py From pympress with GNU General Public License v2.0 | 6 votes |
def on_scroll(self, widget, event): """ Try scrolling the annotations window. Args: widget (:class:`~Gtk.Widget`): the widget which has received the event. event (:class:`~Gdk.Event`): the GTK event. Returns: `bool`: whether the event was consumed """ adj = self.scrolled_window.get_vadjustment() if event.direction == Gdk.ScrollDirection.UP: adj.set_value(adj.get_value() - adj.get_step_increment()) elif event.direction == Gdk.ScrollDirection.DOWN: adj.set_value(adj.get_value() + adj.get_step_increment()) else: return False return True
Example #10
Source File: extras.py From pympress with GNU General Public License v2.0 | 6 votes |
def track_zoom_target(self, widget, event): """ Draw the zoom's target rectangle. Args: widget (:class:`~Gtk.Widget`): the widget which has received the event. event (:class:`~Gdk.Event`): the GTK event. Returns: `bool`: whether the event was consumed """ if self.zoom_selecting and self.zoom_points: self.zoom_points[1] = self.get_slide_point(widget, event) self.redraw_current_slide() return True return False
Example #11
Source File: ui.py From pympress with GNU General Public License v2.0 | 6 votes |
def track_motions(self, widget, event): """ Track mouse motion events. Handles mouse motions on the "about" menu. Args: widget (:class:`~Gtk.Widget`): the widget that received the mouse motion event (:class:`~Gdk.Event`): the GTK event containing the mouse position Returns: `bool`: whether the event was consumed """ if self.zoom.track_zoom_target(widget, event): return True elif self.scribbler.track_scribble(widget, event): return True elif self.laser.track_pointer(widget, event): return True else: return self.hover_link(widget, event)
Example #12
Source File: timeline.py From addons-source with GNU General Public License v2.0 | 6 votes |
def on_pointer_motion(self, _dummy, event): """ Called when the pointer is moved. @param _dummy: This widget. Unused. @type _dummy: Gtk.Widget @param event: An event. @type event: Gdk.Event """ allocation = self.get_allocation() x = allocation.width / 2 y = allocation.height / 2 if (event.x > (x - NODE_SIZE) and event.x < (x + NODE_SIZE) and event.y > (y - NODE_SIZE) and event.y < (y + NODE_SIZE)): active = True else: active = False if self.__active != active: self.__active = active self.queue_draw() return False
Example #13
Source File: taglist.py From addons-source with GNU General Public License v2.0 | 6 votes |
def on_pointer_motion(self, _dummy, event): """ Called when the pointer is moved. @param _dummy: This widget. Unused. @type _dummy: Gtk.Widget @param event: An event. @type event: Gdk.Event """ if self.__rects is None: return False active = -1 for i, rect in enumerate(self.__rects): if (event.x > rect[0] and event.x < rect[0] + rect[2] and event.y > rect[1] and event.y < rect[1] + rect[3]): active = i if self.__active != active: self.__active = active if active == -1: self.set_tooltip_text('') else: self.set_tooltip_text(self.tag_list[active][0]) return False
Example #14
Source File: dna.py From addons-source with GNU General Public License v2.0 | 6 votes |
def on_pointer_motion(self, _dummy, event): """ Called when the pointer is moved. @param _dummy: This widget. Unused. @type _dummy: Gtk.Widget @param event: An event. @type event: Gdk.Event """ if self.__rects is None: return False active = -1 for i, rect in enumerate(self.__rects): if (event.x > rect[0] and event.x < rect[0] + rect[2] and event.y > rect[1] and event.y < rect[1] + rect[3]): active = i if self.__active != active: self.__active = active if active == -1: self.set_tooltip_text('') else: self.set_tooltip_text('%s cMs' % self.segments[active][4]) return False
Example #15
Source File: ui.py From pympress with GNU General Public License v2.0 | 5 votes |
def hover_link(self, widget, event): """ Manage events related to hyperlinks, setting the cursor to a pointer if the hovered region is clickable. Args: widget (:class:`~Gtk.Widget`): the widget in which the event occurred event (:class:`~Gdk.Event`): the event that occurred Returns: `bool`: whether the event was consumed """ if event.type != Gdk.EventType.MOTION_NOTIFY: return False # Where did the event occur? if widget is self.p_da_next: page = self.doc.next_page() if page is None: return else: page = self.doc.current_page() x, y = self.zoom.get_slide_point(widget, event) page_mode = self.notes_mode if widget is self.p_da_notes else self.notes_mode.complement() if page.get_link_at(x, y, page_mode): extras.Cursor.set_cursor(widget, 'pointer') return False else: extras.Cursor.set_cursor(widget, 'parent') return True
Example #16
Source File: ui.py From pympress with GNU General Public License v2.0 | 5 votes |
def on_window_state_event(self, widget, event): """ Track whether the preview window is maximized. Args: widget (:class:`~Gtk.Widget`): the widget in which the event occurred event (:class:`~Gtk.Event`): the event that occurred Returns: `bool`: whether the event was consumed. """ if widget.get_name() == self.c_win.get_name(): fullscreen = (Gdk.WindowState.FULLSCREEN & event.new_window_state) != 0 util.set_screensaver(fullscreen, self.c_win.get_window()) return False
Example #17
Source File: gtk.py From pywebview with BSD 3-Clause "New" or "Revised" License | 5 votes |
def destroy(self): self.window.emit('delete-event', Gdk.Event())
Example #18
Source File: scribble.py From pympress with GNU General Public License v2.0 | 5 votes |
def on_configure_da(self, widget, event): """ Transfer configure resize to the cache. Args: widget (:class:`~Gtk.Widget`): the widget which has been resized event (:class:`~Gdk.Event`): the GTK event, which contains the new dimensions of the widget """ # Don't trust those if not event.send_event: return self.resize_cache(widget.get_name(), event.width, event.height)
Example #19
Source File: scribble.py From pympress with GNU General Public License v2.0 | 5 votes |
def switch_scribbling(self, widget, event = None): """ Starts the mode where one can read on top of the screen. Args: widget (:class:`~Gtk.Widget`): the widget which has received the event. event (:class:`~Gdk.Event` or None): the GTK event., None when called through a menu item Returns: `bool`: whether the event was consumed """ if issubclass(type(widget), Gtk.CheckMenuItem) and widget.get_active() == self.scribbling_mode: # Checking the checkbox conforming to current situation: do nothing return False elif issubclass(type(widget), Gtk.Actionable): # A button or menu item, etc. directly connected to this action pass elif event.type != Gdk.EventType.KEY_PRESS: return False # Perform the state toggle if self.scribbling_mode: return self.disable_scribbling() else: return self.enable_scribbling()
Example #20
Source File: editable_label.py From pympress with GNU General Public License v2.0 | 5 votes |
def on_keypress(self, widget, event, name = None, command = None): """ Manage key presses for the editable label. If we are editing the label, intercept some key presses (to validate or cancel editing or other specific behaviour), otherwise pass the key presses on to the button for normal behaviour. Args: widget (:class:`~Gtk.Widget`): the widget which has received the event. event (:class:`~Gdk.Event`): the GTK event. name (`str`): the name of the key stroke command (`str`): the name of the command in case this function is called by on_navigation Returns: `bool`: whether the event was consumed """ if not self.editing or event.type != Gdk.EventType.KEY_PRESS: return False if command == 'validate': self.validate() self.restore_label() elif command == 'cancel': self.cancel() self.restore_label() else: return self.more_actions(event, name) return True
Example #21
Source File: editable_label.py From pympress with GNU General Public License v2.0 | 5 votes |
def on_scroll(self, widget, event): """ Scroll event. Pass it on to the spin button if we're currently editing the page number. Args: widget (:class:`~Gtk.Widget`): the widget which has received the event. event (:class:`~Gdk.Event`): the GTK event. Returns: `bool`: whether the event was consumed """ if not self.editing: return False else: # flip scroll direction to get scroll down advancing slides if self.invert_scroll and event.direction == Gdk.ScrollDirection.DOWN: event.direction = Gdk.ScrollDirection.UP elif self.invert_scroll and event.direction == Gdk.ScrollDirection.UP: event.direction = Gdk.ScrollDirection.DOWN # Manually get destination slide if we're editing labels if self.edit_label.is_focus(): cur_page = int(self.spin_cur.get_value()) - 1 if event.direction == Gdk.ScrollDirection.DOWN: self.spin_cur.set_value(1 + self.label_before(cur_page)) elif event.direction == Gdk.ScrollDirection.UP: self.spin_cur.set_value(1 + self.label_after(cur_page)) # Otherwise let the spinner do its job else: return Gtk.SpinButton.do_scroll_event(self.spin_cur, event)
Example #22
Source File: pointer.py From pympress with GNU General Public License v2.0 | 5 votes |
def track_enter_leave(self, widget, event): """ Switches laser off/on in continuous mode on leave/enter slides. In continuous mode, the laser pointer is switched off when the mouse leaves the slide (otherwise the laser pointer "sticks" to the edge of the slide). It is switched on again when the mouse reenters the slide. Args: widget (:class:`~Gtk.Widget`): the widget which has received the event. event (:class:`~Gdk.Event`): the GTK event. Returns: `bool`: whether the event was consumed """ # Only handle enter/leave events on one of the current slides if self.pointer_mode != PointerMode.CONTINUOUS or widget not in [self.c_da, self.p_da_cur]: return False if event.type == Gdk.EventType.ENTER_NOTIFY: self.show_pointer = True extras.Cursor.set_cursor(widget, 'invisible') elif event.type == Gdk.EventType.LEAVE_NOTIFY: self.show_pointer = False extras.Cursor.set_cursor(widget, 'parent') self.redraw_current_slide() return True
Example #23
Source File: pointer.py From pympress with GNU General Public License v2.0 | 5 votes |
def toggle_pointer(self, widget, event): """ Track events defining when the laser is pointing. Args: widget (:class:`~Gtk.Widget`): the widget which has received the event. event (:class:`~Gdk.Event`): the GTK event. Returns: `bool`: whether the event was consumed """ if self.pointer_mode in {PointerMode.DISABLED, PointerMode.CONTINUOUS}: return False ctrl_pressed = event.get_state() & Gdk.ModifierType.CONTROL_MASK if ctrl_pressed and event.type == Gdk.EventType.BUTTON_PRESS: self.show_pointer = True extras.Cursor.set_cursor(widget, 'invisible') # Immediately place & draw the pointer return self.track_pointer(widget, event) elif self.show_pointer and event.type == Gdk.EventType.BUTTON_RELEASE: self.show_pointer = False extras.Cursor.set_cursor(widget, 'parent') self.redraw_current_slide() return True else: return False
Example #24
Source File: keyboard.py From hazzy with GNU General Public License v2.0 | 5 votes |
def emulate_key(self, widget, event=None, key=None): try: event = Gdk.Event.new(Gdk.EventType.KEY_PRESS) if key: event.keyval = int(key) else: event.keyval = ord(widget.get_label()) event.hardware_keycode = _keymap.get_entries_for_keyval(event.keyval)[1][0].keycode # add control mask if ctrl is active if self.builder.get_object('ctrl').get_active(): event.state = Gdk.ModifierType.CONTROL_MASK self.builder.get_object('ctrl').set_active(False) #self.entry.get_parent_window() # FIXME This is a kludge to get the window for both Entry and TextView try: event.window = self.entry.get_window() except TypeError: event.window = self.entry.get_window(Gtk.TextWindowType.TEXT) self.entry.event(event) # Do the initial event # Call key repeat function every 50ms self.wait_counter = 0 # Set counter for repeat timeout GObject.timeout_add(50, self.key_repeat, widget, event) except Exception as e: log.exception(e) # Unshift if left shift is active, right shift is "sticky" if self.builder.get_object('left_shift').get_active(): self.shift(False)
Example #25
Source File: keyboard.py From hazzy with GNU General Public License v2.0 | 5 votes |
def escape(self): try: event = Gdk.Event(Gdk.KEY_PRESS) event.keyval = Gdk.KEY_Escape event.window = self.entry.window self.entry.event(event) self.entry.emit("key-press-event", event) except: pass self.entry.disconnect(self.focus_out_sig) self.entry.disconnect(self.key_press_sig) self.keyboard.hide()
Example #26
Source File: state_icons.py From RAFCON with Eclipse Public License 1.0 | 5 votes |
def on_mouse_motion(self, widget, event): """selection on mouse over :param widget: :param Gdk.Event event: mouse motion event """ path = self.view.get_path_at_pos(int(event.x), int(event.y)) if path is not None: self.view.select_path(path) else: self.view.unselect_all()
Example #27
Source File: dna.py From addons-source with GNU General Public License v2.0 | 5 votes |
def on_button_press(self, _dummy, event): """ Called when a mouse button is clicked. @param _dummy: This widget. Unused. @type _dummy: Gtk.Widget @param event: An event. @type event: Gdk.Event """ if (event.button == 1 and event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS and self.__active != -1): self.emit('clicked', self.__active)
Example #28
Source File: taglist.py From addons-source with GNU General Public License v2.0 | 5 votes |
def on_button_press(self, _dummy, event): """ Called when a mouse button is clicked. @param _dummy: This widget. Unused. @type _dummy: Gtk.Widget @param event: An event. @type event: Gdk.Event """ if (event.button == 1 and event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS and self.__active != -1): self.emit('clicked', self.__active)
Example #29
Source File: main_window.py From RAFCON with Eclipse Public License 1.0 | 5 votes |
def _on_key_press(self, widget, event): """Updates the currently pressed keys :param Gtk.Widget widget: The main window :param Gdk.Event event: The key press event """ self.currently_pressed_keys.add(event.keyval)
Example #30
Source File: main_window.py From RAFCON with Eclipse Public License 1.0 | 5 votes |
def _on_key_release(self, widget, event): """Updates the currently pressed keys :param Gtk.Widget widget: The main window :param Gdk.Event event: The key release event """ self.currently_pressed_keys.discard(event.keyval)