Desarrollo de herramientas de utilidad Python: Pyqt/PySide6 crea una herramienta de búsqueda de archivos para encontrar "materiales de aprendizaje" en la computadora, que puede denominarse una "versión de gama baja de Everything" (código fuente adjunto)

Tabla de contenido

 

prefacio

1. Introducción e instalación de pyqt/pyside6

2. Ejecute la interfaz y el código de la interfaz UI

3. Tutorial de descarga y uso de recursos.

4. Resumen


prefacio

No hace mucho, publiqué un artículo sobre optimización de computadoras y recomendaciones de software (los amigos interesados ​​pueden leer el artículo). Hay un software que me impresionó mucho, y ese es el artefacto de búsqueda de archivos: Todo. La velocidad de búsqueda Está en el nivel de milisegundos y el software ocupa poca memoria, comparado con el motor de búsqueda que viene con win10, es realmente diferente. Recientemente estuve estudiando GUI (interfaz gráfica de usuario). Como estudiante de Python, realmente quiero copiar este software, por lo que actuar es peor que pensar...

[Colección recomendada] Optimización del sistema Windows 10/11 para computadora nueva, especificaciones de uso y consejos y recomendaciones de software para mejorar el rendimiento y la experiencia de la computadora_import _este blog - blog de CSDN Optimización del sistema Windows 10/11 para computadora nueva, especificaciones de uso y consejos y recomendaciones de software para mejorar la computadora rendimiento y experiencia. Si lo encuentra útil, dale Me gusta o síguelo. Gracias por mirar https://blog.csdn.net/python_sy/article/details/127268101


1. Introducción e instalación de pyqt/pyside6

Si aún no ha instalado pyside6, puede leer el siguiente artículo:

Introducción a Pyqt/PySide6 y método de instalación PySide6 y PyQt5 se basan en la biblioteca Qt. Existe una biblioteca de desarrollo de interfaz gráfica muy poderosa en la biblioteca Qt, pero la biblioteca Qt está desarrollada en lenguaje C ++. PySide2, PySide6 y PyQt5 nos permiten usar Qt a través del lenguaje Python https://blog.csdn.net/python_sy /artículo/detalles/ 127425142


2. Ejecute la interfaz y el código de la interfaz UI

Interfaz de ejecución:

294efd205c7f493f974347046328fe16.png

Interfaz de finalización de búsqueda:

21fa0341459a409686aace896cf4c7f6.png

 Hay muchas funciones que puedes explorar tú mismo (porque se llama la versión de gama baja de Everything, la llamé Anything jeje ~)

