Esempio n. 1
0
class BaseContainer(BaseUI.BaseContainer):
    container_classes = widgets.get_container_classes()
    widget_classes = widgets.get_widget_classes()
    # TODO: make this use the container class in widgets module
    def add_child(self, widget, **kwargs):
        if isinstance(self.topcontainer, gtk.Table):
            expand = kwargs.get('expand')
            if expand is not None:
                del kwargs['expand']
                if expand:
                    kwargs.setdefault('xoptions', gtk.EXPAND | gtk.FILL)
                    kwargs.setdefault('yoptions', gtk.EXPAND | gtk.FILL)
                    #print 'xoptions', kwargs.get('xoptions')
            else:
                kwargs.setdefault('xoptions', gtk.FILL)
                kwargs.setdefault('yoptions', gtk.FILL)
            sizeX = self.topcontainer.get_property('n-columns')
            sizeY = self.topcontainer.get_property('n-rows')
            loc = None
            for x in range(sizeX):
                for y in range(sizeY):
                    if (x, y) not in self._child_widgets_locations:
                        loc = (x, y)
                        break
            if loc is None:
                self.topcontainer.resize(sizeY+1, sizeX)
                loc = (sizeX, sizeY+1)
            self.topcontainer.attach(widget, loc[0], loc[0]+1, loc[1], loc[1]+1, **kwargs)
            self._child_widgets_locations.update({loc:widget})
        else:
            kwargs.setdefault('expand', False)
            
            self.topcontainer.pack_start(widget, **kwargs)
Esempio n. 2
0
    def __init__(self, **kwargs):
        if not hasattr(self, 'container_classes'):
            self.container_classes = kwargs.get('container_classes',
                                                get_container_classes())
        if not hasattr(self, 'widget_classes'):
            self.widget_classes = kwargs.get('widget_classes',
                                             get_widget_classes())
        self.section = kwargs.get('section')
        size = self.section.container_size
        if size is not None:
            twkwargs = kwargs.get('topwidget_kwargs', {})
            twkwargs.update({'rows': size[0], 'columns': size[1]})
            kwargs.setdefault('topwidget_kwargs', twkwargs)
        kwargs.setdefault('topwidget_name', self.section.name)
        kwargs.setdefault(
            'topwidget_cls',
            self.container_classes.get(self.section.container_widget, 'VBox'))

        #new_kwargs = kwargs.copy()
        #new_kwargs.update({'topwidget_cls':self.container_classes['VBox']})

        #if hasattr(self.section, 'container_widget'):
        #    cls = self.container_classes.get(self.section.container_widget)
        #    if cls is not None:
        #        new_kwargs.update({'topwidget_cls':cls})
        super(ControlContainer, self).__init__(**kwargs)
        self.topwidget.set_label(self.section.name)
        self.controls = {}
        self.containers = {}
        self.children = {}
        if self.section.params_by_group is not None:
            for group in self.section.params_by_group.iterkeys():
                self.controls.update({group: {}})
        self.build_controls()
        if len(self.section.children) > 0:
            self.build_children()
        self.topwidget.show_all()
Esempio n. 3
0
 def __init__(self, **kwargs):
     if not hasattr(self, 'container_classes'):
         self.container_classes = kwargs.get('container_classes', get_container_classes())
     if not hasattr(self, 'widget_classes'):
         self.widget_classes = kwargs.get('widget_classes', get_widget_classes())
     self.section = kwargs.get('section')
     size = self.section.container_size
     if size is not None:
         twkwargs = kwargs.get('topwidget_kwargs', {})
         twkwargs.update({'rows':size[0], 'columns':size[1]})
         kwargs.setdefault('topwidget_kwargs', twkwargs)
     kwargs.setdefault('topwidget_name', self.section.name)
     kwargs.setdefault('topwidget_cls', self.container_classes.get(self.section.container_widget, 'VBox'))
     
     
     
     
     #new_kwargs = kwargs.copy()
     #new_kwargs.update({'topwidget_cls':self.container_classes['VBox']})
     
     #if hasattr(self.section, 'container_widget'):
     #    cls = self.container_classes.get(self.section.container_widget)
     #    if cls is not None:
     #        new_kwargs.update({'topwidget_cls':cls})
     super(ControlContainer, self).__init__(**kwargs)
     self.topwidget.set_label(self.section.name)
     self.controls = {}
     self.containers = {}
     self.children = {}
     if self.section.params_by_group is not None:
         for group in self.section.params_by_group.iterkeys():
             self.controls.update({group:{}})
     self.build_controls()
     if len(self.section.children) > 0:
         self.build_children()
     self.topwidget.show_all()
Esempio n. 4
0
class ControlContainer(BaseUI.ControlContainer):
    container_classes = widgets.get_container_classes()
    widget_classes = widgets.get_widget_classes()
    def build_children(self):
        cinfo = self.section.child_container
        size = cinfo.get('size')
        cboxkwargs = {}
        if size is not None:
            cboxkwargs.update({'rows':size[1], 'columns':size[0]})
        #cbox = self.container_classes.get(cinfo.get('cls', 'VBox'))(**cboxkwargs)
        book = self.container_classes.get('Notebook')()
        #print 'name %s,cboxclass %s, kwargs %s' % (self.section.name, cinfo.get('cls'), cboxkwargs)
        #for key, val in self.section.children.iteritems():
        keys = self.section.child_order
        if keys is None:
            keys = self.section.children.keys()
        for key in keys:
            val = self.section.children[key]
            self.children.update({key:{}})
            for cKey, cVal in val.iteritems():
                #topwidget = self.container_classes.get(cVal.container_widget, self.container_classes['VBox'])
                #topwidget = self.container_classes['Frame']
                #topwidget = self.container_classes.get(cVal.container_widget, self.container_classes['VBox'])
                #twkwargs = {}
                #if cVal.container_size is not None:
                #    twkwargs.update({'rows':cVal.container_size[0], 'columns':cVal.container_size[1]})
                #if topwidget is None:
                #    topwidget = VBox
                child = ControlContainer(section=cVal, 
                                         container_classes=self.container_classes, 
                                         widget_classes=self.widget_classes)
                #self.add_child(child.topwidget)
                #cbox.pack_end(child.topwidget)
                book.add_page(widget=child.topwidget, label=child._topwidget_name)
                self.children[key].update({cKey:child})
            self.add_child(book)
