本文整理汇总了Python中gi.repository.Gtk.DrawingArea方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.DrawingArea方法的具体用法?Python Gtk.DrawingArea怎么用?Python Gtk.DrawingArea使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.DrawingArea方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import DrawingArea [as 别名]
def __init__(self, *args, **kwargs):
Gtk.Box.__init__(self, *args, **kwargs)
self.canvas = Gtk.DrawingArea()
self.pack_start(self.canvas, True, True, 0)
self.instance = vlc.Instance()
self.canvas.connect('realize', self.on_canvas_realized)
self.canvas.connect('draw', self.on_canvas_draw)
self.player = self.instance.media_player_new()
self.player.video_set_scale(0)
self.player.video_set_aspect_ratio('16:9')
self.player.video_set_deinterlace('on')
self.player.video_set_mouse_input(False)
self.player.video_set_key_input(False)
add_widget_class(self, 'player-video')
示例2: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import DrawingArea [as 别名]
def __init__(self, view, format_helper, person):
Gtk.DrawingArea.__init__(self)
self.view = view
self.format_helper = format_helper
self.person = person
self.force_mouse_over = False
self.in_drag = False
self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
self.add_events(Gdk.EventMask.BUTTON_RELEASE_MASK)
if self.person:
self.connect("button-release-event", self.cb_on_button_release)
self.connect("drag_data_get", self.cb_drag_data_get)
self.connect("drag_begin", self.cb_drag_begin)
self.connect("drag_end", self.cb_drag_end)
# Enable drag
self.drag_source_set(Gdk.ModifierType.BUTTON1_MASK,
[],
Gdk.DragAction.COPY)
tglist = Gtk.TargetList.new([])
tglist.add(DdTargets.PERSON_LINK.atom_drag_type,
DdTargets.PERSON_LINK.target_flags,
DdTargets.PERSON_LINK.app_id)
#allow drag to a text document, info on drag_get will be 0L !
tglist.add_text_targets(0)
self.drag_source_set_target_list(tglist)
示例3: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import DrawingArea [as 别名]
def __init__(self, background_color='#CECECE', show_grid=True, grid_color='#DDDDDD', grid_size=(15, 15), point_radius=3):
Gtk.Frame.__init__(self)
self.points = []
self.point_opacity = 0.7
self.point_radius = point_radius
self.show_grid = show_grid
self.grid_color = grid_color
self.grid_size = grid_size
self.background_color = background_color
self.use_origin_colors = False
self.add_borders = False
self.drawing_area = Gtk.DrawingArea()
self.drawing_area.set_has_tooltip(True)
self.drawing_area.connect('draw', self.on_draw)
self.drawing_area.connect('query-tooltip', self.on_query_tooltip)
self.add(self.drawing_area)
示例4: draw_scribble
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import DrawingArea [as 别名]
def draw_scribble(self, widget, cairo_context):
""" Perform the drawings by user.
Args:
widget (:class:`~Gtk.DrawingArea`): The widget where to draw the scribbles.
cairo_context (:class:`~cairo.Context`): The canvas on which to render the drawings
"""
ww, wh = widget.get_allocated_width(), widget.get_allocated_height()
cairo_context.set_line_cap(cairo.LINE_CAP_ROUND)
for color, width, points in self.scribble_list:
points = [(p[0] * ww, p[1] * wh) for p in points]
cairo_context.set_source_rgba(*color)
cairo_context.set_line_width(width)
cairo_context.move_to(*points[0])
for p in points[1:]:
cairo_context.line_to(*p)
cairo_context.stroke()
示例5: start
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import DrawingArea [as 别名]
def start(self, bridge):
"""Start the UI event loop."""
debug_ext_env = os.environ.get("NVIM_PYTHON_UI_DEBUG_EXT", "")
extra_exts = {x:True for x in debug_ext_env.split(",") if x}
bridge.attach(80, 24, rgb=True, **extra_exts)
drawing_area = Gtk.DrawingArea()
drawing_area.connect('draw', self._gtk_draw)
window = Gtk.Window()
window.add(drawing_area)
window.set_events(window.get_events() |
Gdk.EventMask.BUTTON_PRESS_MASK |
Gdk.EventMask.BUTTON_RELEASE_MASK |
Gdk.EventMask.POINTER_MOTION_MASK |
Gdk.EventMask.SCROLL_MASK)
window.connect('configure-event', self._gtk_configure)
window.connect('delete-event', self._gtk_quit)
window.connect('key-press-event', self._gtk_key)
window.connect('key-release-event', self._gtk_key_release)
window.connect('button-press-event', self._gtk_button_press)
window.connect('button-release-event', self._gtk_button_release)
window.connect('motion-notify-event', self._gtk_motion_notify)
window.connect('scroll-event', self._gtk_scroll)
window.connect('focus-in-event', self._gtk_focus_in)
window.connect('focus-out-event', self._gtk_focus_out)
window.show_all()
im_context = Gtk.IMMulticontext()
im_context.set_client_window(drawing_area.get_window())
im_context.set_use_preedit(False) # TODO: preedit at cursor position
im_context.connect('commit', self._gtk_input)
self._pango_context = drawing_area.create_pango_context()
self._drawing_area = drawing_area
self._window = window
self._im_context = im_context
self._bridge = bridge
Gtk.main()
示例6: destroy
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import DrawingArea [as 别名]
def destroy(self):
#Gtk.DrawingArea.destroy(self)
self.close_event()
GObject.source_remove(self._idle_event_id)
if self._idle_draw_id != 0:
GObject.source_remove(self._idle_draw_id)
示例7: destroy
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import DrawingArea [as 别名]
def destroy(self):
#Gtk.DrawingArea.destroy(self)
self.close_event()
if self._idle_draw_id != 0:
GLib.source_remove(self._idle_draw_id)
示例8: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import DrawingArea [as 别名]
def __init__(self, *args, **kwargs):
Gtk.Box.__init__(self, *args, **kwargs)
self.vid_url = None
self.stopped = False
self.canvas = Gtk.DrawingArea()
self.pack_start(self.canvas, True, True, 0)
self.player = mpv.MPV(ytdl=True, input_cursor=False, cursor_autohide=False)
self.canvas.connect('realize', self.on_canvas_realize)
self.canvas.connect('draw', self.on_canvas_draw)
add_widget_class(self, 'player-video')
示例9: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import DrawingArea [as 别名]
def __init__(self):
Gtk.DrawingArea.__init__(self)
self.add_events(Gdk.EventMask.POINTER_MOTION_MASK |
Gdk.EventMask.BUTTON_PRESS_MASK |
Gdk.EventMask.BUTTON_RELEASE_MASK)
self.connect('motion-notify-event', self.on_pointer_motion)
self.connect('button-press-event', self.on_button_press)
self.title = ''
self.axis = ''
self.grid_lines = True
self.__rects = None
self.__active = -1
self.chromosomes = (
('1', 248956422),
('2', 242193529),
('3', 198295559),
('4', 190214555),
('5', 181538259),
('6', 170805979),
('7', 159345973),
('8', 145138636),
('9', 138394717),
('10', 133797422),
('11', 135086622),
('12', 133275309),
('13', 114364328),
('14', 107043718),
('15', 101991189),
('16', 90338345),
('17', 83257441),
('18', 80373285),
('19', 58617616),
('20', 64444167),
('21', 46709983),
('22', 50818468),
('X', 156040895))
self.labels = [chromo[0] for chromo in self.chromosomes]
示例10: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import DrawingArea [as 别名]
def __init__(self):
Gtk.DrawingArea.__init__(self)
self.connect('draw', self._draw)
self.active = False
self.set_size_request(5, -1)
示例11: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import DrawingArea [as 别名]
def __init__(self, tag_list=None):
Gtk.DrawingArea.__init__(self)
self.add_events(Gdk.EventMask.POINTER_MOTION_MASK |
Gdk.EventMask.BUTTON_PRESS_MASK |
Gdk.EventMask.BUTTON_RELEASE_MASK)
self.connect('motion-notify-event', self.on_pointer_motion)
self.connect('button-press-event', self.on_button_press)
self.__active = -1
self.__rects = []
if tag_list is None:
self.tag_list = []
else:
self.tag_list = tag_list
示例12: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import DrawingArea [as 别名]
def __init__(self, position='middle'):
Gtk.DrawingArea.__init__(self)
self.add_events(Gdk.EventMask.POINTER_MOTION_MASK |
Gdk.EventMask.BUTTON_PRESS_MASK |
Gdk.EventMask.BUTTON_RELEASE_MASK)
self.connect('motion-notify-event', self.on_pointer_motion)
self.connect('button-press-event', self.on_button_press)
self.position = position
self.__active = False
示例13: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import DrawingArea [as 别名]
def __init__(self):
Gtk.DrawingArea.__init__(self)
self.connect("draw", self.on_draw)
self.timer = GObject.timeout_add(1000, self.tick)
示例14: destroy
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import DrawingArea [as 别名]
def destroy(self):
#Gtk.DrawingArea.destroy(self)
self.close_event()
GLib.source_remove(self._idle_event_id)
if self._idle_draw_id != 0:
GLib.source_remove(self._idle_draw_id)
示例15: main
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import DrawingArea [as 别名]
def main():
builder = Gtk.Builder()
builder.add_objects_from_file(os.path.join(os.path.dirname(__file__),
"mpl_with_glade3.glade"),
("window1", ""))
builder.connect_signals(Window1Signals())
window = builder.get_object("window1")
sw = builder.get_object("scrolledwindow1")
# Start of Matplotlib specific code
figure = Figure(figsize=(8, 6), dpi=71)
axis = figure.add_subplot(111)
t = np.arange(0.0, 3.0, 0.01)
s = np.sin(2*np.pi*t)
axis.plot(t, s)
axis.set_xlabel('time [s]')
axis.set_ylabel('voltage [V]')
canvas = FigureCanvas(figure) # a Gtk.DrawingArea
canvas.set_size_request(800, 600)
sw.add_with_viewport(canvas)
# End of Matplotlib specific code
window.show_all()
Gtk.main()