def add_entries(self, entries): if self.inputs is not None: print('warning: there is already one instance of key: value entries in the input frame') return self.inputs = tk_tools.KeyValueEntry(self, keys=entries, on_change_callback=self.start_command) self.add_widget(self.inputs)
def __init__(self, parent, daq): self.parent = parent tk.LabelFrame.__init__(self, self.parent, text='Analog Output') self.daq = daq self.kve = tk_tools.KeyValueEntry(self, ['ao0', 'ao1'], on_change_callback=self.on_change) self.kve.grid()
def __init__(self, parent, daq): self.parent = parent tk.LabelFrame.__init__(self, self.parent, text='Analog Input') self.daq = daq self.kve = tk_tools.KeyValueEntry(self, ['ai0', 'ai1', 'ai2', 'ai3']) self.kve.grid() self.retrieve_all()
def __init__(self, parent, start_command=None, abort_command=None, entries: list=None): self.parent = parent super().__init__(self.parent, text='User Inputs') self.start_command = start_command # create the images and image items for the buttons self.abort_image = tk.PhotoImage(data=btn_abort).subsample(2) self.start_image = tk.PhotoImage(data=btn_start).subsample(2) # create the buttons self.abort_button = tk.Button(self, image=self.abort_image, command=abort_command) self.add_widget(self.abort_button) self.start_button = tk.Button(self, image=self.start_image, command=self.start_command) self.add_widget(self.start_button) if entries is not None: self.inputs = tk_tools.KeyValueEntry(self, keys=entries, on_change_callback=self.start_command) self.add_widget(self.inputs) else: self.inputs = None
import tkinter as tk import tk_tools if __name__ == '__main__': root = tk.Tk() key_value = tk_tools.KeyValueEntry( root, ['key0', 'key1', 'key2'], title='help', unit_labels=['one', 'two', 'three'], defaults=['', 'two', 'three'], enables=[True, False, True], on_change_callback=lambda: print('works')) key_value.pack() key_value.add_row('key3') key_value.add_row('key4', enable=False) key_value.add_row('key5', unit_label='five') key_value.load({ 'key0': '1', 'key1': '2', 'key2': '3', 'key3': '4', 'key4': '5', 'key5': '6' }) root.mainloop()
import tkinter as tk import tk_tools root = tk.Tk() # create the key-value with a title kve0 = tk_tools.KeyValueEntry( root, title='Key/Value 0', keys=['Buckets', 'Dollars', 'Hens'], unit_labels=['buckets', 'dollars', 'hens'], ) kve0.grid(row=0) # create another key-value set without a title and with no units kve1 = tk_tools.KeyValueEntry(root, keys=['Baskets', 'Cows']) kve1.grid(row=1) # create a key-value with some entries disabled, then load values into each kve2 = tk_tools.KeyValueEntry(root, title='Static Key Value', keys=['Buckets', 'Dollars', 'Hens'], unit_labels=['buckets', 'dollars', 'hens'], enables=[False, False, True]) kve2.grid(row=2) kve2.load({'Buckets': 'x', 'Dollars': 'y', 'Hens': 'z'}) def get_values(): print('kve0: {}'.format(kve0.get())) print('kve1: {}'.format(kve1.get()))