-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunit
More file actions
31 lines (25 loc) · 886 Bytes
/
runit
File metadata and controls
31 lines (25 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
# tkinter implementation of gnome's Alt+F2 run box
from tkinter import *
from tkinter import ttk
from os import system
import sys
root = Tk()
root.title('RUNIT')
def runit(*args):
root.destroy()
system(cmd.get())
mainframe = ttk.Frame(root, padding='3 3 12 12')
mainframe.grid(column=0, row=0, sticky=(N,W,E,S))
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
ttk.Button(mainframe, text='QUIT', command=root.quit).grid(row=1,column=1, sticky=(S,E))
ttk.Button(mainframe, text='OK',command=lambda:runit()).grid(row=1,column=0, sticky=(S,W))
cmd = StringVar()
cmd_entry = ttk.Entry(mainframe, width=10, textvariable=cmd)
cmd_entry.grid(column=0, row=0, columnspan=2)
for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5)
cmd_entry.focus()
root.bind('<Return>',runit)
root.bind('<Escape>',exit)
root.mainloop()