Beispiel #1
0
import memtkinter as tk
from memtkinter.megawidgets import LiveLogger

if __name__ == '__main__':
	def normal():
		print('normal text\n')
		
	def special():
		logger.write('special\n', 'special text')
		
	def error():
		a = b
		
	root = tk.Tk(keytype=tk.HKCU, filepath='./livelogpath', name='Software\\livelogapp')
	
	tk.Button(root, text='normal', command=normal).pack()
	tk.Button(root, text='special', command=special).pack()
	tk.Button(root, text='error', command=error).pack()
	
	logger = LiveLogger(root, 'livelogger')
	
	logger.add_stream('special', None, {'foreground':'green'})
	root.mainloop()
Beispiel #2
0
import memtkinter as tk
from memtkinter.megawidgets import Listbox

if __name__ == '__main__':
    root = tk.Tk(tk.HKCU, './test.xml', 'test')
    l = Listbox(root, scrollbars='auto')
    l.pack(fill='both', expand=True)
    for i in range(0, 10):
        l.insert(tk.END, 'item %i' % i)
    root.mainloop()
Beispiel #3
0
		headings = ['Name', 'Type', 'Value']
		self.tree = ttk.Treeview(self, columns=headings)
		self.tree.heading('#0', text='Node')
		for heading in headings:
			self.tree.heading(headings.index(heading), text=heading)
		self.tree.pack(fill=tk.BOTH, expand=True)
		ttk.Button(self, text='Refresh', command=self.refresh).pack(fill='x')
		
		self.refresh()
		
	def add_node(self, parent, node):
		p = self.tree.insert(parent, 0, text=node._name, open=True)
		for key in node._keywords:
			val = getattr(node, key)
			self.tree.insert(p, 'end', values=[key, repr(type(val)), repr(val)])
		for child in node.children:
			if node[child] != self.settings:
				self.add_node(p, node[child])
				
	def refresh(self):
		for item in self.tree.get_children():
			self.tree.delete(item)
		self.add_node('', self.settings_root)
		
if __name__ == '__main__':
	root = tk.Tk(None, './test.xml', 'test')
	
	sv = SettingsViewer(root)
	
	root.mainloop()
Beispiel #4
0
        ttk.Button.__init__(self, master, **kw)

    def choosecolour(self):
        '''
		invoked when button pushed to prompt user to select a colour
		'''
        s = ttk.Style()
        kw = s.configure("%s.label" % self._style)
        if 'background' in kw:
            colour = kw['background']
        else:
            colour = 'white'
        colour = colorchooser.askcolor(initialcolor=colour)[1]
        s.configure(self._style,
                    background=colour,
                    foreground='red',
                    highlightcolor='green')
        #		print(s.configure(self._style))
        if self._command:
            self._command()


if __name__ == '__main__':
    root = tk.Tk(keytype=tk.HKCU,
                 filepath=None,
                 name='Software\\colourbuttontest')
    c1 = ColourButton(root, text="tkbutton", name='testtkcolourbutton')
    c1.pack(fill='both', expand=True)
    c2 = ColourTtkButton(root, text="ttkbutton")
    c2.pack(fill='both', expand=True)
    root.mainloop()
Beispiel #5
0
import memtkinter as tk
from memtkinter.megawidgets import CollapsibleScrolledFrame

if __name__ == '__main__':
    root = tk.Tk(keytype=tk.HKCU,
                 filepath=None,
                 name='Software\\CollapsibleFrametest')
    cf = CollapsibleScrolledFrame(root, 'cf', text="Test Frame")
    cf.pack()
    for i in range(0, 10):
        tk.Label(cf, text='test %i' % i).grid(column=1, row=i, sticky='nesw')
    root.mainloop()
import memtkinter as tk
from memtkinter.megawidgets import SettingsViewer

if __name__ == '__main__':
    root = tk.Tk(keytype=tk.HKCU, filepath='./test.xml', name='test')

    sv = SettingsViewer(root)

    root.mainloop()
Beispiel #7
0
import memtkinter as tk
from memtkinter.megawidgets import ScrolledFrame

if __name__ == '__main__':
    root = tk.Tk(keytype=tk.HKCU,
                 filepath=None,
                 name='Software\\ScrolledFrametest')
    sf = ScrolledFrame(root, 'cf', scrollbars='auto')
    sf.pack(fill='both', expand=True)
    for i in range(0, 10):
        tk.Label(sf, text='Test %i' % i).grid(column=1, row=i, sticky='nesw')
    root.mainloop()