Esempio n. 5
0
    def run(self, join=False):
        mwkwargs = self.mainwindow_kwargs.copy()
        self.mainwindow = self._build_mainwindow(**mwkwargs)
        self.emit('start')
        self.start_GUI_loop(join)

    def on_mainwindow_close(self, *args, **kwargs):
        self.stop_ParentEmissionThread()
        self.stop_GUI_loop()
        self.emit('exit')


from bases.widgets import get_widget_classes, get_container_classes

widget_classes = get_widget_classes()
container_classes = get_container_classes()


class BaseWindow(BaseObject):
    _Properties = {
        'title': dict(default=''),
        'size': dict(default=[1150, 800]),
        'position': dict(default=[40, 40]),
        'fullscreen': dict(default=False)
    }

    def __init__(self, **kwargs):
        kwargs['ParentEmissionThread'] = kwargs[
            'Application'].ParentEmissionThread
        super(BaseWindow, self).__init__(**kwargs)
        self._Application = None
Esempio n. 6
0
class GUIThread(BaseThread):
    def __init__(self, **kwargs):
        kwargs['thread_id'] = 'GUIThread'
        super(GUIThread, self).__init__(**kwargs)
        self._threaded_call_ready.wait_timeout = None
    def insert_threaded_call(self, call, *args, **kwargs):
        if threading.currentThread().name in ['MainThread', self._thread_id, gtksimple.gCBThread._thread_id]:
            call(*args, **kwargs)
        else:
            gtksimple.gCBThread.add_callback(call, *args, **kwargs)
    def stop(self, **kwargs):
        gtksimple.gCBThread.stop(**kwargs)
        super(GUIThread, self).stop(**kwargs)
        
widget_classes = widgets.get_widget_classes()
container_classes = widgets.get_container_classes()

class BaseWindow(BaseUI.BaseWindow):
    def __init__(self, **kwargs):
        super(BaseWindow, self).__init__(**kwargs)
        #if hasattr(self, 'topwidget_name'):
        #    kwargs.setdefault('topwidget_name', self.topwidget_name)
        #title = kwargs.get('topwidget_name', '')
        self.set_window_size(self.size)
        if self.title is not None:
            self.window.set_title(self.title)
        
        self.child_windows = {}
        self.widgets = {}
            
    def _Application_set(self, old, new):
Esempio n. 7
0
        
    def run(self, join=False):
        mwkwargs = self.mainwindow_kwargs.copy()
        self.mainwindow = self._build_mainwindow(**mwkwargs)
        self.emit('start')
        self.start_GUI_loop(join)
        
    def on_mainwindow_close(self, *args, **kwargs):
        self.stop_ParentEmissionThread()
        self.stop_GUI_loop()
        self.emit('exit')

from bases.widgets import get_widget_classes, get_container_classes

widget_classes = get_widget_classes()
container_classes = get_container_classes()

class BaseWindow(BaseObject):
    _Properties = {'title':dict(default=''), 
                   'size':dict(default=[1150, 800]), 
                   'position':dict(default=[40, 40]), 
                   'fullscreen':dict(default=False)}
    def __init__(self, **kwargs):
        kwargs['ParentEmissionThread'] = kwargs['Application'].ParentEmissionThread
        super(BaseWindow, self).__init__(**kwargs)
        self.window = self._build_window(**kwargs)
        self.bind(property_changed=self._on_own_property_changed)
        self._Application = None
        self.Application = kwargs.get('Application')
        #for key in ['size', 'window_size']:
        #    if hasattr(self, key):
Esempio n. 8
0
class GUIThread(BaseThread):
    def __init__(self, **kwargs):
        kwargs['thread_id'] = 'GUIThread'
        super(GUIThread, self).__init__(**kwargs)
        self._threaded_call_ready.wait_timeout = None
    def insert_threaded_call(self, call, *args, **kwargs):
        if threading.currentThread().name in ['MainThread', self._thread_id, gtksimple.gCBThread._thread_id]:
            call(*args, **kwargs)
        else:
            gtksimple.gCBThread.add_callback(call, *args, **kwargs)
    def stop(self, **kwargs):
        gtksimple.gCBThread.stop(**kwargs)
        super(GUIThread, self).stop(**kwargs)
        
widget_classes = widgets.get_widget_classes()
container_classes = widgets.get_container_classes()

class BaseWindow(BaseUI.BaseWindow):
    def __init__(self, **kwargs):
        super(BaseWindow, self).__init__(**kwargs)
        #if hasattr(self, 'topwidget_name'):
        #    kwargs.setdefault('topwidget_name', self.topwidget_name)
        #title = kwargs.get('topwidget_name', '')
        self.set_window_size(self.size)
        if self.title is not None:
            self.window.set_title(self.title)
        
        self.child_windows = {}
        self.widgets = {}
            
    def _Application_set(self, old, new):