Erster Testcode
This commit is contained in:
commit
d10715c81f
10
README.md
Normal file
10
README.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Programm-Öffner
|
||||
|
||||
## Beschreibung
|
||||
Programm-Öffner ist ein einfaches Python-Projekt, das als Test für ein Shortcut-Programm dient. Mit dieser Anwendung kannst du "schnell" installierte Programme auf deinem Computer öffnen.
|
||||
|
||||
## Funktionen
|
||||
- Öffnen von installierten Programmen über einen Shortcut.
|
||||
|
||||
## Anforderungen
|
||||
- Python 3.x
|
14
program_list.json
Normal file
14
program_list.json
Normal file
@ -0,0 +1,14 @@
|
||||
[
|
||||
{
|
||||
"Name": "Crunchyroll Downloader",
|
||||
"Pfad": "C:\\Users\\Akamaru\\AppData\\Local\\Programs\\crunchyroll-downloader\\Crunchyroll Downloader.exe"
|
||||
},
|
||||
{
|
||||
"Name": "clrmamepro",
|
||||
"Pfad": "D:\\Portable\\clrmamepro\\cmpro64.exe"
|
||||
},
|
||||
{
|
||||
"Name": "Programm 3",
|
||||
"Pfad": "E:\\Pfad\\zum\\Programm3.exe"
|
||||
}
|
||||
]
|
43
run.py
Normal file
43
run.py
Normal file
@ -0,0 +1,43 @@
|
||||
import tkinter as tk
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
def open_program(program_path):
|
||||
print(f"Attempting to open: {program_path}")
|
||||
subprocess.Popen(program_path)
|
||||
|
||||
def load_programs():
|
||||
with open('program_list.json') as f:
|
||||
data = json.load(f)
|
||||
return data
|
||||
|
||||
def program_clicked(program_path):
|
||||
open_program(program_path)
|
||||
|
||||
def populate_listbox(programs):
|
||||
for program in programs:
|
||||
program_name = program['Name']
|
||||
program_path = program['Pfad']
|
||||
listbox.insert(tk.END, program_name)
|
||||
listbox.bind('<<ListboxSelect>>', on_select)
|
||||
|
||||
def on_select(event):
|
||||
index = listbox.curselection()[0]
|
||||
selected_program = programs[index]
|
||||
program_clicked(selected_program['Pfad'])
|
||||
|
||||
# Erstelle das Hauptfenster
|
||||
root = tk.Tk()
|
||||
|
||||
# Erstelle eine Listbox
|
||||
listbox = tk.Listbox(root)
|
||||
listbox.pack()
|
||||
|
||||
# Lade die Programme aus der JSON-Datei
|
||||
programs = load_programs()
|
||||
|
||||
# Fülle die Listbox mit den Programmen
|
||||
populate_listbox(programs)
|
||||
|
||||
# Starte die GUI-Schleife
|
||||
root.mainloop()
|
Loading…
Reference in New Issue
Block a user