예제 #1
0
 def print_item(event):
     s = lb.get(lb.curselection())
     if isf[0] == TRUE:
         fl.pop()
     fl.append(s)
     p = '\\'.join(fl)
     if findfl.GetFileList(p) != 0:
         if '\\' not in p:
             p += '\\'
         lb.delete(0, END)
         for item in findfl.GetFileList(p):
             lb.insert(END, item)
         lb.bind('<ButtonRelease-1>', print_item)
     else:
         isf[0] = TRUE
     var2.set(p)  # 设置文本框中的值
예제 #2
0
 def goback():
     if isf[0] == TRUE:
         fl.pop()
         isf[0] = FALSE
     if fl:
         fl.pop()
         p = '\\'.join(fl)
         if '\\' not in p:
             p += '\\'
         lb.delete(0, END)
         for item in findfl.GetFileList(p):
             lb.insert(END, item)
         lb.bind('<ButtonRelease-1>', print_item)
         var2.set(p)  # 设置文本框中的值
         if p == '\\':
             lb.delete(0, END)
             for item in list_item:
                 lb.insert(END, item)
             lb.bind('<ButtonRelease-1>', print_item)
         if not fl:
             var2.set(" ")
예제 #3
0
def pro_find_run():
    global p
    root = Tk()
    root.title("file chooser")
    root.geometry("530x340")

    var = StringVar()
    var2 = StringVar()
    fl = []
    isf = [FALSE]

    def print_item(event):
        s = lb.get(lb.curselection())
        print(s)
        if isf[0] == TRUE:
            fl.pop()
        fl.append(s)
        p = '\\'.join(fl)
        if findfl.GetFileList(p) != 0:
            if '\\' not in p:
                p += '\\'
            lb.delete(0, END)
            for item in findfl.GetFileList(p):
                lb.insert(END, item)
            lb.bind('<ButtonRelease-1>', print_item)
        else:
            isf[0] = TRUE
        var2.set(p)  # 设置文本框中的值
        print(p)
        gridtest.file_connect(p)
        return (p)

    lb = Listbox(root, listvariable=var, height=15, width=90)
    list_item = []
    if findfl.GetFileList('c:\\') != 0:
        list_item.append('c:')
    if findfl.GetFileList('d:\\') != 0:
        list_item.append('d:')
    if findfl.GetFileList('e:\\') != 0:
        list_item.append('e:')
    if findfl.GetFileList('f:\\') != 0:
        list_item.append('f:')
    if findfl.GetFileList('g:\\') != 0:
        list_item.append('g:')
    for item in list_item:
        lb.insert(END, item)
    lb.bind('<ButtonRelease-1>', print_item)
    lb.pack()

    e = Entry(root, textvariable=var2, width=90)
    e.pack()  # 这里的side可以赋值为LEFT  RTGHT TOP  BOTTOM

    def ok():
        print("llaaaaaaaaaaaaaaaaaaaaaa")
        s = var2.get()
        print(s)
        #
        #
        #
        # file_connect("findfile open")
        # file_connect("s")
        root.destroy()
        return s
        #break
    def cancel():
        root.destroy()

    def goback():
        if isf[0] == TRUE:
            fl.pop()
            isf[0] = FALSE
        if fl:
            fl.pop()
            p = '\\'.join(fl)
            if '\\' not in p:
                p += '\\'
            lb.delete(0, END)
            for item in findfl.GetFileList(p):
                lb.insert(END, item)
            lb.bind('<ButtonRelease-1>', print_item)
            var2.set(p)  # 设置文本框中的值
            if p == '\\':
                lb.delete(0, END)
                for item in list_item:
                    lb.insert(END, item)
                lb.bind('<ButtonRelease-1>', print_item)
            if not fl:
                var2.set(" ")

    # icon = PhotoImage(file = 'C:\\Users\\yu\\Documents\\workspace\\nasd\\qwr.gif')
    Button(root, text="OK", height=1, width=8, command=ok).pack(side=RIGHT,
                                                                padx=10)
    Button(root, height=1, width=8, text="Cancel",
           command=cancel).pack(side=LEFT, padx=10)
    Button(root, height=1, width=8, text="Last",
           command=goback).pack(side=LEFT)

    root.mainloop()  # 进入消息循环


#pro_find_run()
예제 #4
0
파일: UI2.py 프로젝트: OXVyeah/yayade
    def createFrame(self):
        global mac
        global repo


        label_frame_top = LabelFrame(self)
        # label_frame_top.pack()

        label_frame_center = LabelFrame(self)
        label_frame_center.pack(fill="x")

        lfc_field_1 = LabelFrame(label_frame_center)
        lfc_field_1.pack(fill="x")

        self.lfc_field_1_l = Label(lfc_field_1, text="IP MAC HHHHHHH", width=10)
        self.lfc_field_1_l.pack(fill="x", expand=0, side=TOP)