Beispiel #8
0
import memtkinter as tk
from memtkinter.mixins import MultiColumnListboxScrollbar

if __name__ == '__main__':
    root = tk.Tk(tk.HKCU, './test.xml', 'Software\\Multiwidgetscrolltest')
    root.grid_columnconfigure(1, weight=1)
    root.grid_columnconfigure(2, weight=1)
    root.grid_columnconfigure(3, weight=1)

    root.grid_rowconfigure(1, weight=1)

    selmode = tk.EXTENDED
    l1 = tk.Listbox(root, selectmode=selmode)
    l1.grid(column=1, row=1, sticky='nesw')
    l2 = tk.Listbox(root, selectmode=selmode)
    l2.grid(column=2, row=1, sticky='nesw')
    l3 = tk.Listbox(root, selectmode=selmode)
    l3.grid(column=3, row=1, sticky='nesw')

    sb = MultiColumnListboxScrollbar(root)
    sb.grid(column=10, row=1, sticky='nesw')
    sb.add_listbox(l1)
    sb.add_listbox(l2)
    sb.add_listbox(l3)

    for i in range(0, 20):
        sb.insert(tk.END, ('test %i' % i, 'test %i' % i, 'test %i' % i))

    root.mainloop()
Beispiel #9
0
import memtkinter as tk
from memtkinter.megawidgets import Grip

if __name__ == '__main__':
    root = tk.Tk(keytype=tk.HKCU, filepath=None, name='Software\\griptest')

    # this could be any type of widget as long as it has a non zero size
    # i.e. it can be clicked on.
    griplabel = tk.Label(root, text='click and drag to move')
    griplabel.pack()
    grip = Grip(griplabel)

    root.mainloop()
Beispiel #10
0
        print("instance_release:\t%s\t%s" % (event.widget, event.keysym))

    def class_press(event):
        print("class_press:\t%s\t%s" % (event.widget, event.keysym))

    def class_release(event):
        print("class_release:\t%s\t%s" % (event.widget, event.keysym))

    def all_press(event):
        print("all_press:\t%s\t%s" % (event.widget, event.keysym))

    def all_release(event):
        print("all_release:\t%s\t%s" % (event.widget, event.keysym))

    root = tk.Tk(keytype=tk.HKCU,
                 filepath='./test.xml',
                 name='Software\\debouncetest')
    frame = DebounceFrame(root,
                          width=100,
                          height=100,
                          bg='red',
                          takefocus=True)
    frame2 = DebounceFrame(root,
                           width=100,
                           height=100,
                           bg='blue',
                           takefocus=True)
    frame.bind("<KeyPress-a>", instance_press, False)
    frame.bind("<KeyRelease-a>", instance_release, False)
    frame.bind("<KeyPress-s>", instance_press)
    frame.bind("<KeyRelease-s>", instance_release)
Beispiel #11
0
#!python3

import memtkinter as tk

from tkinter.scrolledtext import ScrolledText

from memtkinter import tkdnd

root = tk.Tk(keytype=tk.HKCU, filepath=None, name='Software/James Kent/tkdndtest')

root.withdraw()
root.title('TkinterDnD simple text demo')
root.grid_rowconfigure(1, weight=1, minsize=250)
root.grid_columnconfigure(0, weight=1, minsize=300)

tk.Label(root, text='Drag and drop text here:').grid(
                    row=0, column=0, padx=10, pady=5)
buttonbox = tk.Frame(root, 'buttonbox')
buttonbox.grid(row=2, column=0, columnspan=2, pady=5)
tk.Button(buttonbox, text='Quit', command=root.quit).pack(
                    side=tk.LEFT, padx=5)

msg = "You can drop text onto the Label to append it to the Label's text "+\
      "string.\nYou can drag the Label's text string into other " +\
      "applications.\n"
label = tk.Label(root, name='dnd_demo_label', bg='white', relief='sunken',
                bd=1, highlightthickness=1, text=msg, takefocus=True,
                justify='left', anchor='nw', padx=5, pady=5)
label.grid(row=1, column=0, padx=5, pady=5, sticky='news')

# make the Label a drop target: