当前位置: 首页>>代码示例>>Python>>正文


Python Entry.get_text方法代码示例

本文整理汇总了Python中gtk.Entry.get_text方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.get_text方法的具体用法?Python Entry.get_text怎么用?Python Entry.get_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gtk.Entry的用法示例。


在下文中一共展示了Entry.get_text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: change_user_dialog

# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import get_text [as 别名]
class change_user_dialog(Dialog):

    def __init__(self, parent, icon):
        Dialog.__init__(self, _("Confirm makepkg as root"),
                        parent, DIALOG_MODAL | DIALOG_DESTROY_WITH_PARENT,
                        (STOCK_OK, RESPONSE_ACCEPT,
                         STOCK_CANCEL, RESPONSE_REJECT))

        self.add_button(_("Run as root"), 1000)
        
        lab = Label(_("Running makepkg as root is a bad idea.\nSelect an alternate user or confirm that you want to run it as root"))

        uname_frame = Frame(_("Username:"))
        pwd_frame = Frame(_("Password"))

        self.uname_entry = Entry()
        
        uname_frame.add(self.uname_entry)
        
        self.vbox.pack_start(lab)
        self.vbox.pack_start(uname_frame)
        self.vbox.show_all()

    def run(self):
        res = Dialog.run(self)
        if res == 1000:
            return "root"
        elif res == RESPONSE_ACCEPT:
            uname = self.uname_entry.get_text()
            return uname
        else:
            self.destroy()
            return "reject"
开发者ID:BackupTheBerlios,项目名称:gtkpacman-svn,代码行数:35,代码来源:dialogs.py

示例2: MDSplusSequentialWidget

# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import get_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,e:
            pass
        ans.phase=self.phase.get_text()
        try:
            ans.phase=Data.compile(ans.phase)
        except Exception,e:
            pass
开发者ID:dgarnier,项目名称:MDSplus-forked,代码行数:33,代码来源:mdsplussequentialwidget.py

示例3: MDSplusWindowWidget

# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import get_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,e:
                msg="Invalid startIdx specified.\n\n%s" % (e,)
                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,e:
                msg="Invalid endIdx specified.\n\n%s" % (e,)
                MDSplusErrorMsg('Invalid EndIdx',msg)
                raise
开发者ID:dgarnier,项目名称:MDSplus-forked,代码行数:40,代码来源:mdspluswindowwidget.py

示例4: MDSplusRangeWidget

# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import get_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,e:
                msg="Invalid begin specified.\n\n%s" % (e,)
                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,e:
                msg="Invalid ending specified.\n\n%s" % (e,)
                MDSplusErrorMsg('Invalid Ending',msg)
                raise
开发者ID:dgarnier,项目名称:MDSplus-forked,代码行数:40,代码来源:mdsplusrangewidget.py

示例5: input_entry_dialog

# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import get_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
开发者ID:paritworkercoop,项目名称:bokeep-mirror,代码行数:16,代码来源:gtkutil.py

示例6: on_add_button_clicked

# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import get_text [as 别名]
 def on_add_button_clicked(self, *args):
     # Ask the user for a new trustor's name.
     md = MessageDialog(parent = self.top_window,
                        type = MESSAGE_QUESTION,
                        buttons = BUTTONS_OK_CANCEL,
                        message_format = "What's the new trustor's name?")
     vbox = md.get_child()
     name_entry = Entry()
     vbox.pack_end(name_entry)
     vbox.show_all()
     r = md.run()
     new_trustor_name = name_entry.get_text()
     md.destroy() # destroys embedded widgets too
     
     # Save the new trustor.
     if r == RESPONSE_OK and new_trustor_name != '':
         self.current_name = new_trustor_name
         self.trust_module.add_trustor_by_name(new_trustor_name)
         transaction.get().commit()
         self.refresh_trustor_list()
开发者ID:paritworkercoop,项目名称:bokeep-mirror,代码行数:22,代码来源:trustor_management.py

示例7: MDSplusMethodWidget

# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import get_text [as 别名]
class MDSplusMethodWidget(Table):

    def __init__(self,value=None):
        super(MDSplusMethodWidget,self).__init__(rows=4,columns=2,homogeneous=False)
        self.device=Entry()
        self.method=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("Device:"),0,1,0,1,0,0)
        self.attach(self.device,1,2,0,1,EXPAND|FILL,0)
        self.attach(Label("Method:"),0,1,1,2,0,0)
        self.attach(self.method,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=Method()
        ans.method=self.method.get_text()
        try:
            ans.method=Data.compile(ans.method)
        except Exception,e:
            pass
        try:
            ans.object=Data.compile(self.device.get_text())
        except Exception,e:
            msg="Invalid device specified.\n\n%s" % (e,)
            MDSplusErrorMsg('Invalid Device',msg)
            raise
开发者ID:dgarnier,项目名称:MDSplus-forked,代码行数:43,代码来源:mdsplusmethodwidget.py

示例8: MDSplusRoutineWidget

# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import get_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,e:
            pass
        ans.routine=self.routine.get_text()
        try:
            ans.routine=Data.compile(ans.routine)
        except Exception,e:
            pass
开发者ID:dgarnier,项目名称:MDSplus-forked,代码行数:42,代码来源:mdsplusroutinewidget.py

示例9: ItemEntry

# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import get_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()
开发者ID:BackupTheBerlios,项目名称:useless-svn,代码行数:26,代码来源:simple.py

示例10: MDSplusSequentialWidget

# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import get_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)
开发者ID:MDSplus,项目名称:Python-TDISHR,代码行数:75,代码来源:mdsplussequentialwidget.py

示例11: MDSplusRoutineWidget

# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import get_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)
#.........这里部分代码省略.........
开发者ID:LucyScott,项目名称:mdsplus,代码行数:103,代码来源:mdsplusroutinewidget.py

示例12: GeoForm

# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import get_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
开发者ID:LinusU,项目名称:geocache,代码行数:65,代码来源:GeoForm.py

示例13: Base

# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import get_text [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
#.........这里部分代码省略.........
开发者ID:pborky,项目名称:pyslides,代码行数:103,代码来源:startslideshow.py

示例14: MDSplusRangeWidget

# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import get_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)
开发者ID:MDSplus,项目名称:Python-TDISHR,代码行数:80,代码来源:mdsplusrangewidget.py

示例15: MDSplusWindowWidget

# 需要导入模块: from gtk import Entry [as 别名]
# 或者: from gtk.Entry import get_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)
开发者ID:LucyScott,项目名称:mdsplus,代码行数:80,代码来源:mdspluswindowwidget.py


注:本文中的gtk.Entry.get_text方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。