Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # !/usr/bin/env python3
- # -*- coding: utf-8 -*-
- #
- # Doc Holliday's Specialized medical bag
- # what I'm trying to do is make a multi application launcher
- # to help neaten up my desktop.
- import subprocess, sys
- from tkinter import *
- PROGRAMS = (
- (r"C:\eclipse\eclipse.exe", "Eclipse (Java)"), # ... is for fussies
- (r"C:\Program Files (x86)\Lua\5.1\lua.exe", "Lua"),
- (r"C:\Program Files (x86)\Notepad++\notepad++.exe", "Notepad++"),
- (r"C:\Program Files (x86)\Filezilla\filezilla.exe", "Filezilla"),
- (r"C:\Program Files (x86)\Lua\5.1\SciTE\SciTE.exe", "Scintilla"),
- (r"C:\Users\Bryan\Documents\My Games\metapad36\metapad.exe", "Metapad"),
- (r"C:\Dev-Cpp\devcpp.exe", "Dev-C++"),
- )
- class AppLauncher(Frame):
- def __init__(self, parent):
- Frame.__init__(self, parent)
- self.parent = parent
- self.initialize()
- def initialize(self):
- # Don't do this - grid doesn't play well with pack, and we don't want
- # to assume
- #~ self.grid()
- for i, progPair in enumerate(PROGRAMS):
- program, name = progPair
- tmpBtn = Button(self, text=name, border=4, command=(lambda prog=program: self.openProg(prog) ) )
- tmpBtn.grid(row=i//3, column=i%3, padx=1, pady=1, sticky="NSEW")
- def openProg(self, prog):
- print("Opening \"{}\"".format(prog))
- try:
- subprocess.call([prog])
- except OSError as e:
- reason = e.args[1]
- if "No such" in reason:
- print("ERROR: \"{}\" doesn't exist".format(prog), file=sys.stderr)
- if __name__ == "__main__":
- root = Tk()
- root.title("Doc Holliday's Medical Bag")
- root.resizable(False, False)
- app = AppLauncher(root)
- app.grid(sticky="NSEW")
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement