Example #1
0
 def destroy(self):
     self._ensure_destroyed()
     try:
         application().remove(self)
     except ValueError:
         # Already removed
         pass
Example #2
0
 def destroy(self):
     Frame.destroy(self)
     try:
         application().remove(self)
     except ValueError:
         # Already removed
         pass
Example #3
0
    def __init__(self, proxy, _test=0):
        """
        Store the proxy and perform general initialisation.

        If the main loop has been entered already, the Wrapper will
        prod itself. Otherwise, the Proxy should call prod() at some
        later point, when the event loop has been entered.

        The constructor sets up the self.aggregateSetters dictionary with
        aggregate setters, by calling the setAggregateSetter
        method. Subclasses wanting to add (or override) setaggregates
        should use the same method.
        """
        self.proxy = proxy

        #@@@ Hm. Some of this could be done globally/class-wide...

        self.aggregateSetters = {}
        self.setAggregateSetter('position', ('x', 'y'))
        self.setAggregateSetter('size', ('width', 'height'))
        self.setAggregateSetter('geometry', ('x', 'y', 'width', 'height'))

        self.aggregateGetters = {}
        self.setAggregateGetter('geometry', ('x', 'y', 'width', 'height'))

        self.constraints = []

        if not _test:
            application().manage(self)
            self.inMainLoop = 0
            self.prod()  #@@@ ?
Example #4
0
 def __init__(self, dir, filters, sort_rule=DIRS_FIRST):
     manygui.Window.__init__(self, title='Open File - ' + \
                     manygui.application().name + '-' + manygui.application().version, \
                     geometry=(250, 200, 420, 350))
     self._updating = 0
     self.dirMngr = DirManager(dir, filters[0], sort_rule)
     self._priorSelections = []
     #self.createTripaneDirList()
     self.initWidgets(filters)
Example #5
0
 def closeHandler(self, event):
     if DEBUG: print('in closeHandler of: ', self.widget)
     # What follows is a dirty hack, but PyQt will seg-fault the
     # interpreter if a call onto QWidget.destroy() is made after
     # the Widget has been closed. It is also necessary to inform
     # the front-end of self being closed.
     self.destroyingSelf = 1
     self.destroy()
     self.destroyingSelf = 0
     self.connected = 0
     self.widget = None
     self.mainWindow = None
     application().remove(self.proxy)
     return 1
Example #6
0
 def __init__(self, proxy):
     if not self in wrappers:
         wrappers.append(self)
     # self.makeSetterMap()
     self.proxy = proxy
     if application().running:
         self.prod()
Example #7
0
 def widgetFactory(self,*args,**kws):
     app = application()
     if self.proxy.container and hasattr(self.proxy.container,'wrapper'):
         parent = self.proxy.container.wrapper.widget
     else:
         parent = 0
     t = self._wndclass
     if t is None:
         self._i_wndclass = 0
     elif type(t) is type(''):
         self._i_wndclass = windll.cstring(t)
     elif type(t) is type(0):
         self._i_wndclass = t
     widget = user32.CreateWindowEx(self._win_style_ex,
                                      self._i_wndclass,
                                      0,
                                      self._win_style,
                                      0,
                                      0,
                                      10,
                                      10,
                                      parent,
                                      0, # hMenu
                                      0, # hInstance
                                      0)
     app.widget_map[widget] = self
     return widget
Example #8
0
 def setContainer(self,container):
     if not application().isRunning(): return
     if container is None: pass
     if self.widget is None: self.create(container)
     self.proxy.push(blocked=['container'])
     # Ensure contents are properly created.
     for comp in self.proxy.contents:
         comp.container = self.proxy
Example #9
0
 def setContainer(self,container):
     if not application().isRunning(): return
     if container is None: return
     if not self.widget:
         self.create()
     user32.ShowWindow(self.widget, SW_HIDE)
     user32.UpdateWindow(self.widget)
     self.proxy.push(blocked=['container'])
     # Ensure contents are properly created.
     for comp in self.proxy.contents:
         comp.container = self.proxy
Example #10
0
 def prod(self):
     """
     Check environment for changes.
     
     The front-end Proxy should call this every time something has
     changed in the environment that it believes the Wrapper may be
     interested in. One such condition is that the main even loop
     has been entered, since many backend Wrappers will then be
     able to instantiate their native widgets.
     """
     if application().isRunning() and not self.inMainLoop:
         self.inMainLoop = 1
         self.enterMainLoop()
     self.internalProd()
