PKJJmj aui_tk/App.pyfrom aui import App import tkinter as tk class _App(tk.Frame): """Actual Tk application class""" def __init__(self, master=None): """ Keyword arguments: master -- parent of the element (default: None) """ super().__init__(master) self.pack(fill=tk.constants.BOTH, expand=1) class TkApp(App): def __init__(self, ui, title=None): """ Keyword arguments: ui -- an object representing User Interface (widgets, containers) title -- window title | str """ self.app = _App() self.__parse_ui(ui) self.__setup_config(title) self.app.bind_class('Text', '', lambda e: e.widget.tag_add("sel", "1.0", "end")) def __setup_config(self, title): """ Sets up the application config (window title). Keyword arguments: config -- dict with application configuration """ self.app.master.title(title or App.DEFAULT_TITLE) def __parse_ui(self, root): """Creates UI based on the root UI object""" root.create(self.app) def run(self): """Runs application""" self.app.mainloop() PKJJ*s6j33aui_tk/Errors.pyclass NotInitializedException(Exception): pass PKJJ@aui_tk/__init__.py"""tk implementation of python-aui""" __version__ = '0.1' import sys from aui_tk.App import TkApp from aui_tk import widgets sys.modules['aui'].App = TkApp sys.modules['aui.widgets'] = widgets PKJJgaui_tk/widgets/Base.pyimport abc class Base(metaclass=abc.ABCMeta): """ Abstract class that needs to be derieved by every abstract representation of a Tk widget. """ @abc.abstractmethod def create(self, parent, align=None): """ Abstract method that handles creation of the widget. Keyword arguments: parent -- parent of the element to be put into align -- alignment of the element in container tk.constants.(TOP/RIGHT/BOTTOM/LEFT) """ raise NotImplementedError("`create` method not implemented") @abc.abstractmethod def destroy(self): """Destroys the widget""" raise NotImplementedError("`destroy` method not implemented") PKJJȟʟ aui_tk/widgets/Button.pyimport tkinter as tk import tkinter.ttk as ttk from aui.widgets import Button from aui_tk.widgets.Base import Base from aui_tk import Errors class Button(Button, Base): """Represents Tk button""" def __init__(self, text, onclick=None, **kwargs): """ Keyword arguments: text -- button text | str onclick -- function invoked after pressing the button | function: Button -> void Arguments: **kwargs -- any keyword arguments that will be pased additionally when creating ttk.Checkbutton Attributes: wide -- makes the button wide """ self._initial_value = text self._text = None self.callback = lambda: onclick(self) if onclick else None self._extra_params = kwargs self._button = None self.__wide = False def __make_wide(self): self.__wide = True def __getattr__(self, attr): functions = { 'wide': self.__make_wide } if attr not in functions: raise KeyError("`{}` is not a valid button modifier".format(attr)) functions[attr]() return self @property def text(self): """Get button's text""" try: return self._text.get() except: raise Errors.NotInitializedException("Button has not been initialized yet") @text.setter def text(self, value): """Set button's text""" try: self._text.set(value) except: raise Errors.NotInitializedException("Button has not been initialized yet") def destroy(self): """Destroys the button""" self._button.destroy() def create(self, parent, align=None): """ Creates button and assigns it to its parent Keyword arguments: parent -- parent of the element to be put into align -- alignment of the element in container tk.constants.(TOP/RIGHT/BOTTOM/LEFT) """ self._text = tk.StringVar() self._text.set(self._initial_value) self._button = ttk.Button(parent, textvariable=self._text, command=self.callback, **self._extra_params) self._button.pack(side=align, fill=tk.constants.X if self.__wide else None) PKJJ:C_ _ aui_tk/widgets/Checkbox.pyimport tkinter as tk import tkinter.ttk as ttk from aui.widgets import Checkbox from aui_tk.Errors import NotInitializedException from aui_tk.widgets.Base import Base class Checkbox(Checkbox, Base): """Represents Tk checkbox with label""" def __init__(self, text, selected=False, onchange=None, **kwargs): """ Keyword arguments: text -- checkbox text | str selected -- whether the checkbox is selected on init | boolean onchange -- function invoked after toggling the checkbox | function: Checkbox -> void Arguments: **kwargs -- any keyword arguments that will be pased additionally when creating ttk.Checkbutton """ self.text = text self._selected = selected self._value = None self._extra_params = kwargs self.callback = lambda: onchange(self) if onchange else None self._checkbox = None @property def selected(self): """Check if checkbox is selected""" try: return self._value.get() except: raise NotInitializedException("Checkbox has not been initialized yet") @selected.setter def selected(self, value): """Set checkbox (not) selected""" try: self._value.set(value) except: raise NotInitializedException("Checkbox has not been initialized yet") def destroy(self): """Destroys the checkbox""" pass self._checkbox.destroy() def create(self, parent, align=None): """ Creates checkbox with label and assigns it to its parent Keyword arguments: parent -- parent of the element to be put into align -- alignment of the element in container (UP/RIGHT/BOTTOM/LEFT) """ self._value = tk.BooleanVar() self._value.set(self._selected) self._checkbox = ttk.Checkbutton(parent, text=self.text, onvalue=True, offvalue=False, variable=self._value, command=self.callback, **self._extra_params) self._checkbox.pack(side=align) PKJJscaui_tk/widgets/Horizontal.pyimport tkinter as tk import tkinter.ttk as ttk from aui.widgets import Horizontal from aui_tk.widgets.Base import Base class Horizontal(Horizontal, Base): """Horizontal container - tkinter.Frame""" def __init__(self, *children, **kwargs): """ Arguments: *children -- children elements of the container **kwargs -- any keyword arguments that will be pased additionally when creating ttk.Frame """ self.__children = children self._extra_params = kwargs self._horizontal = None def create(self, parent, align=None): """ Creates horizontal container and assigns it to its parent Keyword arguments: parent -- parent of the element to be put into align -- alignment of the element in container tk.constants.(TOP/RIGHT/BOTTOM/LEFT) """ self._horizontal = ttk.Frame(parent, **self._extra_params) self._horizontal.pack(side=align, fill=tk.constants.BOTH, expand=1) self.__mount_children() def __mount_children(self): for child in self.__children: self.append(child) def destroy(self): """Destroys the horizontal container""" self._horizontal.destroy() def clear(self): for child in self.__children: child.destroy() def append(self, child): """ Appends widget to the horizontal container Keyword arguments: child -- the widget to be placed into the container """ if self._horizontal is not None: child.create(self._horizontal, tk.constants.LEFT) if child not in self.__children: self.__children.append(child) PKJJe  aui_tk/widgets/Input.pyimport tkinter as tk import tkinter.ttk as ttk from aui.widgets import Input from aui_tk.widgets.Base import Base from aui_tk import Errors class Input(Input, Base): """Represents Tk entry""" def __init__(self, value="", onenter=None, **kwargs): """ Keyword arguments: value -- default value | str (default: "") onenter -- function called after the return button is pressed | function: Input -> void Arguments: **kwargs -- any keyword arguments that will be pased additionally when creating ttk.Entry Attributes: wide -- makes the input wide """ self._initial_value = value self._value = None self.onenter = onenter self._extra_params = kwargs self._input_field = None self.__wide = False def __make_wide(self): self.__wide = True def __getattr__(self, attr): functions = { 'wide': self.__make_wide } if attr not in functions: raise KeyError("`{}` is not a valid button modifier".format(attr)) functions[attr]() return self @property def value(self): """Get input's value""" try: return self._value.get() except: raise Errors.NotInitializedException("Input has not been initialized yet") @value.setter def value(self, new_value): """Set input's value""" try: self._value.set(new_value) except: raise Errors.NotInitializedException("Input has not been initialized yet") def __onenter(self, event): """Calls self.onenter function. Bound to press.""" if self.onenter: self.onenter(self) def destroy(self): """Destroys the input field""" self._input_field.destroy() def ctrl_a_handler(self, e): e.widget.select_range(0, tk.constants.END) return 'break' def create(self, parent, align=None): """ Creates input and assigns it to its parent Keyword arguments: parent -- parent of the element to be put into align -- alignment of the element in container (UP/RIGHT/BOTTOM/LEFT) """ self._value = tk.StringVar() self._value.set(self._initial_value) self._input_field = ttk.Entry(parent, textvariable=self._value, **self._extra_params) self._input_field.pack(side=align, fill=tk.constants.X if self.__wide else None) self._input_field.bind('', self.ctrl_a_handler) self._input_field.bind('', self.__onenter) PKJJ=aui_tk/widgets/Label.pyimport tkinter as tk import tkinter.ttk as ttk from aui.widgets import Label from aui_tk.widgets.Base import Base class Label(Label): """Represents Tk label""" def __init__(self, text, **kwargs): """ Keyword arguments: text -- label text | str Arguments: **kwargs -- any keyword arguments that will be pased additionally when creating ttk.Label """ self._text = text self._extra_params = kwargs self._label = None self._parent = None @property def text(self): return self._text @text.setter def text(self, value): self._text = value self.destroy() self.create(self._parent) def destroy(self): """Destroys the label""" self._label.destroy() def create(self, parent, align=None): """ Creates label and assigns it to its parent Keyword arguments: parent -- parent of the element to be put into align -- alignment of the element in container (UP/RIGHT/BOTTOM/LEFT) """ self._parent = parent self._label = ttk.Label(parent, text=self.text, **self._extra_params) self._label.pack(side=align) PKJJԎaui_tk/widgets/Text.pyimport tkinter as tk from aui.widgets import Text from aui_tk.widgets.Base import Base from aui_tk import Errors class Text(Text, Base): """Represents Tk Text""" def __init__(self, text="", **kwargs): """ Keyword arguments: text -- default text | str (default: "") Arguments: **kwargs -- any keyword arguments that will be pased additionally when creating tk.Text """ self._initial_text = text self._extra_params = kwargs self._text_field = None @property def text(self): """Get text's text""" try: return self._text_field.get("1.0", tk.constants.END) except: raise Errors.NotInitializedException("Text has not been initialized yet") @text.setter def text(self, new_text): """Set text's text""" try: self._text_field.delete("1.0", tk.constants.END) self._text_field.insert("1.0", new_text) except: raise Errors.NotInitializedException("Text has not been initialized yet") def destroy(self): """Destroys the text field""" self._text_field.destroy() def create(self, parent, align=None): """ Creates input and assigns it to its parent Keyword arguments: parent -- parent of the element to be put into align -- alignment of the element in container (UP/RIGHT/BOTTOM/LEFT) """ self._text_field = tk.Text(parent, **self._extra_params) self._text_field.pack(side=align, fill=tk.constants.BOTH, expand=1) PKJJ ֦aui_tk/widgets/Vertical.pyimport tkinter as tk import tkinter.ttk as ttk from aui.widgets import Vertical from aui_tk.widgets.Base import Base class Vertical(Vertical, Base): """Vertical container - tkinter.Frame""" def __init__(self, *children, **kwargs): """ Arguments: *children -- children elements of the container **kwargs -- any keyword arguments that will be pased additionally when creating ttk.Frame """ self.__children = list(children) self._extra_params = kwargs self._vertical = None def create(self, parent, align=None): """ Creates vertical container and assigns it to its parent Keyword arguments: parent -- parent of the element to be put into align -- alignment of the element in container tk.constants.(TOP/RIGHT/BOTTOM/LEFT) """ self._vertical = ttk.Frame(parent, **self._extra_params) self._vertical.pack(side=align, fill=tk.constants.BOTH, expand=1) self.__mount_children() def __mount_children(self): for child in self.__children: self.append(child) def destroy(self): """Destroys the vertical container""" self._vertical.destroy() def clear(self): for child in self.__children: child.destroy() def append(self, child): """ Appends widget to the vertical container Keyword arguments: child -- the widget to be placed into the container """ if self._vertical is not None: child.create(self._vertical, tk.constants.TOP) if child not in self.__children: self.__children.append(child) PKJJ^>>aui_tk/widgets/__init__.py# widgets from aui_tk.widgets.Button import Button from aui_tk.widgets.Checkbox import Checkbox from aui_tk.widgets.Input import Input from aui_tk.widgets.Label import Label from aui_tk.widgets.Text import Text # containers from aui_tk.widgets.Horizontal import Horizontal from aui_tk.widgets.Vertical import Vertical PK!H;@QPaui-tk-0.1.dist-info/WHEEL1 0 RZq+D-Dv;_[*7Fp ܦpv/fݞoL(*IPK!H%&aui-tk-0.1.dist-info/METADATARR1+]*&B6T6#ήck-r:I==ŀ-9H8)?%j0ʇDTQkt a֣"M&`HuHBj*F:簎uX=FB&7sC'jmy}N‚>ڣid%NPAg;pm;=Ev䋛m# gsǔL R 2@JgR#>^f\WW0Gg4/CHrlPk6=1$wq8;rvIg|εC߸,l<]M8{L0 Mm` jwu#K!V>Lc%4V%vd!r4B)vPK!H_vaui-tk-0.1.dist-info/RECORDmےcPl8D  9Q!K)7WGCۻжoŮFaDmvӜY 3< 3pP#]ty^66dnQ|pt͍C0̰^]M|0aX4ja;{=ɭ{9a86XEw1곅ru]X+ (zw08%<E0nrvG&e %gJV̚i>:IN J,ʹ v$-ܰ@u_HGFA!_TLdy34]97GJ27 &09i5_ӁZ,pI ~FUxA>BJLEĻ-mCK6_HGPzg} Mc9NWAaF%KkHP#;HlZNh#OtBasaP>`R)pwAǠ]Flކǥ.fV*{3;o֑)" ^g\k!(^;qCi[EToe4 VxKJ7gEqr׿Xb3kS"{)gACv ^p:2<բ#\Yk&邀udl/PKJJmj aui_tk/App.pyPKJJ*s6j33aui_tk/Errors.pyPKJJ@Saui_tk/__init__.pyPKJJgHaui_tk/widgets/Base.pyPKJJȟʟ C aui_tk/widgets/Button.pyPKJJ:C_ _ aui_tk/widgets/Checkbox.pyPKJJscaui_tk/widgets/Horizontal.pyPKJJe  #aui_tk/widgets/Input.pyPKJJ=.aui_tk/widgets/Label.pyPKJJԎ4aui_tk/widgets/Text.pyPKJJ ֦:aui_tk/widgets/Vertical.pyPKJJ^>>Aaui_tk/widgets/__init__.pyPK!H;@QP3Caui-tk-0.1.dist-info/WHEELPK!H%&Caui-tk-0.1.dist-info/METADATAPK!H_vEaui-tk-0.1.dist-info/RECORDPKH