Skip to content

Commit

Permalink
log log
Browse files Browse the repository at this point in the history
  • Loading branch information
pussinboot committed Oct 22, 2015
1 parent 8aa7411 commit f0b3990
Showing 1 changed file with 61 additions and 10 deletions.
71 changes: 61 additions & 10 deletions v0.5.0/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
hope is to be able to play back again with or without rearranging
"""
import threading, time
import tkinter as tk
from tkinter import ttk

class PresetLog:
"""
an entire log
"""

def __init__(self):
def __init__(self,title='untitled'):
self.title = title
self.log = []
#self.start_time = time.time()

Expand Down Expand Up @@ -50,11 +53,12 @@ def __init__(self,timestamp,fxn_called=None,args=[],prev_log=None):
self.args = args
if prev_log:
prev_log.link_line(self)
if not fxn_called: # in case of resume event
self.fxn_called = fxn_called
if not self.fxn_called: # in case of resume event
self.time_int = 0
fxn_called = lambda: None
self.fxn_called = lambda: None
def fxn():
fxn_called(*self.args)
self.fxn_called(*self.args)
if self.next_log:
self.next_log.redo()

Expand All @@ -70,6 +74,13 @@ def link_line(self,next_log):
next_log.set_int(self)
self.next_log = next_log

def swap_funcs(self,nother_log):
curargs, curfun = self.args, self.fxn_called
self.args = nother_log.args
self.fxn_called = nother_log.fxn_called
nother_log.args = curargs
nother_log.fxn_called = curfun

def redo(self):
self.timer = threading.Timer(self.time_int,self.fxn)
self.timer.start()
Expand All @@ -79,11 +90,51 @@ def cancel(self):
if self.timer:
self.timer.cancel()

class LogGui:
"""
shows a presetlog and allows 4 manipulation of it
new log items get added to current log and show up as rows in tree
can be dragged up and down to switch what preset when
can be double clicked to change time interval
multiple logs 4 multiple recordings, idk
"""
def __init__(self,master):
self.master = master
self.logs = [PresetLog()]
self.current_log_index = 0
# gui whatever
self.win = tk.Toplevel()
self.mainframe = tk.Frame(self.win)

self.buttonframe = tk.Frame(self.mainframe)
self.playpause = tk.Button(self.buttonframe,text='> ||',width=5)
self.record = tk.Button(self.buttonframe,text='O',width=5)
self.stop = tk.Button(self.buttonframe,text='[ ]',width=5)
self.playpause.pack(side=tk.LEFT)
self.record.pack(side=tk.LEFT)
self.stop.pack()

self.treeframe = tk.Frame(self.mainframe)
self.tree = ttk.Treeview(self.treeframe,selectmode='browse')
self.tree.pack(side=tk.LEFT,anchor=tk.N,fill=tk.BOTH,expand=tk.Y)
self.ysb = ttk.Scrollbar(self.treeframe, orient='vertical', command=self.tree.yview)
self.tree.configure(yscrollcommand=self.ysb.set)
self.ysb.pack(side=tk.RIGHT,anchor=tk.N,fill=tk.Y)
self.buttonframe.pack()
self.treeframe.pack()
self.mainframe.pack()

def main():
root = tk.Tk()
root.wm_state('iconic')
loggui = LogGui(root)
root.mainloop()

if __name__ == '__main__':
# test
logs = [None]*5
logs[0] = LogLine(0,print,'start')
for i in range(1,5):
logs[i] = LogLine(i*1.0,print,[i],logs[i-1])
#
logs[0].redo()
# logs = [None]*5
# logs[0] = LogLine(0,print,'start')
# for i in range(1,5):
# logs[i] = LogLine(i*1.0,print,[i],logs[i-1])
main()
# logs[0].redo()

0 comments on commit f0b3990

Please sign in to comment.