ArticleThe name is used to make good use of the software. everything is a quick search tool for Windows. it is basically not used in Linux. I have been using gnome-do, and I feel it is okay. thisProgramIt is only used to practice wxpython. Currently, it is only a very simple version. of course, the backend uses mlocate. in Linux, the search principle is basically the same as that in everything, but the command line is used. I just wrote a front-end GUI.
Below is the preliminaryCode.
1 # /Usr/bin/Python 2 # -*-<Coding = UTF-8> -*- 3 4 """ 5 This example shows the Linux version of the Everything program in Windows. The backend is implemented based on locate. 6 """ 7 8 Import WX 9 Import OS 10 Import Subprocess 11 12 Class Guimainframe (wx. Frame ): 13 14 Def _ Init __ (Self ): 15 Wx. Frame. _ Init __ (Self, parent = none, id =-1, Title = "" , Pos = wx. defaultposition, size = Wx. defaultsize) 16 17 # Add a panel. 18 Panel = Wx. Panel (Self) 19 20 # Create menu bar 21 Menubar = Wx. menubar () 22 23 # File menu 24 Filemenu = Wx. menu () 25 Filemenu. append (-1, " & Open " , "" ) 26 Menubar. append (filemenu, " & File " ) 27 28 # Edit menu 29 Editmenu = Wx. menu () 30 Editmenu. append (-1, " & Copy " , "" ) 31 Menubar. append (editmenu, " & Edit " ) 32 33 # Help/about menu 34 Helpmenu = Wx. menu () 35 Helpmenu. append (-1, " About " , "" ) 36 Menubar. append (helpmenu, " & Help " ) 37 38 # Call setmenubar to display it in the Framework. 39 Self. setmenubar (menubar) 40 41 # Add search input box in panel 42 # Filterinput = wx. textctrl (panel,-1 ,"") 43 Self. Filter = wx. searchctrl (panel, style = Wx. te_process_enter) 44 Self. Filter. BIND (wx. evt_text_enter, self. dosearch) 45 # Self. Filter. BIND (wx. evt_text, self. dosearch )#This will cause the program to fail to respond for a long time, so we are still looking for a more efficient method.. 46 47 # Add a Type Selection box to the Panel 48 Typelist = [ " ALL :*.* " , " Document: *. Doc, *. xls, *. ppt " , " Audio: *. MP3 " , " Vedio: *. rmvb, *. MKV " , " Application: *. exe " ] 49 Filetype = wx. ComboBox (panel,-1, "" , Choices = Typelist) 50 51 # Add an output result display box to the Panel 52 Self. multitext = wx. textctrl (panel,-1, "" , Style = wx. te_multiline | Wx. te_process_enter) 53 Self. multitext. setminsize (800,600) )) 54 55 # Add the status bar and whether to add it to sizer for management. 56 Statusbar = Self. createstatusbar () 57 58 # Management Layout. Create two sizer, the primary sizer manages filtersizer, and the result display box contains two controls. 59 # Filtersizer management query input box and Type Selection box 60 Mainsizer = Wx. boxsizer (wx. Vertical) 61 62 Filtersizer = wx. gridsizer (rows = 1, cols = 2 ) 63 Filtersizer. Add (self. filter, 0, wx. Expand) 64 Filtersizer. Add (filetype, 0, wx. Expand) 65 66 # This sentence leads to gaps in the text box. Why cannot it be used like this? Does menubar need to be added to mainsizer? 67 # Mainsizer. Add (menubar) 68 Mainsizer. Add (filtersizer, 0, wx. Expand) 69 Mainsizer. Add (self. multitext, 2, wx. Expand | Wx. All) 70 # Statusbar created in the frame, which does not need to be added to sizer for management. 71 # Mainsizer. Add (statusbar, 0, wx. Expand) 72 73 # This is the key to associating sizer with frame. 74 Panel. setsizer (mainsizer) 75 Mainsizer. Fit (Self) 76 77 Def Dosearch (self, event ): 78 Pattern = Self. Filter. getvalue () 79 Print Pattern 80 Cmd = " /Usr/bin/locate " 81 Arg1 = " -I " 82 Arg2 = " -D " 83 Arg3 = " /Var/lib/mlocate. DB " 84 Arg4 = Pattern 85 86 P1 = subprocess. popen ([cmd, arg1, arg2, arg3, arg4], shell = false, stdout = subprocess. Pipe, stderr = Subprocess. Pipe) 87 (Stdoutdata, stderrdata) = P1.communicate () 88 # Stdoutdata = "just test" 89 Self. multitext. setvalue (stdoutdata) 90 91 If _ Name __ = " _ Main __ " : 92 APP = Wx. pysimpleapp () 93 Frame =Guimainframe () 94 Frame. Show () 95 App. mainloop ()