本文整理汇总了Python中gtk.Entry.set_text方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.set_text方法的具体用法?Python Entry.set_text怎么用?Python Entry.set_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk.Entry
的用法示例。
在下文中一共展示了Entry.set_text方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ItemEntry_orig
# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import set_text [as 别名]
class ItemEntry_orig(HBox):
def __init__(self, item, name='ItemEntry'):
HBox.__init__(self)
self.set_name(name)
self._key_, self._val_ = item
self.label = Label(self._key_)
self.entry = Entry()
self.entry.set_text(self._val_)
self.pack_start(self.label,0,0,0)
self.pack_end(self.entry,0,0,0)
map(lambda x: x.show(), [self.label, self.entry])
self.show()
示例2: input_entry_dialog
# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import set_text [as 别名]
def input_entry_dialog(msg, default_answer="", parent=None):
dia = Dialog(
msg, parent, gtk.DIALOG_MODAL |gtk.DIALOG_DESTROY_WITH_PARENT,
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
gtk.STOCK_OK, RESPONSE_OK) )
dia.vbox.pack_start(Label(msg))
da_entry = Entry()
da_entry.set_text(default_answer)
dia.vbox.pack_end( da_entry )
dia.show_all()
result = dia.run()
datext = da_entry.get_text()
dia.destroy()
return datext if result == RESPONSE_OK else None
示例3: _FieldEntry
# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import set_text [as 别名]
class _FieldEntry(HBox):
def __init__(self, name, default=None):
HBox.__init__(self)
self.set_name(name)
self.label = Label(name)
self.entry = Entry()
self.pack_start(self.label, True, True, 0)
self.add(self.entry)
self.label.show()
self.entry.show()
if default:
self.set(default)
self.show()
def set(self, value):
self.entry.set_text(value)
示例4: ItemEntry
# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import set_text [as 别名]
class ItemEntry(HBox):
def __init__(self, item, name='ItemEntry'):
if len(item) != 2:
raise Error, 'ItemEntry needs item not %s' %item
field, value = item
HBox.__init__(self)
self.set_name(name)
self.label = Label(field)
self.pack_start(self.label, FALSE, FALSE, 0)
self.entry = Entry()
self.set(str(value))
self.pack_end(self.entry, TRUE, TRUE, 0)
self.label.show()
self.entry.show()
self.show()
def get(self):
return self.entry.get_text()
def set(self, value):
self.entry.set_text(value)
def fieldname(self):
return self.label.get_text()
示例5: MDSplusXdBox
# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import set_text [as 别名]
#.........这里部分代码省略.........
self.expression = MDSplusExpressionWidget()
self.method = MDSplusMethodWidget()
self.routine = MDSplusRoutineWidget()
self.dispatch = MDSplusDispatchWidget()
self.range = MDSplusRangeWidget()
self.widgets = (
self.action,
self.sequential,
self.expression,
self.method,
self.routine,
self.dispatch,
self.range,
self.windoww,
)
self.ok = Button(stock=STOCK_OK)
self.cancel = Button(stock=STOCK_CANCEL)
self.redo = Button(stock=STOCK_REDO)
self.ok.connect("clicked", self.do_ok)
self.cancel.connect("clicked", self.do_cancel)
self.redo.connect("clicked", self.do_redo)
hb2 = HBox()
hb2.add(self.ok)
hb2.add(self.redo)
hb2.add(self.cancel)
vb = VBox(homogeneous=False)
vb.set_border_width(10)
vb.pack_start(hbtop, False, False, 0)
vb.pack_start(hbtags, False, False, 0)
vb.pack_start(expression_menu, False, False, 0)
vb.pack_start(axis_menu, False, False, 0)
vb.pack_start(window_menu, False, False, 0)
vb.pack_start(dispatch_menu, False, False, 0)
vb.pack_start(action_menu, False, False, 0)
vb.pack_start(task_menu, False, False, 0)
vb.pack_start(any_menu, False, False, 0)
for w in self.widgets:
w.set_no_show_all(True)
vb.pack_start(w, False, False, 0)
vb.pack_start(hb2, False, False, 20)
self.add(vb)
self.do_redo(self.redo)
self.putOnApply = True
self.nidOffset = -1
def set_dtype(self):
if hasattr(self, "_node"):
try:
exec("self.dtype=self.dtype_%s" % (self.node.usage.lower(),))
except Exception:
self.dtype = self.dtype_expression
else:
self.dtype = self.dtype_any
self.dtype.set_no_show_all(False)
def do_ok(self, button):
try:
value = self.value
if not self.putOnApply:
self.hide()
elif hasattr(self, "_node"):
try:
self.node.record = value
self.hide()
except Exception:
self.popupError(sys.exc_info())
else:
self.value = value
self.hide()
except:
pass
def do_redo(self, button):
if not hasattr(self, "_node"):
self.value = _value
self.set_dtype()
else:
self.path.reset()
self.on.set_active(self.node.disabled == False)
self.parent_on.set_active(self.node.parent_disabled == False)
tags = self.node.tags
if tags is None:
self.tags.set_text("")
else:
taglist = ""
for tag in tags:
if taglist == "":
taglist = tag
else:
taglist = taglist + "," + tag
self.tags.set_text(taglist)
self.set_dtype()
try:
self.value = self.record
except:
self.value = None
self.reset()
def do_cancel(self, button):
self.hide()
示例6: MDSplusSequentialWidget
# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import set_text [as 别名]
class MDSplusSequentialWidget(Table):
def __init__(self,value=None):
super(MDSplusSequentialWidget,self).__init__(rows=4,columns=2,homogeneous=False)
self.ident=Entry()
self.phase=Entry()
self.sequence=Entry()
self.event=Entry()
self.attach(Label("Server: "),0,1,0,1,0,0)
self.attach(self.ident,1,2,0,1,EXPAND|FILL,0)
self.attach(Label("Phase: "),0,1,1,2,0,0)
self.attach(self.phase,1,2,1,2,EXPAND|FILL,0)
self.attach(Label("Sequence:"),0,1,2,3,0,0)
self.attach(self.sequence,1,2,2,3,EXPAND|FILL,0)
self.attach(Label("Event: "),0,1,3,4,0,0)
self.attach(self.event,1,2,3,4,EXPAND|FILL,0)
self.set_row_spacings(5)
self.value=value
def getValue(self):
ans=Dispatch(dispatch_type=2)
ans.ident=self.ident.get_text()
try:
ans.ident=Data.compile(ans.ident)
except Exception:
pass
ans.phase=self.phase.get_text()
try:
ans.phase=Data.compile(ans.phase)
except Exception:
pass
try:
ans.when=Data.compile(self.sequence.get_text())
except Exception:
msg="Invalid sequence specified.\n\n%s" % (sys.exc_info()[1],)
MDSplusErrorMsg('Invalid Sequence',msg)
raise
ans.completion=self.event.get_text()
if ans.completion == '':
ans.completion=None
else:
try:
ans.completion=Data.compile(ans.event)
except Exception:
pass
return ans
def setValue(self,d):
self._value=d
self.reset()
def reset(self):
if isinstance(self._value,Dispatch):
self.ident.set_text(self._value.ident.decompile())
self.phase.set_text(self._value.phase.decompile())
self.sequence.set_text(self._value.when.decompile())
if self._value.completion is None:
self.event.set_text('')
else:
self.event.set_text(self._value.completion.decompile())
else:
self.ident.set_text('')
self.phase.set_text('')
self.sequence.set_text('')
self.event.set_text('')
value=property(getValue,setValue)
def show(self):
old=self.get_no_show_all()
self.set_no_show_all(False)
self.show_all()
self.set_no_show_all(old)
示例7: MDSplusRoutineWidget
# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import set_text [as 别名]
class MDSplusRoutineWidget(Table):
def __init__(self,value=None):
super(MDSplusRoutineWidget,self).__init__(rows=4,columns=2,homogeneous=False)
self.image=Entry()
self.routine=Entry()
self.args=list()
self.argTable=Table(rows=8,columns=2,homogeneous=False)
for i in range(8):
self.args.append(Entry())
self.argTable.attach(Label("Arg %d: " % (i+1,)),0,1,i,i+1,0,0)
self.argTable.attach(self.args[i],1,2,i,i+1,EXPAND|FILL,0)
self.scrolledWindow=ScrolledWindow()
self.scrolledWindow.add_with_viewport(self.argTable)
self.scrolledWindow.set_policy(POLICY_NEVER,POLICY_ALWAYS)
adj=self.scrolledWindow.get_vadjustment()
adj.connect("changed",adj_changed)
self.timeout=Entry()
self.attach(Label("Library:"),0,1,0,1,0,0)
self.attach(self.image,1,2,0,1,EXPAND|FILL,0)
self.attach(Label("Routine:"),0,1,1,2,0,0)
self.attach(self.routine,1,2,1,2,EXPAND|FILL,0)
self.attach(self.scrolledWindow,0,2,2,3)
self.attach(Label("Timeout:"),0,1,3,4,0,0)
self.attach(self.timeout,1,2,3,4,EXPAND|FILL,0)
self.set_row_spacings(5)
self.value=value
def getValue(self):
ans=Routine()
ans.image=self.image.get_text()
try:
ans.image=Data.compile(ans.image)
except Exception:
pass
ans.routine=self.routine.get_text()
try:
ans.routine=Data.compile(ans.routine)
except Exception:
pass
if self.timeout.get_text() == '' or self.timeout.get_text() == '*':
ans.timeout=None
else:
try:
ans.timeout=Data.compile(self.timeout.get_text())
except Exception:
msg="Invalid timeout specified.\n\n%s" % (sys.exc_info(),)
MDSplusErrorMsg('Invalid Timeout',msg)
raise
idx=len(self.args)-1
found=False
while idx >= 0:
t = self.args[idx].get_text()
if t == '':
if found:
ans.setArgumentAt(idx,None)
else:
try:
a=Data.compile(t)
except Exception:
msg="Invalid argument specified.\n\n%s" % (sys.exc_info(),)
MDSplusErrorMsg('Invalid Argument',msg)
raise
ans.setArgumentAt(idx,a)
found=True
idx=idx-1
return ans
def setValue(self,d):
self._value=d
self.reset()
def reset(self):
if isinstance(self._value,Routine):
self.image.set_text(self._value.image.decompile())
self.routine.set_text(self._value.routine.decompile())
if self._value.timeout is None or self._value.timeout.decompile() == '*':
self.timeout.set_text('')
else:
self.timeout.set_text(self._value.timeout.decompile())
idx=0
for arg in self.args:
if self._value.getArgumentAt(idx) is None:
arg.set_text('')
else:
arg.set_text(self._value.getArgumentAt(idx).decompile())
idx=idx+1
else:
self.image.set_text('')
self.routine.set_text('')
self.timeout.set_text('')
for arg in self.args:
arg.set_text('')
value=property(getValue,setValue)
def show(self):
old=self.get_no_show_all()
self.set_no_show_all(False)
#.........这里部分代码省略.........
示例8: GeoForm
# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import set_text [as 别名]
class GeoForm(Table):
__gsignals__ = {
'search': (SIGNAL_ACTION, TYPE_NONE, (TYPE_FLOAT, TYPE_FLOAT))
}
def __init__(self):
Table.__init__(self, 1, 5)
self.entry1 = Entry()
self.entry2 = Entry()
self.button = Button("Search")
self.attach(self.entry1, 0, 1, 0, 1)
self.attach(self.entry2, 1, 2, 0, 1)
self.attach(self.button, 2, 3, 0, 1)
self.entry1.set_width_chars(12)
self.entry2.set_width_chars(12)
self.entry1.set_text("59.666042")
self.entry2.set_text("16.481794")
self.button.connect('clicked', self.clicked)
def get_lat_long(self):
s1 = self.entry1.get_text()
s2 = self.entry2.get_text()
re1 = FMT1.match(s1)
re2 = FMT1.match(s2)
if re1 and re2:
return float(re1.group(0)), float(re2.group(0))
re1 = FMT2.match(s1)
re2 = FMT3.match(s2)
if re1 and re2:
c1 = re1.group(3), re1.group(1), re1.group(2)
c2 = re2.group(3), re2.group(1), re2.group(2)
return geo2dec(c1, c2)
re1 = FMT4.match(s1)
re2 = FMT5.match(s2)
if re1 and re1:
c1 = re1.group(1), re1.group(2), re1.group(3)
c2 = re2.group(1), re2.group(2), re2.group(3)
return geo2dec(c1, c2)
raise SyntaxError()
def clicked(self, event):
try:
self.emit('search', *self.get_lat_long())
except SyntaxError: pass
示例9: Base
# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import set_text [as 别名]
#.........这里部分代码省略.........
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
slide = SlideShow(
path=self._getFilePaths(('.jpg', '.jpeg', '.png')),
transition='None',
fullscreen=True,
delay=5,
order=ordfnc,
principal=self.editable.get_text(),
img_callback = img_cbs,
kp_callback = kp_cbs,
)
self.editable.set_text('')
slide()
def __call__(self):
gtk.main()
示例10: MDSplusRangeWidget
# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import set_text [as 别名]
class MDSplusRangeWidget(Table):
def __init__(self,value=None):
super(MDSplusRangeWidget,self).__init__(rows=3,columns=2,homogeneous=False)
self.begin=Entry()
self.ending=Entry()
self.delta=Entry()
self.attach(Label("Begin: "),0,1,0,1,0,0)
self.attach(self.begin,1,2,0,1,EXPAND|FILL,0)
self.attach(Label("Ending: "),0,1,1,2,0,0)
self.attach(self.ending,1,2,1,2,EXPAND|FILL,0)
self.attach(Label("Delta:"),0,1,2,3,0,0)
self.attach(self.delta,1,2,2,3,EXPAND|FILL,0)
self.set_row_spacings(5)
self.value=value
def getValue(self):
ans=Range()
t=self.begin.get_text()
if t == '':
ans.begin=None
else:
try:
ans.begin=Data.compile(self.begin.get_text())
except Exception:
msg="Invalid begin specified.\n\n%s" % (sys.exc_info()[1],)
MDSplusErrorMsg('Invalid Begin',msg)
raise
t=self.ending.get_text()
if t == '':
ans.ending=None
else:
try:
ans.ending=Data.compile(self.ending.get_text())
except Exception:
msg="Invalid ending specified.\n\n%s" % (sys.exc_info()[1],)
MDSplusErrorMsg('Invalid Ending',msg)
raise
t=self.delta.get_text()
if t != '':
try:
ans.delta=Data.compile(self.delta.get_text())
except Exception:
msg="Invalid delta specified.\n\n%s" % (sys.exc_info()[1],)
MDSplusErrorMsg('Invalid Delta',msg)
raise
return ans
def setValue(self,d):
self._value=d
self.reset()
def reset(self):
if isinstance(self._value,Range):
if self._value.begin is None:
self.begin.set_text('')
else:
self.begin.set_text(self._value.begin.decompile())
if self._value.ending is None:
self.ending.set_text('')
else:
self.ending.set_text(self._value.ending.decompile())
if self._value.delta is None:
self.delta.set_text('')
else:
self.delta.set_text(self._value.delta.decompile())
else:
self.begin.set_text('')
self.ending.set_text('')
self.delta.set_text('')
value=property(getValue,setValue)
def show(self):
old=self.get_no_show_all()
self.set_no_show_all(False)
self.show_all()
self.set_no_show_all(old)
示例11: MDSplusWindowWidget
# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import set_text [as 别名]
class MDSplusWindowWidget(Table):
def __init__(self,value=None):
super(MDSplusWindowWidget,self).__init__(rows=3,columns=2,homogeneous=False)
self.startIdx=Entry()
self.endIdx=Entry()
self.timeAt0=Entry()
self.attach(Label("StartIdx: "),0,1,0,1,0,0)
self.attach(self.startIdx,1,2,0,1,EXPAND|FILL,0)
self.attach(Label("EndIdx: "),0,1,1,2,0,0)
self.attach(self.endIdx,1,2,1,2,EXPAND|FILL,0)
self.attach(Label("TimeAt0:"),0,1,2,3,0,0)
self.attach(self.timeAt0,1,2,2,3,EXPAND|FILL,0)
self.set_row_spacings(5)
self.value=value
def getValue(self):
ans=Window()
t=self.startIdx.get_text()
if t == '':
ans.startIdx=None
else:
try:
ans.startIdx=Data.compile(self.startIdx.get_text())
except Exception:
msg="Invalid startIdx specified.\n\n%s" % (sys.exc_info(),)
MDSplusErrorMsg('Invalid StartIdx',msg)
raise
t=self.endIdx.get_text()
if t == '':
ans.endIdx=None
else:
try:
ans.endIdx=Data.compile(self.endIdx.get_text())
except Exception:
msg="Invalid endIdx specified.\n\n%s" % (sys.exc_info(),)
MDSplusErrorMsg('Invalid EndIdx',msg)
raise
t=self.timeAt0.get_text()
if t != '':
try:
ans.timeAt0=Data.compile(self.timeAt0.get_text())
except Exception:
msg="Invalid timeAt0 specified.\n\n%s" % (sys.exc_info(),)
MDSplusErrorMsg('Invalid TimeAt0',msg)
raise
return ans
def setValue(self,d):
self._value=d
self.reset()
def reset(self):
if isinstance(self._value,Window):
if self._value.startIdx is None:
self.startIdx.set_text('')
else:
self.startIdx.set_text(self._value.startIdx.decompile())
if self._value.endIdx is None:
self.endIdx.set_text('')
else:
self.endIdx.set_text(self._value.endIdx.decompile())
if self._value.timeAt0 is None:
self.timeAt0.set_text('')
else:
self.timeAt0.set_text(self._value.timeAt0.decompile())
else:
self.startIdx.set_text('')
self.endIdx.set_text('')
self.timeAt0.set_text('')
value=property(getValue,setValue)
def show(self):
old=self.get_no_show_all()
self.set_no_show_all(False)
self.show_all()
self.set_no_show_all(old)