本文整理汇总了Python中gtk.Entry.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.connect方法的具体用法?Python Entry.connect怎么用?Python Entry.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk.Entry
的用法示例。
在下文中一共展示了Entry.connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search_dialog
# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import connect [as 别名]
class search_dialog(Dialog):
def __init__(self, parent, icon):
Dialog.__init__(self, _("Search for.."), parent,
DIALOG_MODAL | DIALOG_DESTROY_WITH_PARENT,
(STOCK_OK, RESPONSE_ACCEPT,
STOCK_CANCEL, RESPONSE_REJECT))
self.set_icon(pixbuf_new_from_file(icon))
self._setup_layout()
def _setup_layout(self):
self.label = Label(_("Insert keywords:"))
self.entry = Entry()
self.entry.connect("activate", self._entry_response)
self.vbox.pack_start(self.label, False, False, 0)
self.vbox.pack_start(self.entry, False, False, 0)
self.vbox.show_all()
def _entry_response(self, widget, data=None):
self.response(RESPONSE_ACCEPT)
示例2: Base
# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import connect [as 别名]
class Base(object):
def __init__(self):
from gtk import Window,WINDOW_TOPLEVEL,Button,Label,HBox,Entry,VBox,VSeparator
self.window = Window(WINDOW_TOPLEVEL)
self.window.set_title("Slideshow")
self.window.connect("delete_event", self.delete_event)
self.window.set_border_width(10)
self.vbox = VBox(False, 0)
self.window.add(self.vbox)
self.hbox1 = HBox(False, 0)
self.vbox.pack_start(self.hbox1, True, True, 1)
self.hbox = HBox(False, 0)
self.vbox.pack_start(self.hbox, False, False, 1)
self.hbox2 = HBox(False, 0)
self.vbox.pack_start(self.hbox2, True, True, 1)
self.label = Label('Identifikační číslo:')
self.hbox.pack_start(self.label, False, False, 1)
self.label.show()
self.editable = Entry()
self.editable.connect('key_press_event', self.key_press_event)
self.hbox.pack_start(self.editable, True, True, 1)
self.editable.show()
self.button = Button("Začít")
self.button.connect("clicked", self.callback)
self.button.set_receives_default(True)
self.button.set_can_focus(True)
self.hbox.pack_start(self.button, False, False, 1)
self.button.show()
self.hbox1.show()
self.hbox.show()
self.hbox2.show()
self.vbox.show()
self.window.show()
def delete_event(self, widget, event, data=None):
gtk.main_quit()
return False
def key_press_event(self, widget, event):
from gtk.gdk import keyval_from_name,keyval_name
if event.keyval in (keyval_from_name('Return'),keyval_from_name('KP_Enter')):
self.callback(widget)
def _getFilePaths(self, fileTypes, recursive=True):
import os
import re
from sys import argv
pt = re.compile(r'.*([%(0)s][^%(0)s]*)'%{'0':os.path.extsep})
path = [a for m,a in ((pt.match(os.path.basename(a)),a) for a in argv[1:]) if m and m.group(1) in fileTypes]
if not path:
path = '/home/pi/img/*.jpg'
if isinstance(path, str):
## Returns list containing paths of files in /path/ that are of a file type in /fileTypes/,
## if /recursive/ is False subdirectories are not checked.
paths = []
if recursive:
for root, folders, files in os.walk(path, followlinks=True):
for file in files:
for fileType in fileTypes:
if file.endswith(fileType):
paths.append(os.path.join(root, file))
else:
for item in os.listdir(path):
for fileType in fileTypes:
if item.endswith(fileType):
paths.append(os.path.join(root, item))
return paths
elif iterable(path):
return path
else:
return []
def _init_cb(self,trans):
from threading import Thread
if not iterable(trans):
trans = trans,
callbacks = []
for name,cb in trans:
t = Thread(target=cb, name='%sThread'%name)
t.daemon = True
t.start()
callbacks.append(cb.enqueue)
def wrap(msg):
for cb in callbacks:
if not cb(msg):
return False
return True
return wrap
def callback(self, widget):
from slideshow import SlideShow
from trans import Message,GpioTransceiver,JsonTransceiver
if not self.editable.get_text():
return False
img_cbs = self._init_cb([('ImgGpioCallback',GpioTransceiver(24)),('ImgJsonCallback',JsonTransceiver('img.json'))])
kp_cbs = self._init_cb([('KpGpioCallback',GpioTransceiver(26,bcd=False)),('KpJsonCallback',JsonTransceiver('kp.json'))])
def ordfnc(path):
from numpy.random import permutation
gray = path[0]
result = []
for p in permutation(path[1:]):
result.append(p)
result.append(gray)
return result
#.........这里部分代码省略.........