Código de interfaz de usuario:

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>760</width>
    <height>594</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>Anything</string>
  </property>
  <property name="windowIcon">
   <iconset>
    <normaloff>icons/icon.png</normaloff>icons/icon.png</iconset>
  </property>
  <property name="styleSheet">
   <string notr="true">QTreeView {
	border:none
}
</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <layout class="QVBoxLayout" name="verticalLayout_3">
    <property name="spacing">
     <number>0</number>
    </property>
    <property name="leftMargin">
     <number>0</number>
    </property>
    <property name="topMargin">
     <number>0</number>
    </property>
    <property name="rightMargin">
     <number>0</number>
    </property>
    <property name="bottomMargin">
     <number>0</number>
    </property>
    <item>
     <layout class="QVBoxLayout" name="verticalLayout_2">
      <item>
       <spacer name="verticalSpacer_2">
        <property name="orientation">
         <enum>Qt::Vertical</enum>
        </property>
        <property name="sizeType">
         <enum>QSizePolicy::Fixed</enum>
        </property>
        <property name="sizeHint" stdset="0">
         <size>
          <width>20</width>
          <height>10</height>
         </size>
        </property>
       </spacer>
      </item>
      <item>
       <layout class="QHBoxLayout" name="horizontalLayout">
        <item>
         <spacer name="horizontalSpacer">
          <property name="orientation">
           <enum>Qt::Horizontal</enum>
          </property>
          <property name="sizeType">
           <enum>QSizePolicy::Fixed</enum>
          </property>
          <property name="sizeHint" stdset="0">
           <size>
            <width>10</width>
            <height>20</height>
           </size>
          </property>
         </spacer>
        </item>
        <item>
         <widget class="QGroupBox" name="groupBox">
          <property name="enabled">
           <bool>true</bool>
          </property>
          <property name="font">
           <font>
            <stylestrategy>PreferDefault</stylestrategy>
           </font>
          </property>
          <property name="mouseTracking">
           <bool>false</bool>
          </property>
          <property name="tabletTracking">
           <bool>false</bool>
          </property>
          <property name="contextMenuPolicy">
           <enum>Qt::DefaultContextMenu</enum>
          </property>
          <property name="accessibleName">
           <string/>
          </property>
          <property name="layoutDirection">
           <enum>Qt::LeftToRight</enum>
          </property>
          <property name="autoFillBackground">
           <bool>false</bool>
          </property>
          <property name="title">
           <string>填写内容后点击开始搜索</string>
          </property>
          <property name="alignment">
           <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
          </property>
          <property name="flat">
           <bool>false</bool>
          </property>
          <layout class="QVBoxLayout" name="verticalLayout">
           <item>
            <layout class="QGridLayout" name="gridLayout">
             <item row="0" column="1">
              <widget class="QLineEdit" name="upLineEdit">
               <property name="placeholderText">
                <string>请输入文件路径(默认C:/)</string>
               </property>
              </widget>
             </item>
             <item row="1" column="1">
              <widget class="QLineEdit" name="downLineEdit">
               <property name="placeholderText">
                <string>请输入文件类型,列如exe</string>
               </property>
              </widget>
             </item>
             <item row="1" column="0">
              <widget class="QLabel" name="downLabel">
               <property name="font">
                <font>
                 <family>微软雅黑</family>
                 <pointsize>11</pointsize>
                 <bold>true</bold>
                </font>
               </property>
               <property name="text">
                <string>类型:</string>
               </property>
              </widget>
             </item>
             <item row="0" column="0">
              <widget class="QLabel" name="upLabel">
               <property name="font">
                <font>
                 <family>微软雅黑</family>
                 <pointsize>11</pointsize>
                 <bold>true</bold>
                </font>
               </property>
               <property name="text">
                <string>路径:</string>
               </property>
              </widget>
             </item>
             <item row="1" column="2">
              <widget class="QPushButton" name="searchButton">
               <property name="text">
                <string>开始搜索</string>
               </property>
              </widget>
             </item>
             <item row="0" column="2">
              <widget class="QPushButton" name="browseButton">
               <property name="text">
                <string>选择文件夹</string>
               </property>
              </widget>
             </item>
            </layout>
           </item>
          </layout>
         </widget>
        </item>
        <item>
         <spacer name="horizontalSpacer_2">
          <property name="orientation">
           <enum>Qt::Horizontal</enum>
          </property>
          <property name="sizeType">
           <enum>QSizePolicy::Fixed</enum>
          </property>
          <property name="sizeHint" stdset="0">
           <size>
            <width>10</width>
            <height>20</height>
           </size>
          </property>
         </spacer>
        </item>
       </layout>
      </item>
      <item>
       <spacer name="verticalSpacer">
        <property name="orientation">
         <enum>Qt::Vertical</enum>
        </property>
        <property name="sizeType">
         <enum>QSizePolicy::Fixed</enum>
        </property>
        <property name="sizeHint" stdset="0">
         <size>
          <width>20</width>
          <height>20</height>
         </size>
        </property>
       </spacer>
      </item>
      <item>
       <widget class="Line" name="line">
        <property name="orientation">
         <enum>Qt::Horizontal</enum>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QTreeWidget" name="outputTreeWidget">
        <property name="enabled">
         <bool>true</bool>
        </property>
        <property name="sizeAdjustPolicy">
         <enum>QAbstractScrollArea::AdjustIgnored</enum>
        </property>
        <property name="showDropIndicator" stdset="0">
         <bool>true</bool>
        </property>
        <property name="indentation">
         <number>20</number>
        </property>
        <property name="rootIsDecorated">
         <bool>false</bool>
        </property>
        <property name="uniformRowHeights">
         <bool>false</bool>
        </property>
        <property name="itemsExpandable">
         <bool>true</bool>
        </property>
        <property name="sortingEnabled">
         <bool>false</bool>
        </property>
        <property name="animated">
         <bool>false</bool>
        </property>
        <property name="allColumnsShowFocus">
         <bool>false</bool>
        </property>
        <property name="headerHidden">
         <bool>false</bool>
        </property>
        <property name="expandsOnDoubleClick">
         <bool>true</bool>
        </property>
        <property name="columnCount">
         <number>5</number>
        </property>
        <attribute name="headerVisible">
         <bool>true</bool>
        </attribute>
        <attribute name="headerCascadingSectionResizes">
         <bool>false</bool>
        </attribute>
        <attribute name="headerMinimumSectionSize">
         <number>25</number>
        </attribute>
        <attribute name="headerDefaultSectionSize">
         <number>100</number>
        </attribute>
        <attribute name="headerHighlightSections">
         <bool>false</bool>
        </attribute>
        <column>
         <property name="text">
          <string>名称</string>
         </property>
         <property name="textAlignment">
          <set>AlignLeading|AlignVCenter</set>
         </property>
        </column>
        <column>
         <property name="text">
          <string>类型</string>
         </property>
         <property name="textAlignment">
          <set>AlignLeading|AlignVCenter</set>
         </property>
        </column>
        <column>
         <property name="text">
          <string>大小</string>
         </property>
         <property name="textAlignment">
          <set>AlignTrailing|AlignVCenter</set>
         </property>
        </column>
        <column>
         <property name="text">
          <string>修改时间</string>
         </property>
         <property name="textAlignment">
          <set>AlignCenter</set>
         </property>
        </column>
        <column>
         <property name="text">
          <string>路径</string>
         </property>
        </column>
       </widget>
      </item>
     </layout>
    </item>
   </layout>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
  <widget class="QMenuBar" name="menuBar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>760</width>
     <height>22</height>
    </rect>
   </property>
   <widget class="QMenu" name="searchMenu">
    <property name="title">
     <string>搜索(&amp;S)</string>
    </property>
    <addaction name="actionSearchType"/>
    <addaction name="actionSearchName"/>
    <addaction name="actionSearchWeb"/>
    <addaction name="actionSearchKey"/>
   </widget>
   <widget class="QMenu" name="toolsMenu">
    <property name="title">
     <string>工具(&amp;T)</string>
    </property>
    <addaction name="actionTextViewer"/>
    <addaction name="actionPlayerViewer"/>
    <addaction name="actionImageViewer"/>
   </widget>
   <widget class="QMenu" name="helpMenu">
    <property name="title">
     <string>帮助(&amp;H)</string>
    </property>
    <addaction name="actionHelp"/>
   </widget>
   <widget class="QMenu" name="aboutMenu">
    <property name="title">
     <string>关于(&amp;A)</string>
    </property>
    <addaction name="actionAbout"/>
   </widget>
   <addaction name="searchMenu"/>
   <addaction name="toolsMenu"/>
   <addaction name="helpMenu"/>
   <addaction name="aboutMenu"/>
  </widget>
  <action name="actionAbout">
   <property name="text">
    <string>关于作者</string>
   </property>
   <property name="shortcut">
    <string>Ctrl+Shift+A</string>
   </property>
  </action>
  <action name="actionHelp">
   <property name="text">
    <string>查看用法</string>
   </property>
   <property name="shortcut">
    <string>Ctrl+H</string>
   </property>
  </action>
  <action name="actionSearchType">
   <property name="icon">
    <iconset>
     <normaloff>icons/radio-circle-marked.png</normaloff>icons/radio-circle-marked.png</iconset>
   </property>
   <property name="text">
    <string>类型搜索</string>
   </property>
  </action>
  <action name="actionSearchName">
   <property name="icon">
    <iconset>
     <normaloff>icons/radio-circle.png</normaloff>icons/radio-circle.png</iconset>
   </property>
   <property name="text">
    <string>名称搜索</string>
   </property>
  </action>
  <action name="actionTextViewer">
   <property name="text">
    <string>文本查看器</string>
   </property>
  </action>
  <action name="actionPlayerViewer">
   <property name="text">
    <string>音频播放器</string>
   </property>
  </action>
  <action name="actionImageViewer">
   <property name="text">
    <string>图像查看器</string>
   </property>
  </action>
  <action name="actionSearchWeb">
   <property name="icon">
    <iconset>
     <normaloff>icons/radio-circle.png</normaloff>icons/radio-circle.png</iconset>
   </property>
   <property name="text">
    <string>Web搜索</string>
   </property>
  </action>
  <action name="actionSearchKey">
   <property name="icon">
    <iconset>
     <normaloff>icons/radio-circle.png</normaloff>icons/radio-circle.png</iconset>
   </property>
   <property name="text">
    <string>文件关键字搜索</string>
   </property>
  </action>
 </widget>
 <resources/>
 <connections/>
</ui>


3. Tutorial de descarga y uso de recursos.

El tutorial de uso está en el software, ¡descárgalo y echa un vistazo!

Recursos relacionados: https://download.csdn.net/download/python_sy/86801488


4. Resumen

¡En este punto, el subprograma de búsqueda de archivos finalmente está completo!
Además, si encuentra algún problema al utilizar este código, puede enviarme sus comentarios.

Gracias a todos por su apoyo y visualización. Si les gusta si lo ven aquí, síganlo ^_^. ¡Su apoyo es mi mayor motivación para actualizar!

Supongo que te gusta

Origin blog.csdn.net/python_sy/article/details/127424641
Recomendado
Clasificación