pygtkdrawingwindow package¶
Submodules¶
pygtkdrawingwindow.base module¶
-
class
pygtkdrawingwindow.base.
DrawingWindow
[source]¶ Bases:
gtk.ScrolledWindow
Drawing widget.
-
__gsignals__
¶ GObject signals:
- render(widget :
DrawingWindow
, ctx:cairo.Context
) - Image draw signal.
- render(widget :
-
screen
¶ gtk.DrawingArea
– Drawing area.
-
pointer
¶ (
float
,float
) or None – Pointer coordinates on drawing area.
-
pointer_root
¶ (
float
,float
) or None – Pointer coordinates on root window.
-
_scrollbar_size
¶ int
– Scrollbar size.
-
_fit_offset
¶ int
– Fit offset.
-
_size
¶ (
int
,int
) – Image size.
-
_rotate
¶ float
– Image rotation angle.
-
_scale
¶ float
– Zoom ratio.
-
_prev_scale
¶ float
– Previous zoom ratio.
-
_fit
¶ FitType
– Fit type.
-
_do_fit
¶ function
– Fit function.
-
_do_fit_funcs
¶ tuple
offunction
– Fit functions by type.
Examples
>>> def render(widget, ctx): ... width, height = widget.get_size() ... ctx.set_source_rgb(1.0, 0.5, 1.0) ... ctx.rectangle(0, 0, width, height) ... ctx.stroke() ... >>> widget = DrawingWindow() >>> widget.set_size(200, 200) >>> widget.connect('render', render)
-
BUTTON_MASK
= <flags GDK_BUTTON1_MASK | GDK_BUTTON2_MASK of type GdkModifierType>¶ ModifierType
– Pointer motion button mask.
-
EVENTS
= <flags GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_LEAVE_NOTIFY_MASK of type GdkEventMask>¶ EventMask
– Drawing area event mask.
-
POLICY
= <enum GTK_POLICY_AUTOMATIC of type GtkPolicyType>¶ PolicyType
– Scrollbar policy type.
-
SHADOW
= <enum GTK_SHADOW_NONE of type GtkShadowType>¶ ShadowType
– Shadow type.
-
draw_event
(_, ctx)[source]¶ Handle drawing area
draw
event.Parameters: - _ (
gtk.DrawingArea
) – - ctx (
cairo.Context
) –
- _ (
-
expose_event
(_, event)[source]¶ Handle drawing area
expose
event.Parameters: - _ (
gtk.DrawingArea
) – - event (
gtk.gdk.Event
) –
- _ (
-
get_screen_size
()[source]¶ Get drawing area size.
Returns: Drawing area width and height. Return type: ( int
,int
)
-
leave_notify_event
(_, ev_)[source]¶ Handle drawing area
leave-notify
event.Parameters: - _ (
gtk.DrawingArea
) – - ev (
gtk.gdk.Event
) –
Returns: True
to stop event propagation.Return type: bool
- _ (
-
motion_notify_event
(_, event)[source]¶ Handle drawing area
motion-notify
event.Parameters: - _ (
gtk.DrawingArea
) – - event (
gtk.gdk.Event
) –
Returns: True
to stop event propagation.Return type: bool
- _ (
-
scroll_event
(_, event)[source]¶ Handle
scroll
event.Parameters: - _ (
DrawingWindow
) – - event (
gtk.gdk.Event
) –
Returns: True
to stop event propagation.Return type: bool
- _ (
-
set_size
(width, height)[source]¶ Set image size.
Parameters: - width (
int
) – Image width. - height (
int
) – Image height.
- width (
-
pygtkdrawingwindow.deps module¶
-
class
pygtkdrawingwindow.deps.
ImageType
[source]¶ Bases:
enum.IntEnum
PyGTK image types.
-
ANIMATION
= 6¶
-
EMPTY
= 0¶
-
ICON_SET
= 5¶
-
IMAGE
= 2¶
-
PIXBUF
= 3¶
-
PIXMAP
= 1¶
-
STOCK
= 4¶
-
-
class
pygtkdrawingwindow.deps.
NoRsvg
[source]¶ Bases:
object
Missing rsvg module class.
Examples
>>> rsvg = NoRsvg >>> rsvg.Handle('image.svg') glib.GError: missing rsvg module >>> rsvg.Handle.new_from_file('image.svg') glib.GError: missing rsvg module
pygtkdrawingwindow.image module¶
-
class
pygtkdrawingwindow.image.
ImageWindow
[source]¶ Bases:
pygtkdrawingwindow.base.DrawingWindow
Drawing widget with background image.
-
image_filter
¶ Cairo filter for image scaling.
-
new_image_fit
¶ FitType
– Fit type to set on image change.
-
_image
¶ None
orgtk.gdk.Pixbuf
orgtk.gdk.PixbufAnimation
orrsvg.Handle
– Background image.
-
_animation
¶ gtk.gdk.PixbufAnimationIter
– Animation iterator.
-
_animation_time
¶ float
orNone
– Animation start/stop time.
-
_animation_timeout
¶ int
orNone
– Animation timeout id.
-
_prev_delay
¶ int
– Previous frame delay in milliseconds.
-
EVENTS
= <flags GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK of type GdkEventMask>¶ EventMask
– Drawing area event mask.
-
MIN_ANIMATION_DELAY
= 10¶ int
– Minimum animation frame delay in milliseconds.
-
get_image
()[source]¶ Get background image.
Returns: Background image. Return type: None
orgtk.gdk.Pixbuf
orgtk.gdk.PixbufAnimation
orrsvg.Handle
-
set_animation
(enable)[source]¶ Set animation state.
Parameters: enable ( bool
) –True
to start animation,False
to stop.
-
pygtkdrawingwindow.util module¶
-
class
pygtkdrawingwindow.util.
FitType
[source]¶ Bases:
enum.IntEnum
Zoom fit types.
-
FIT
= 1¶
-
FIT_OR_1TO1
= 4¶
-
HEIGHT
= 3¶
-
LAST
= -1¶
-
NONE
= 0¶
-
WIDTH
= 2¶
-
-
pygtkdrawingwindow.util.
freeze
(*args, **kwds)[source]¶ Widget update freezing context manager.
Parameters: widget ( gtk.Widget
) – Widget to freeze.
-
pygtkdrawingwindow.util.
get_gtk_image_size
(img)[source]¶ Get GTK size.
Parameters: img ( gtk.Image
) –Raises: ValueError
– If image storage type is invalid.Returns: Image width and height. Return type: ( int
,int
)
-
pygtkdrawingwindow.util.
get_image_size
(img)[source]¶ Get image size.
Parameters: img ( None
orrsvg.Handle
orgtk.gdk.Pixbuf
orgtk.gdk.PixbufAnimation
orgtk.Image
) –Raises: TypeError
– If image type is invalid.Returns: Image width and height. Return type: ( int
,int
)
-
pygtkdrawingwindow.util.
get_pixbuf_size
(pixbuf)[source]¶ Get GTK pixbuf size.
Parameters: img ( gtk.gdk.Pixbuf
orgtk.gdk.PixbufAnimation
) –Returns: Pixbuf width and height. Return type: ( int
,int
)
-
pygtkdrawingwindow.util.
get_scroll_direction
(event)[source]¶ Get scroll event direction.
Parameters: event ( gtk.gdk.Event
) – Scroll event.Returns: Return type: ScrollDirection
-
pygtkdrawingwindow.util.
get_timeval
(time_)[source]¶ Get time value.
Parameters: time ( float
) – Time fromtime.time()
Returns: Time value for gtk.gdk.PixbufAnimation.get_iter()
.Return type: gi.repository.GLib.TimeVal
orfloat
-
pygtkdrawingwindow.util.
ignore_args
(func)[source]¶ Create a function that ignores its arguments.
Parameters: func ( function
) – Function to decorate.Returns: Return type: function
Examples
>>> @ignore_args ... def f(*args): ... print(args) ... >>> f(1, 2, x=3) ()
-
pygtkdrawingwindow.util.
load_gtk_image
(img, widget=None)[source]¶ Load GTK image.
Parameters: - img (
gtk.Image
) – Image to load. - widget (
gtk.Widget
, optional) – Widget for icon rendering (default: gtk.Label()).
Raises: ValueError
– If image storage type not in (EMPTY, PIXBUF, ANIMATION, STOCK).Returns: Loaded image or
None
if image is empty.Return type: gtk.gdk.Pixbuf
orgtk.gdk.PixbufAnimation
orNone
- img (
-
pygtkdrawingwindow.util.
load_image
(img, widget=None)[source]¶ Load an image.
Parameters: - img (
str
orgtk.Image
orgtk.gdk.Pixbuf
orgtk.gdk.PixbufAnimation
orrsvg.Handle
) – Image to load. - widget (
gtk.Widget
, optional) – Widget for icon rendering (default: gtk.Label()).
Returns: Loaded image or
None
if image is empty.Return type: gtk.gdk.Pixbuf
orgtk.gdk.PixbufAnimation
orrsvg.Handle
orNone
- img (
-
pygtkdrawingwindow.util.
load_image_file
(path)[source]¶ Load image from file.
Parameters: path ( str
) – Image file path.Returns: Loaded image. Return type: rsvg.Handle
orgtk.Image