# -----


        lfc_field_2 = LabelFrame(label_frame_center)
        lfc_field_2.pack(fill="x")

        self.lfc_field_1_l = Label(lfc_field_2, text="KEYBORAD", width=10)

        self.lfc_field_1_l.pack(fill="y", expand=0, side=LEFT)

        ##########文本框与滚动条
        self.lfc_field_1_t_sv = Scrollbar(lfc_field_2, orient=VERTICAL)  # 文本框-竖向滚动条

        self.lfc_field_1_t = Text(lfc_field_2, height=15, yscrollcommand=self.lfc_field_1_t_sv.set,
                                           wrap='c')  # 设置滚动条-不换行

        self.lfc_field_1_t.insert(1.0, keyboard_record(repo,mac))
        # 滚动事件
        self.lfc_field_1_t_sv.config(command=self.lfc_field_1_t.yview)

        # 布局
        self.lfc_field_1_t_sv.pack(fill="y", expand=0, side=RIGHT, anchor=N)
        self.lfc_field_1_t.pack(fill="x", expand=1, side=LEFT)

        # 绑定事件
        self.lfc_field_1_t.bind("<Control-Key-a>", self.selectText)
        self.lfc_field_1_t.bind("<Control-Key-A>", self.selectText)

        ##########文本框与滚动条Tkinker.END


# ------

        lfc_field_3 = LabelFrame(label_frame_center)
        lfc_field_3.pack(fill="x")

        self.lfc_field_1_l = Label(lfc_field_3, text="CHOOSE FILE", width=10)
        self.lfc_field_1_l.pack(fill="y", expand=0, side=LEFT)

        # self.lfc_field_1_b = Button(lfc_field_1, text="清除:", width=10, height=1, command=self.clearText)
        # self.lfc_field_1_b.pack(fill="none", expand=0, side=RIGHT, anchor=SE)

        ##########文本框与滚动条
        self.lfc_field_2_t_sv = Scrollbar(lfc_field_3 )  # 文本框-竖向滚动条 orient=VERTICAL


        ###文本框设置

        var = StringVar()
        var2 = StringVar()
        fl = []
        isf = [FALSE]
        self.lb = Listbox(lfc_field_3, listvariable=var, height=15, width=90)
        list_item = []
        self.lb['yscrollcommand'] = self.lfc_field_2_t_sv.set
        self.lfc_field_2_t_sv['command'] = self.lb.yview



        # 将所有搜索结果替换为海绵的查找函数   搜索的条是点击结果
        def print_item(event):
            self.lb.delete(1,len(list_item))
            var2=StringVar()
           # fl = []	# 作为搜索内容每次都清空
            s = self.lb.get(self.lb.curselection())
            p=s;
            if (p) != 0:
            	del list_item[:]
            	for item in search_file(p):
            		list_item.append(item)
            	
            	for item in list_item:
            		self.lb.insert(END, item)
            	self.lb.bind('<ButtonRelease-1>', print_item)
            else:
            	isf[0] = 1
            var2.set(p)  # 设置文本框中的值
            print list_item
            

        if findfl.GetFileList('c:\\') != 0:
            list_item.append('c:')
        if findfl.GetFileList('d:\\') != 0:
            list_item.append('d:')
        if findfl.GetFileList('e:\\') != 0:
            list_item.append('e:')
        if findfl.GetFileList('f:\\') != 0:
            list_item.append('f:')
        if findfl.GetFileList('g:\\') != 0:
            list_item.append('g:')

        for item in list_item:
            self.lb.insert(-1, item)

        del list_item[:]

        self.lb.bind('<ButtonRelease-1>', print_item)
        self.lb.pack(side = LEFT)

        lfc_field_4 = LabelFrame(label_frame_center)
        lfc_field_4.pack(fill="x")

        self.lfc_field_search = Text(lfc_field_4, height=1, wrap='c')  # 设置滚动条-不换行
        self.lfc_field_search.pack(fill="x", expand=0, side=LEFT)

        # 删除字符串的最后一个字符
        def DelLastChar(str):
            str_list = list(str)
            str_list.pop()
            return "".join(str_list)
        def getFile():
            filename = self.lfc_field_search.get(1.0,END)
            print filename
            print "nnn:",filename
            filename=DelLastChar(filename)
            fff = ""
            for i in filename:
                fff +=i

            fff=str(fff)
            self.downloadFilesFromGit(fff)
            # fff=fff.replace("\\","\\\\")
            # print fff
            # t = threading.Thread(target=self.downloadFilesFromGit, args=(fff))
            # t.start()

        self.lfc_field_search_b = Button(lfc_field_4, text="获得文件", width=10, height=1, command=getFile)
        self.lfc_field_search_b.pack(fill="none", expand=0, side=RIGHT, anchor=SE)


# -----

        lfc_field_5 = LabelFrame(label_frame_center)
        lfc_field_5.pack(fill="x")

        self.lfc_field_1_l = Label(lfc_field_5, text="SHOW SCREENSHOOT", width=40)
        self.lfc_field_1_l.pack(fill="y", expand=0, side=LEFT)

        self.lfc_field_1_b = Button(lfc_field_5, text="刷新", width=10, height=1, command=self.clearText)
        self.lfc_field_1_b.pack(fill="none", expand=0, side=RIGHT, anchor=SE)

        label_frame_bottom = LabelFrame(self)
        # label_frame_bottom.pack()

        pass