Construir um aplicativo para pesquisar aplicativos instalados usando Python
Pré-requisito - Tkinter em Python .
Neste artigo, vamos escrever scripts Python para procurar um aplicativo instalado no Windows e vinculá-lo ao aplicativo GUI. Estamos usando winapps módulos para gerenciar aplicativos instalados no Windows.
Para instalar o módulo, execute este comando em seu terminal:
pip install winapps
Métodos usados do módulo winapps
Para imprimir os aplicativos instalados, o módulo winapps possui o método winapps.list_installed() . T
import
winapps
for
item
in
winapps.list_installed():
(item)
Resultado:
InstalledApplication (name = 'Mi Smart Share', version = '1.0.0.452 ′, install_date = None, install_location = None, install_source = None, modify_path = None, publisher =' Xiaomi Inc. ', uninstall_string =' C: \\ Programa Arquivos \\ MI \\ AIoT \\ MiShare \\ 1.0.0.452 \\ Uninstall.exe ')
InstalledApplication (name = 'Git versão 2.27.0 ′, version =' 2.27.0 ′, install_date = datetime.date (2020, 7, 22), install_location = WindowsPath ('D: / Installation_bulk / Git'), install_source = None , modify_path = None, publisher = 'The Git Development Community', uninstall_string = '”D: \\ Installation_bulk \\ Git \\ unins000.exe”')
InstalledApplication (name = 'Microsoft 365 - en-us', version = '16 .0.13127.20408 ′, install_date = None, install_location = WindowsPath ('C: / Program Files / Microsoft Office'), install_source = None, modify_path = '”C : \\ Arquivos de programas \\ Arquivos comuns \\ Microsoft Shared \\ ClickToRun \\ OfficeClickToRun.exe ”cenário = plataforma de reparo = x64 cultura = en-us ', publisher =' Microsoft Corporation ', uninstall_string ='” C: \\ Arquivos de programas \\ Arquivos comuns \\ Microsoft Shared \\ ClickToRun \\ OfficeClickToRun.exe ”scenery = install cenáriosubtype = ARP sourcetype = Nenhum productstoremove = O365HomePremRetail.16_en-us_x-none culture = en-us version.16 = 16.0 ′)
InstalledApplication (name = 'On Screen Display Utility', version = '1.0.0.140 ′, install_date = None, install_location = None, install_source = None, modify_path = None, publisher =' Xiaomi Inc. ', uninstall_string =' C: \\ Arquivos de programa \\ MI \\ OSD Utility \\ 1.0.0.140 \\ Uninstall.exe ')
InstalledApplication (name = 'Intel (R) Management Engine Components', version = '1921.14.0.1280 ′, install_date = None, install_location = WindowsPath (' C: / Program Files (x86) / Intel / Intel (R) Management Engine Components ' ), install_source = None, modify_path = None, publisher = 'Intel Corporation', uninstall_string = '”C: \\ ProgramData \\ Intel \\ Package Cache \\ {1CEAC85D-2590-4760-800F-8DE5E91F3700} \\ Setup. exe ”-desinstalar ')
………
Para pesquisar os aplicativos existentes, o módulo possui o método search_installed ('App_name') .
for
item
in
winapps.search_installed(
'chrome'
):
(item)
Resultado:
InstalledApplication (name = 'Google Chrome', version = '85 .0.4183.102 ′, install_date = datetime.date (2020, 9, 11),
install_location = WindowsPath ('C: / Program Files (x86) / Google / Chrome / Application' ), install_source = None,
modify_path = None, publisher = 'Google LLC', uninstall_string = '
“C: \\ Arquivos de programas (x86) \\ Google \\ Chrome \\ Application \\ 85.0.4183.102 \\ Installer \\ setup .exe ”
–uninstall –system-level –verbose-logging ')
Pesquisando aplicativo em windows usando Tkinter
from
tkinter
import
*
import
winapps
def
app():
for
item
in
winapps.search_installed(e.get()):
name.
set
(item.name)
version.
set
(item.version)
Install_date.
set
(item.install_date)
publisher.
set
(item.publisher)
uninstall_string.
set
(item.uninstall_string)
master
=
Tk()
master.configure(bg
=
'light grey'
)
name
=
StringVar()
version
=
StringVar()
Install_date
=
StringVar()
publisher
=
StringVar()
uninstall_string
=
StringVar()
Label(master, text
=
"Enter App name : "
,
bg
=
"light grey"
).grid(row
=
0
, sticky
=
W)
Label(master, text
=
"Name : "
,
bg
=
"light grey"
).grid(row
=
2
, sticky
=
W)
Label(master, text
=
"Version :"
,
bg
=
"light grey"
).grid(row
=
3
, sticky
=
W)
Label(master, text
=
"Install date :"
,
bg
=
"light grey"
).grid(row
=
4
, sticky
=
W)
Label(master, text
=
"publisher :"
,
bg
=
"light grey"
).grid(row
=
5
, sticky
=
W)
Label(master, text
=
"Uninstall string :"
,
bg
=
"light grey"
).grid(row
=
6
, sticky
=
W)
Label(master, text
=
"", textvariable
=
name,
bg
=
"light grey"
).grid(row
=
2
, column
=
1
, sticky
=
W)
Label(master, text
=
"", textvariable
=
version,
bg
=
"light grey"
).grid(row
=
3
, column
=
1
, sticky
=
W)
Label(master, text
=
"", textvariable
=
Install_date,
bg
=
"light grey"
).grid(row
=
4
, column
=
1
, sticky
=
W)
Label(master, text
=
"", textvariable
=
publisher,
bg
=
"light grey"
).grid(row
=
5
, column
=
1
, sticky
=
W)
Label(master, text
=
"", textvariable
=
uninstall_string,
bg
=
"light grey"
).grid(row
=
6
, column
=
1
, sticky
=
W)
e
=
Entry(master, width
=
30
)
e.grid(row
=
0
, column
=
1
)
b
=
Button(master, text
=
"Show"
, command
=
app, bg
=
"Blue"
)
b.grid(row
=
0
, column
=
2
, columnspan
=
2
, rowspan
=
2
, padx
=
5
, pady
=
5
,)
mainloop()
Resultado:
As postagens do blog Acervo Lima te ajudaram? Nos ajude a manter o blog no ar!
Faça uma doação para manter o blog funcionando.
70% das doações são no valor de R$ 5,00...
Diógenes Lima da Silva