Last active
December 31, 2015 13:09
-
-
Save vovkkk/7990530 to your computer and use it in GitHub Desktop.
Simple skeleton to create launcher with buttons from tuple of tuples `self.cmds_to_launch`:
first element ('bla') is label text to display on button;
second element ('some command') is actual command to run when corresponding button pressed. Note that `self.cmds_to_launch` may contain any amount of tuples, provide no scrolling though.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python | |
# coding=utf-8 | |
import Tkinter as tk | |
import ttk, subprocess | |
class Launcher(tk.Tk): | |
def __init__(self): | |
tk.Tk.__init__(self) | |
self.geometry("-0+30") | |
self.cmds_to_launch = ( | |
('bla1', 'some command 1'), | |
('bla2', 'some command 2'), | |
('bla3', 'some command 3'), | |
('blaETC', 'some command ETC') | |
) | |
self.createWidgets() | |
def createWidgets(self): | |
for i, c in enumerate(self.cmds_to_launch): | |
vars(self)['b'+str(i)] = ttk.Button(text=c[0], command=lambda i=c[1]: subprocess.Popen(i), width=20).pack(anchor='n', expand='yes', fill='x', side='top') | |
if __name__ == "__main__": | |
Launcher().mainloop() |
Author
vovkkk
commented
Dec 16, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment