コード例 #1
0
ファイル: editchoice.py プロジェクト: drewp/light9
    def __init__(self, parent, graph, resourceObservable, label="Editing:"):
        """
        getResource is called to get the URI of the currently
        """
        self.graph = graph
        self.frame = tk.Frame(parent, relief='raised', border=2)
        self.frame.pack(side='top')
        tk.Label(self.frame, text=label).pack(side='left')
        self.currentLinkFrame = tk.Frame(self.frame)
        self.currentLinkFrame.pack(side='left')

        self.subIcon = tk.Label(self.currentLinkFrame, text="...",
                                borderwidth=2, relief='raised',
                                padx=10, pady=10)
        self.subIcon.pack()

        self.resourceObservable = resourceObservable
        resourceObservable.subscribe(self.uriChanged)

        # when the value is local, this should stop being a drag source
        dragSourceRegister(self.subIcon, 'copy', 'text/uri-list',
                           self.resourceObservable)
        def onEv(ev):
            self.resourceObservable(URIRef(ev.data))
            return "link"
        self.onEv = onEv

        b=tk.Button(self.frame, text="Unlink", command=self.switchToLocalSub)
        b.pack(side='left')

        # it would be nice if I didn't receive my own drags here, and
        # if the hover display wasn't per widget
        for target in ([self.frame, self.currentLinkFrame] +
                       self.frame.winfo_children() +
                       self.currentLinkFrame.winfo_children()):
            dropTargetRegister(target, typeList=["*"], onDrop=onEv,
                               hoverStyle=dict(background="#555500"))
コード例 #2
0
ファイル: tkdnd_minimal_drop.py プロジェクト: drewp/light9

def onDrop(ev):
    print "onDrop", ev


def enter(ev):
    print "enter", ev


def leave(ev):
    print "leave", ev


dropTargetRegister(
    label, onDrop=onDrop, onDropEnter=enter, onDropLeave=leave, hoverStyle=dict(background="yellow", relief="groove")
)

dropTargetRegister(
    labelInner,
    onDrop=onDrop,
    onDropEnter=enter,
    onDropLeave=leave,
    hoverStyle=dict(background="yellow", relief="groove"),
)


def prn():
    print "cont", root.winfo_containing(201, 151)