Ejemplo n.º 1
0
    def make_glass(frame, left=-1, right=-1, top=-1, bottom=-1):
        '''\
        Make a ``wx.Frame`` object translucent, giving it a full glass
        look by default. This behavior can be overridden by explicitly
        specifying the margin values through the four additional parameters.
        '''
        # the message handler for WM_DWMCOMPOSITIONCHANGED
        def OnDwmCompositionChanged(self, wParam, lParam):
            if is_composition_enabled():
                _make_glass(self, left, right, top, bottom)
            else:
                self.SetBackgroundColour(self._BackgroundColourBackup)
            self.Refresh()
            return True
        fun2meth(OnDwmCompositionChanged, frame)

        # first set up the effect properly
        if is_composition_enabled():
            _make_glass(frame, left, right, top, bottom)

        # hook the WndProc so as to catch WM_DWMCOMPOSITIONCHANGED
        # NOTE here we don't wrap these lines also into that if stmt,
        # because Aero can be disabled when we're started, but enabled
        # later.
        wxmsw_wndhook.install_hooks(frame)
        frame.addMsgHandler(WM_DWMCOMPOSITIONCHANGED,
                frame.OnDwmCompositionChanged)
        frame.hookWndProc()
Ejemplo n.º 2
0
    def AddShrimpBtn(self, prnt, idx, shrimp):
        btn_name = SHRIMPBTN_NAME_FMT % idx
        id_name = SHRIMPBTN_ID_FMT % idx
        handler_name = SHRIMPBTN_EVTBUTTON_FMT % idx

        # 1st we make a EVT_BUTTON handler which fires up the corresponding
        # shrimp.
        # the method is adapted from the former OnLvwShrimpListItemActivated
        # handler, adding some cool dynamic stuff
        def _FireUpShrimp(self, event):
            try:
                cooker.bring_up_shrimp(shrimp)
            except ValueError:
                # already running
                wx.MessageBox('error: already running!')
            event.Skip()
        _FireUpShrimp.func_name = handler_name
        fun2meth(_FireUpShrimp, self) # , handler_name)

        # Some identifying info...
        icon_bmap = iconmgr.get_bitmap(shrimp)
        name = cooker.get_name(shrimp)

        # Prepare the button...
        newid = self.__dict__[id_name] = wx.NewId()
        tmp = wx.BitmapButton(prnt, newid, icon_bmap, (0, 0),
                SHRIMPBTN_SIZETUPLE) # , style=SHRIMPBTN_STYLE)
        tmp.SetToolTipString(name)
        self.__dict__[btn_name] = tmp
        tmp.Bind(wx.EVT_BUTTON, getattr(self, handler_name), id=newid)

        # set up layout later, so we are basically done here
        # store some lookup information
        self._ShrimpButtons.append(tmp)