Example #11
0
    def create(self, *args, **kwds):
        """
        Create the native widget, if necessary.

        If the application is running and self.widget is non-existent
        or None or, create a new widget using self.widgetFactory(),
        optionally supplying the given positional and keyword
        arguments.
        """
        # FIXME: Deal with dummy widgets...
        if application().isRunning():
            if not self.widget:
                self.widget = self.widgetFactory(*args, **kwds)
                self.widgetSetUp()
Example #12
0
 def _WM_COMMAND(self, hwnd, msg, wParam, lParam):
     #if _verbose: log("ContainerMixin _WM_COMMAND called for %s"%self)
     # lParam: handle of control (or NULL, if not from a control)
     # HIWORD(wParam): notification code
     # LOWORD(wParam): id of menu item, control, or accelerator
     try:
         app = application()
         child_window = self.widget_map[lParam]
     except KeyError:
         #if _verbose: log("NO SUCH CHILD WINDOW %s"%lParam)
         # we receive (when running test_textfield.py)
         # EN_CHANGE (0x300) and EN_UPDATE (0x400) notifications
         # here even before the call to CreateWindow returns.
         return -1
     #if _verbose: log("Dispatching to child %s"%child_window)
     return child_window._WM_COMMAND(hwnd, msg, wParam, lParam)
Example #13
0
 def widgetFactory(self,*args,**kws):
     app = application()
     if self.proxy.container and hasattr(self.proxy.container,'wrapper'):
         parent = self.proxy.container.wrapper.widget
     else:
         parent = 0
     widget = CreateWindowEx(self._win_style_ex,
                             self._wndclass,
                             0,
                             self._win_style,
                             0,
                             0,
                             10,
                             10,
                             parent,
                             0, # hMenu
                             0, # hInstance
                             0)
     app.widget_map[widget] = self
     return widget
Example #14
0
 def widgetSetUp(self):
     if _verbose: log('Windowwrapper widgetSetup',str(self),'application()',application(),'isRunning()',application().isRunning(),'widget',getattr(self,'widget',None))
     application().widget_map[self.widget] = self
     user32.SendMessage(self.widget, WM_SETFONT, self._hfont, 0)
Example #15
0
 def addToContainer(self,container):
     application().txtapp.add(self.widget)
     self.widget.resize_command = self.resize
Example #16
0
 def closeHandler(self):
     self.destroy()
     application().remove(self.proxy)
Example #17
0
        s = S.append
        s('def %s(self,*A,**K):' % methodname)
        s('\ttry:')
        s('\t\treturn self.%s(*A,**K)' % oldmethodname)
        s('\texcept:')
        s('\t\tfrom manygui.Utils import logTraceback')
        s('\t\tlogTraceback(None,\'[%s.%s]\')' % (C.__name__,methodname))
        s('\t\traise')
        s('setattr(C,oldmethodname,oldmethod)')
        s('setattr(C,methodname,new.instancemethod(%s,None,C))' % methodname)
        exec('\n'.join(S) + '\n', locals())
        n += 1

    for a in __all__:
        C = globals()[a]
        if isclass(C):
            M = []
            m = M.append
            for methodname,method in getmembers(C):
                if ismethod(method): m(methodname)
            for methodname in M: makeTBWrap(C,methodname)

################################################################
if __name__ == '__main__':
    from manygui import *
    app = Application()
    win = Window(title = "A Standard Window",
                 width = 300, height = 200)
    win.show()
    application().run()
Example #18
0
 def internalDestroy(self):
     if DEBUG: print("in internalDestroy of: ", self)
     self.mainWindow.destroy()
     application().remove(self.proxy)
Example #19
0
 def close(self, event):
     self.widget.destroy()
     self.destroy()
     application().remove(self.proxy)
Example #20
0
 def _WM_CLOSE(self, hwnd, msg, wParam, lParam):
     self.destroy()
     application().remove(self.proxy)
     return 0
Example #21
0
def _dispatch_WM_DESTROY(window,hwnd,msg,wParam,lParam):
    app = application()
    app.remove(window)
    app.internalRemove()
    return 0
Example #22
0
 def closeHandler(self, evt):
     self.destroy()
     application().remove(self.proxy) # @@@ Hm...