Skip to content

Instantly share code, notes, and snippets.

@manucabral
Created November 28, 2022 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manucabral/66ebb80712bc05c30233c30e4f501966 to your computer and use it in GitHub Desktop.
Save manucabral/66ebb80712bc05c30233c30e4f501966 to your computer and use it in GitHub Desktop.
test
import tkinter as tk
class Application(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.winfo_toplevel().title('MacroMimo')
self.winfo_toplevel().resizable(False, False)
self.sequences = [
{
'id': 1,
'name': 'abrir chrome 1',
'desc': 'Sequence 1 description',
'duration': '00:00',
},
{
'id': 2,
'name': 'abrir chrome 2',
'desc': 'Sequence 2 description',
'duration': '00:00',
},
{
'id': 3,
'name': 'abrir chrome 3',
'desc': 'Sequence 3 description',
'duration': '00:00',
},
]
self.create_frames()
self.create_widgets()
self.pack()
def create_frames(self):
self.top_frame = tk.Frame(self.master)
self.top_frame.pack(side='top')
self.middle_frame = tk.Frame(self.master)
self.middle_frame.pack(side='top')
self.bottom_frame = tk.Frame(self.master)
self.bottom_frame.pack(side='bottom')
def update_table(self):
print('Update table')
for widget in self.middle_frame.winfo_children():
widget.destroy()
if len(self.sequences) == 0:
return
row = 0
for sequence in self.sequences:
sequence_id = tk.Label(self.middle_frame, text=sequence['id'], width=10, padx=10, pady=10).grid(row=row, column=0)
sequence_name = tk.Label(self.middle_frame, text=sequence['name'], width=16).grid(row=row, column=1)
sequence_desc = tk.Label(self.middle_frame, text=sequence['desc'], width=16).grid(row=row, column=2)
sequence_duration = tk.Label(self.middle_frame, text=sequence['duration'], width=10).grid(row=row, column=3)
sequence_select = tk.Button(self.middle_frame, text='✓', bg='green', fg='white').grid(row=row, column=4)
sequence_config = tk.Button(self.middle_frame, text='⚙', bg='gray', fg='white').grid(row=row, column=5)
sequence_delete = tk.Button(self.middle_frame, text='✖', bg='red', fg='white', command=lambda: self.delete_sequence(sequence)).grid(row=row, column=6)
sequence_info = tk.Button(self.middle_frame, text='🛈', bg='blue', fg='white').grid(row=row, column=7)
row += 1
def delete_sequence(self, sequence):
print('Delete sequence', sequence)
for sequence in self.sequences:
if sequence['id'] == sequence['id']:
self.sequences.remove(sequence)
print(self.sequences)
self.update_table()
def create_widgets(self):
# top buttons
font = ('Arial', 14)
self.play = tk.Button(self.top_frame, text='▶️', command=self.play, width=10, bg='green', fg='white', font=font).grid(row=0, column=0)
self.pause = tk.Button(self.top_frame, text='⏸', command=self.pause, width=10, bg='blue', fg='white', font=font, state='disabled').grid(row=0, column=1)
self.stop = tk.Button(self.top_frame, text='🛑', command=self.stop, width=10, bg='red', fg='white', font=font, state='disabled').grid(row=0, column=2)
self.record_indicator = tk.Label(self.top_frame, text='Not recording', width=10, padx=10, pady=10).grid(row=0, column=5)
# middle buttons
self.update_table()
#self.previous = tk.Button(self.middle_frame, text='Previous', width=10).grid(row=self.rows, column=0)
#self.next = tk.Button(self.middle_frame, text='Next', width=10).grid(row=self.rows, column=1)
# bottom buttons
self.quit = tk.Button(self.bottom_frame, text='Exit', fg='red', width=10, command=self.master.destroy).grid(row=0, column=0)
def play(self):
print('Play')
def pause(self):
print('Pause')
def stop(self):
print('Stop')
root = tk.Tk()
app = Application(master=root)
app.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment