本文整理汇总了Python中gtk.gdk方法的典型用法代码示例。如果您正苦于以下问题:Python gtk.gdk方法的具体用法?Python gtk.gdk怎么用?Python gtk.gdk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk
的用法示例。
在下文中一共展示了gtk.gdk方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: position_popup_group_menu
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gdk [as 别名]
def position_popup_group_menu(self, menu, widget):
"""Calculate the position of the group popup menu"""
_screen_w = gtk.gdk.screen_width()
screen_h = gtk.gdk.screen_height()
if gtk.gtk_version >= (2, 14):
widget_win = widget.get_window()
else:
widget_win = widget.window
widget_x, widget_y = widget_win.get_origin()
_widget_w, widget_h = widget_win.get_size()
_menu_w, menu_h = menu.size_request()
if widget_y + widget_h + menu_h > screen_h:
menu_y = max(widget_y - menu_h, 0)
else:
menu_y = widget_y + widget_h
return(widget_x, menu_y, 1)
示例2: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gdk [as 别名]
def __init__(self):
gtk.DrawingArea.__init__(self)
self.graph = Graph()
self.openfilename = None
self.set_flags(gtk.CAN_FOCUS)
self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK)
self.connect("button-press-event", self.on_area_button_press)
self.connect("button-release-event", self.on_area_button_release)
self.add_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK | gtk.gdk.BUTTON_RELEASE_MASK)
self.connect("motion-notify-event", self.on_area_motion_notify)
self.connect("scroll-event", self.on_area_scroll_event)
self.connect("size-allocate", self.on_area_size_allocate)
self.connect('key-press-event', self.on_key_press_event)
self.x, self.y = 0.0, 0.0
self.zoom_ratio = 1.0
self.zoom_to_fit_on_resize = False
self.animation = NoAnimation(self)
self.drag_action = NullAction(self)
self.presstime = None
self.highlight = None
示例3: display_frame
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gdk [as 别名]
def display_frame(self,a,b):
self.drawing_area.window.draw_rectangle(self.drawing_area.get_style().white_gc,False,0,0,799,599)
if self.isBanner_mode:
self.canvas.draw_rgb_image(self.gc,1,1,798,598,gtk.gdk.RGB_DITHER_NORMAL,self.img.tostring(),2400)
#self.final=self.getOutput_frames()
#self.final=cv2.cvtColor(self.final,cv2.cv.CV_BGR2RGB)
elif not self.isBanner_mode:
if self.final==None:
self.final=self.getOutput_frames()
self.final=cv2.cvtColor(self.final,cv2.cv.CV_BGR2RGB)
self.drawing_area.queue_draw()
return
else:
self.canvas.draw_rgb_image(self.gc,1,1,798,598,gtk.gdk.RGB_DITHER_NORMAL,self.final.tostring(),2400)
self.final=self.getOutput_frames()
self.final=cv2.cvtColor(self.final,cv2.cv.CV_BGR2RGB)
self.drawing_area.queue_draw()
#self.canvas.draw_rgb_image(self.gc,1,1,798,598,gtk.gdk.RGB_DITHER_NORMAL,self.final.tostring(),2400)
示例4: set_cursor_color
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gdk [as 别名]
def set_cursor_color(self):
"""Set the cursor color appropriately"""
if self.config['cursor_color'] == self.config['foreground_color']:
try:
self.vte.set_color_cursor(None)
except TypeError:
# FIXME: I think this is only necessary because of
# https://bugzilla.gnome.org/show_bug.cgi?id=614910
pass
elif self.config['cursor_color'] != '':
self.vte.set_color_cursor(gtk.gdk.color_parse(
self.config['cursor_color']))
示例5: on_group_button_press
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gdk [as 别名]
def on_group_button_press(self, widget, event):
"""Handler for the group button"""
if event.button == 1:
if event.type == gtk.gdk._2BUTTON_PRESS or \
event.type == gtk.gdk._3BUTTON_PRESS:
# Ignore these, or they make the interaction bad
return False
# Super key applies interaction to all terms in group
include_siblings=event.state & gtk.gdk.MOD4_MASK == gtk.gdk.MOD4_MASK
if include_siblings:
targets=self.terminator.get_sibling_terms(self)
else:
targets=[self]
if event.state & gtk.gdk.CONTROL_MASK == gtk.gdk.CONTROL_MASK:
dbg('on_group_button_press: toggle terminal to focused terminals group')
focused=self.get_toplevel().get_focussed_terminal()
if focused in targets: targets.remove(focused)
if self != focused:
if self.group==focused.group:
new_group=None
else:
new_group=focused.group
[term.set_group(None, new_group) for term in targets]
[term.titlebar.update(focused) for term in targets]
return True
elif event.state & gtk.gdk.SHIFT_MASK == gtk.gdk.SHIFT_MASK:
dbg('on_group_button_press: rename of terminals group')
self.targets_for_new_group = targets
self.titlebar.create_group()
return True
elif event.type == gtk.gdk.BUTTON_PRESS:
# Single Click gives popup
dbg('on_group_button_press: group menu popup')
self.create_popup_group_menu(widget, event)
return True
else:
dbg('on_group_button_press: unknown group button interaction')
return(False)
示例6: on_keypress
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gdk [as 别名]
def on_keypress(self, widget, event):
"""Handler for keyboard events"""
if not event:
dbg('Terminal::on_keypress: Called on %s with no event' % widget)
return(False)
# FIXME: Does keybindings really want to live in Terminator()?
mapping = self.terminator.keybindings.lookup(event)
if mapping == "hide_window":
return(False)
if mapping and mapping not in ['close_window',
'full_screen',
'new_tab']:
dbg('Terminal::on_keypress: lookup found: %r' % mapping)
# handle the case where user has re-bound copy to ctrl+<key>
# we only copy if there is a selection otherwise let it fall through
# to ^<key>
if (mapping == "copy" and event.state & gtk.gdk.CONTROL_MASK):
if self.vte.get_has_selection ():
getattr(self, "key_" + mapping)()
return(True)
else:
getattr(self, "key_" + mapping)()
return(True)
# FIXME: This is all clearly wrong. We should be doing this better
# maybe we can emit the key event and let Terminator() care?
groupsend = self.terminator.groupsend
groupsend_type = self.terminator.groupsend_type
window_focussed = self.vte.get_toplevel().get_property('has-toplevel-focus')
if groupsend != groupsend_type['off'] and window_focussed and self.vte.is_focus():
if self.group and groupsend == groupsend_type['group']:
self.terminator.group_emit(self, self.group, 'key-press-event',
event)
if groupsend == groupsend_type['all']:
self.terminator.all_emit(self, 'key-press-event', event)
return(False)
示例7: open_url
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gdk [as 别名]
def open_url(self, url, prepare=False):
"""Open a given URL, conditionally unpacking it from a VTE match"""
oldstyle = False
if prepare == True:
url = self.prepare_url(url)
dbg('open_url: URL: %s (prepared: %s)' % (url, prepare))
if self.config['use_custom_url_handler']:
dbg("Using custom URL handler: %s" %
self.config['custom_url_handler'])
try:
subprocess.Popen([self.config['custom_url_handler'], url])
return
except:
dbg('custom url handler did not work, falling back to defaults')
if gtk.gtk_version < (2, 14, 0) or \
not hasattr(gtk, 'show_uri') or \
not hasattr(gtk.gdk, 'CURRENT_TIME'):
oldstyle = True
if oldstyle == False:
try:
gtk.show_uri(None, url, gtk.gdk.CURRENT_TIME)
except:
oldstyle = True
if oldstyle == True:
dbg('Old gtk (%s,%s,%s), calling xdg-open' % gtk.gtk_version)
try:
subprocess.Popen(["xdg-open", url])
except:
dbg('xdg-open did not work, falling back to webbrowser.open')
import webbrowser
webbrowser.open(url)
示例8: reverse
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gdk [as 别名]
def reverse(self):
front = self.get_property("foreground-gdk")
back = self.get_property("background-gdk")
self.set_property("foreground-gdk", back)
self.set_property("background-gdk", front)
self.reversed = not self.reversed
示例9: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gdk [as 别名]
def __init__(self, tagtable=None):
VView.__init__(self)
self.textview = gtk.TextView()
self.textview.connect("populate_popup", self.vwGetPopup)
self.add(self.textview)
if tagtable == None:
tagtable = gtk.TextTagTable()
self.vwSetTagTable(tagtable)
style = gtk.Style()
style.base[gtk.STATE_NORMAL] = gdk.Color(0,0,0)
style.text[gtk.STATE_NORMAL] = gdk.Color(0,0,0xff)
style.base[gtk.STATE_INSENSITIVE] = gdk.Color(0,0,0)
style.text[gtk.STATE_INSENSITIVE] = gdk.Color(20,20,20)
self.textview.set_style(style)
self.tagcfg = ConfigParser()
self.curtag = None # Is a current tag selected?
#self.deftag =
self.vwInitTag(VTextTag("default"))
start,end = self.textbuf.get_bounds()
self.textbuf.create_mark("insertend", end)
示例10: vwTagSelector
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gdk [as 别名]
def vwTagSelector(self, tag, textview, event, iter):
"""
Use this as the event handler for tag events on exclusivly
selectable tags.
"""
if event.type == gdk.BUTTON_PRESS:
if tag.get_property("name") != "default":
if self.curtag != None:
self.curtag.reverse()
tag.reverse()
self.curtag = tag
return True
示例11: vwTagEvent
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gdk [as 别名]
def vwTagEvent(self, tag, textview, event, iter):
# The first tag on a line is *always* the VA tag
# for the line. Update our "position" on clicks
if event.type == gdk.BUTTON_PRESS:
self.setVaFromIter(iter)
# A special tag event handler for VA tags.
示例12: vaTagEvent
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gdk [as 别名]
def vaTagEvent(self, tag, textview, event, iter):
if event.type == gdk._2BUTTON_PRESS:
self.goto(tag.va)
elif event.type == gdk.BUTTON_PRESS:
self.selectva = tag.va
self.vaTagSelector(tag)
示例13: lookup_color
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gdk [as 别名]
def lookup_color(self, c):
try:
color = gtk.gdk.color_parse(c)
except ValueError:
pass
else:
s = 1.0/65535.0
r = color.red*s
g = color.green*s
b = color.blue*s
a = 1.0
return r, g, b, a
try:
dummy, scheme, index = c.split('/')
r, g, b = brewer_colors[scheme][int(index)]
except (ValueError, KeyError):
pass
else:
s = 1.0/255.0
r = r*s
g = g*s
b = b*s
a = 1.0
return r, g, b, a
sys.stderr.write("unknown color '%s'\n" % c)
return None
示例14: on_motion_notify
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gdk [as 别名]
def on_motion_notify(self, event):
if event.is_hint:
x, y, state = event.window.get_pointer()
else:
x, y, state = event.x, event.y, event.state
dot_widget = self.dot_widget
item = dot_widget.get_url(x, y)
if item is None:
item = dot_widget.get_jump(x, y)
if item is not None:
dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
dot_widget.set_highlight(item.highlight)
else:
dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.ARROW))
dot_widget.set_highlight(None)
示例15: start
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gdk [as 别名]
def start(self):
self.dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.FLEUR))