Пример #1
0
        master = boparent.code_child_master()
        init_args = self._get_init_args()
        bag = []
        for pname, value in init_args.items():
            s = "{0}='{1}'".format(pname, value)
            bag.append(s)
        kwargs = ''
        if bag:
            kwargs = ', {0}'.format(', '.join(bag))
        s = "{0} = tk.Tk({3}) if master is None else {1}({2}{3})".format(self.code_identifier(),
                                       self._code_class_name(), master, kwargs)
        lines.append(s)
        return lines


register_widget('pygubudesigner.ToplevelOrTk',
                ToplevelOrTk, 'ToplevelOrTk', tuple())



class UI2Code(Builder):
    def __init__(self):
        super(UI2Code, self).__init__()
        
        self.buffer = None
        self.as_class = False
        self._code_imports = OrderedDict()
        self._tkvariables = {}
        self._tkimages = {}
        self._callbacks = {}
        self._import_ttk = True;
        self._code = []
Пример #2
0
    def get_child_master(self):
        return self.widget.container

    def add_child(self, bobject):
        cwidget = bobject.widget
        self.widget.add_child(cwidget)

    #
    # Code generation methods
    #
    def code_child_master(self):
        return '{0}.container'.format(self.code_identifier())

    def code_child_add(self, childid):
        lines = []
        line = '{0}.add_child({1})'.format(self.code_identifier(), childid)
        lines.append(line)
        return lines

    def _code_set_property(self, targetid, pname, value, code_bag):
        if pname == 'usemousewheel':
            code_bag[pname] = '{0}'.format(tk.getboolean(value))
        else:
            super(TTKSBHelperBO,
                  self)._code_set_property(targetid, pname, value, code_bag)


register_widget('pygubu.builder.widgets.scrollbarhelper', TTKSBHelperBO,
                'ScrollbarHelper', ('Pygubu Helpers', 'ttk'))
Пример #3
0
                    tw.tl_attrs[pname] = (int(w), int(h))
                else:
                    del tw.tl_attrs[pname]
        elif pname == 'geometry':
            if value:
                w, h = self._get_dimwh(value)
                if w and h:
                    tw.tl_attrs['minsize'] = (int(w), int(h))
                    tw._h_set = tw._w_set = False
                    tw.configure(width=w, height=h)
                    if tw.pack_slaves():
                        tw.pack_propagate(0)
                    elif tw.grid_slaves():
                        tw.grid_propagate(0)
        elif pname == 'resizable':
            # Do nothing, fake 'resizable' property for Toplevel preview
            pass
        elif pname == 'modal':
            # Do nothing, fake 'modal' property for dialog preview
            pass
        else:
            super()._set_property(tw, pname, value)


register_widget(
    'pygubudesigner.ToplevelFramePreview',
    ToplevelFramePreviewBO,
    'ToplevelFramePreview',
    tuple(),
)
Пример #4
0
            super(TKScrolledFrameBO, self)._set_property(self.widget, pname, value)
        else:
            super(TKScrolledFrameBO, self)._set_property(target_widget, pname, value)

    #def layout(self, target=None, configure_gridrc=True):
    #    super(TKScrolledFrameBO, self).layout(target, False)
    #    self._gridrc_config(self.widget.innerframe)
    
    #
    # Code generation methods
    #
    def code_child_master(self):
        return '{0}.innerframe'.format(self.code_identifier())
    
    def code_configure(self, targetid=None):
        realtarget = '{0}.innerframe'.format(self.code_identifier())
        return super(TKScrolledFrameBO,self).code_configure(realtarget)
    
    def _code_set_property(self, targetid, pname, value, code_bag):
        if pname == 'usemousewheel':
            nvalue = '{0}.configure({1}={2})'.format(self.code_identifier(),
                                                     pname,
                                                     tk.getboolean(value))
            code_bag[pname] = [nvalue]
        else:
            super(TKScrolledFrameBO, self)._code_set_property(targetid, pname,
                                                             value, code_bag)

register_widget('pygubu.builder.widgets.tkscrolledframe', TKScrolledFrameBO,
    'ScrolledFrame', ('Pygubu Widgets', 'tk'))
Пример #5
0
# encoding: utf8
from __future__ import unicode_literals

try:
    import tkinter as tk
    from tkinter.scrolledtext import ScrolledText
except:
    import Tkinter as tk
    from ScrolledText import ScrolledText

from pygubu.builder.builderobject import BuilderObject, register_widget
from pygubu.builder.tkstdwidgets import TKText


class TkinterScrolledTextBO(TKText):
    class_ = ScrolledText


register_widget('pygubu.builder.widgets.tkinterscrolledtext',
                TkinterScrolledTextBO, 'ScrolledText',
                ('Control & Display', 'tk'))