當前位置: 首頁>>代碼示例>>Python>>正文


Python Recorder.connect方法代碼示例

本文整理匯總了Python中recorder.Recorder.connect方法的典型用法代碼示例。如果您正苦於以下問題:Python Recorder.connect方法的具體用法?Python Recorder.connect怎麽用?Python Recorder.connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在recorder.Recorder的用法示例。


在下文中一共展示了Recorder.connect方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: RecorderApp

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import connect [as 別名]
class RecorderApp(object):
    def __init__(self):
        gladefile = "main.glade"
        self.windowname = "main"
        
        self.wTree = gtk.glade.XML(gladefile, self.windowname)   

        
        self.wTree.signal_autoconnect(self)

        # load popup
        self.popupEpochTree = gtk.glade.XML(gladefile, "menuPopupEpochs")
        self.popupEpoch = self.popupEpochTree.get_widget("menuPopupEpochs")
        self.popupEpochTree.signal_autoconnect(self)
        self.recorder = Recorder()
        self.setupEpochs()

        # now connect the new-experiment and new-epoch widgets
        self.recorder.connect('experiment-create', self.experimentCreate)
        
        
        self.propertyPanes = {}

        
    def on_menuQuit_activate(self, widget):
        print "QUIT"
        gtk.main_quit()
        
    def on_treeviewExperiments_button_press_event(self, treeview, event):
        if event.button == 3:
            x = int(event.x)
            y = int(event.y)
            time = event.time
            pthinfo = treeview.get_path_at_pos(x, y)
            if pthinfo is not None:
                path, col, cellx, celly = pthinfo
                treeview.grab_focus()
                treeview.set_cursor( path, col, 0)
                self.popupEpoch.popup( None, None, None, event.button, time)
            return 1
    
    def experimentCreate(self, recorder, exp):
        ep = ExperimentProperty(exp)
        exp.connect('epoch-create', self.epochCreate)
        self.propertyPanes[exp] = ep
        
    def epochCreate(self, recorder, epoch):
        print "New epoch", epoch
        ep = EpochProperty(epoch)
        self.propertyPanes[epoch] = ep


    def rowInserted(self, treemodel, path, iter):
        selection = self.treeviewExperiments.get_selection()
        selection.unselect_all()
        
    def setPropertyPane(self):
        box = self.wTree.get_widget("boxProperties")
        try:
            box.remove(box.get_children()[0])
        except:
            pass
        # now put in the correct one,

        selection = self.treeviewExperiments.get_selection()
        (model, iter) = selection.get_selected()
        obj = model.get_value(iter, 0)
        print obj
        pane = self.propertyPanes[obj]
        
        box.add(pane.prop)
        box.show()

    def on_treeviewExperiments_cursor_changed(self, widget):
        print "Cursor changed", widget
        
        self.setPropertyPane()
        
    def setupEpochs(self):
        # pass

        self.treestore = RecorderTreeModel(self.recorder)
        self.treestore.connect('row-inserted', self.rowInserted)
        treeview = self.wTree.get_widget("treeviewExperiments")
        self.treeviewExperiments = treeview
        self.treeviewExperiments.get_selection().set_mode(gtk.SELECTION_SINGLE)
        treeview.set_model(self.treestore)
        
        maincol = gtk.TreeViewColumn("Experiments and Epochs")
        
        cell = gtk.CellRendererText()
        maincol.pack_start(cell, True)
        maincol.add_attribute(cell, "text", 1)
        maincol.add_attribute(cell, "editable", 2)
        cell.connect('edited', self.renameEpoch)

        treeview.append_column(maincol)

        #self.treestore.connect('epoch-created', self.treeModelEpochCreated)

#.........這裏部分代碼省略.........
開發者ID:somaproject,項目名稱:recorder,代碼行數:103,代碼來源:run.py


注:本文中的recorder.Recorder.connect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。