Skip to content

Instantly share code, notes, and snippets.

@MattSegal
Last active August 29, 2015 14:27
Show Gist options
  • Save MattSegal/7f72f58f98ce149f92e8 to your computer and use it in GitHub Desktop.
Save MattSegal/7f72f58f98ce149f92e8 to your computer and use it in GitHub Desktop.
"""
Test GUI
"""
from Tkinter import *
import os
import subprocess
def main():
""" starts up GUI """
root = Tk()
root.wm_title("Test GUI")
app = App(root)
root.mainloop()
class App:
def __init__(self,master):
"""
initialises all GUI elements
"""
self.master = master
frame = Frame(master)
frame.grid(row=0)
self.someVar = StringVar()
self.counter = 0
Button(frame,text='Do Stuff',command=self.doStuff,width=10).grid(row=0)
Label(frame,textvariable=self.someVar,relief = SUNKEN,width=10).grid(row=1)
def doStuff(self):
"""
increments and updates counter every 1000ms
"""
self.counter += 1
self.someVar.set(self.counter)
self.master.after(1000, self.doStuff)
# ===== run main ===== #
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment