コード例 #1
0
ファイル: StatusBar.py プロジェクト: sticker592/EventGhost
    def __init__(self, parent):
        wx.StatusBar.__init__(self, parent, -1)
        self.sizeChanged = False
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_IDLE, self.OnIdle)
        self.SetFieldsCount(2)
        self.SetStatusWidths([-1, 40])
        self.icons = [
            GetInternalBitmap("Tray1"),
            GetInternalBitmap("Tray3"),
            GetInternalBitmap("Tray2"),
        ]
        self.icon = wx.StaticBitmap(self, -1, self.icons[0], (0, 0), (16, 16))
        rect = self.GetFieldRect(0)

        checkBox = wx.CheckBox(self, -1, eg.text.MainFrame.onlyLogAssigned)
        self.checkBox = checkBox
        colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
        checkBox.SetBackgroundColour(colour)
        self.checkBoxColour = checkBox.GetForegroundColour()
        checkBox.SetValue(eg.config.onlyLogAssigned)
        self.SetCheckBoxColour(eg.config.onlyLogAssigned)
        checkBox.Bind(wx.EVT_CHECKBOX, self.OnCheckBox)
        checkBox.SetPosition((rect.x + 2, rect.y + 2))
        checkBox.SetToolTipString(eg.text.MainFrame.onlyLogAssignedToolTip)

        eg.Bind("ProcessingChange", self.OnProcessingChange)
        self.Reposition()
コード例 #2
0
    def __init__(self, parent, includeInvisible=False):
        self.includeInvisible = includeInvisible
        self.pids = {}
        wx.TreeCtrl.__init__(self,
                             parent,
                             -1,
                             style=(wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT
                                    | wx.TR_FULL_ROW_HIGHLIGHT),
                             size=(-1, 150))
        self.imageList = imageList = wx.ImageList(16, 16)
        imageList.Add(GetInternalBitmap("cwindow"))
        imageList.Add(GetInternalBitmap("cedit"))
        imageList.Add(GetInternalBitmap("cstatic"))
        imageList.Add(GetInternalBitmap("cbutton"))
        self.SetImageList(imageList)
        self.root = self.AddRoot("")

        # tree context menu
        def OnCmdHighlight(dummyEvent=None):
            hwnd = self.GetPyData(self.GetSelection())
            for _ in range(10):
                HighlightWindow(hwnd)
                sleep(0.1)

        menu = wx.Menu()
        menuId = wx.NewId()
        menu.Append(menuId, "Highlight")
        self.Bind(wx.EVT_MENU, OnCmdHighlight, id=menuId)
        self.contextMenu = menu

        self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnItemRightClick)
        self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.OnItemExpanding)
        self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.OnItemCollapsed)
        self.AppendPrograms()
コード例 #3
0
    def __init__(self, parent, startFunc, endFunc):
        self.startFunc = startFunc
        self.endFunc = endFunc

        self.text = eg.plugins.Window.FindWindow.text
        wx.PyWindow.__init__(self, parent, -1, style=wx.SIMPLE_BORDER)
        self.SetBackgroundColour(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)
        )
        self.lastTarget = None

        # load images
        self.dragBoxBitmap = GetInternalBitmap("findert")
        image = GetInternalImage('findertc')
        image.SetMaskColour(255, 0, 0)

        # since this image didn't come from a .cur file, tell it where the
        # hotspot is
        image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 15)
        image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 16)

        # make the image into a cursor
        self.cursor = wx.CursorFromImage(image)

        # the image of the drag target
        dragBoxImage = wx.StaticBitmap(self, -1, self.dragBoxBitmap)
        dragBoxImage.SetMinSize(self.dragBoxBitmap.GetSize())
        dragBoxImage.Bind(wx.EVT_LEFT_DOWN, self.OnDragboxClick)
        self.dragBoxImage = dragBoxImage

        # some description for the drag target
        dragBoxText = wx.StaticText(
            self,
            -1,
            self.text.drag2,
            style=wx.ALIGN_CENTRE
        )
        x1, y1 = dragBoxText.GetBestSize()
        dragBoxText.SetLabel(self.text.drag1)
        x2, y2 = dragBoxText.GetBestSize()
        dragBoxText.SetMinSize((max(x1, x2), max(y1, y2)))
        #dragBoxText.Bind(wx.EVT_LEFT_DOWN, self.OnDragboxClick)
        self.dragBoxText = dragBoxText

        self.Bind(wx.EVT_SIZE, self.OnSize)

        # put our drag target together
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(dragBoxImage, 0, wx.ALIGN_CENTER_VERTICAL)
        sizer.Add(dragBoxText, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL)
        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        sizer.Fit(self)
        self.SetMinSize(self.GetSize())
        wx.CallAfter(self.dragBoxImage.SetBitmap, self.dragBoxBitmap)
コード例 #4
0
ファイル: WindowList.py プロジェクト: maffe/EventGhost
 def __init__(self, parent, hwnds):
     wx.ListCtrl.__init__(self,
                          parent,
                          style=wx.LC_REPORT | wx.LC_SINGLE_SEL)
     listmix.ListCtrlAutoWidthMixin.__init__(self)
     imageList = wx.ImageList(16, 16)
     imageList.Add(GetInternalBitmap("cwindow"))
     self.AssignImageList(imageList, wx.IMAGE_LIST_SMALL)
     self.InsertColumn(0, "Program")
     self.InsertColumn(1, "Name")
     self.InsertColumn(2, "Class")
     self.InsertColumn(3, "Handle", wx.LIST_FORMAT_RIGHT)
     for hwnd in hwnds:
         imageIdx = 0
         icon = GetHwndIcon(hwnd)
         if icon:
             imageIdx = imageList.AddIcon(icon)
         idx = self.InsertImageStringItem(sys.maxint,
                                          GetWindowProcessName(hwnd),
                                          imageIdx)
         self.SetStringItem(idx, 1, GetWindowText(hwnd))
         self.SetStringItem(idx, 2, GetClassName(hwnd))
         self.SetStringItem(idx, 3, str(hwnd))
     for i in range(4):
         self.SetColumnWidth(i, -2)
         headerSize = self.GetColumnWidth(i)
         self.SetColumnWidth(i, -1)
         labelSize = self.GetColumnWidth(i)
         if headerSize > labelSize:
             self.SetColumnWidth(i, headerSize)
コード例 #5
0
 def createBrowseButton(self):
     """Create the browse-button control"""
     button = wx.BitmapButton(self, -1, GetInternalBitmap("searchFolder"))
     width, height = button.GetSize()
     button.SetMinSize((width + 8, height))
     button.SetToolTipString(self.toolTip)
     button.Bind(wx.EVT_BUTTON, self.OnBrowse)
     return button
コード例 #6
0
 def __init__(self,
              parent,
              id=-1,
              pos=wx.DefaultPosition,
              size=(40, wx.Button.GetDefaultSize()[1]),
              style=wx.BU_AUTODRAW,
              validator=wx.DefaultValidator,
              name="FontSelectButton",
              value=None):
     self.value = value
     wx.BitmapButton.__init__(self, parent, id, GetInternalBitmap("font"),
                              pos, size, style, validator, name)
     self.Bind(wx.EVT_BUTTON, self.OnButton)
コード例 #7
0
    def CreateTreePopupMenu(self):
        """
        Creates the pop-up menu for the configuration tree.
        """
        menu = wx.Menu()
        text = Text.Menu

        def Append(ident, kind=wx.ITEM_NORMAL, image=wx.NullBitmap):
            item = wx.MenuItem(menu, ID[ident], getattr(text, ident), "", kind)
            item.SetBitmap(image)
            menu.AppendItem(item)
            return item

        Append("Expand", image=GetInternalBitmap("expand"))
        Append("Collapse", image=GetInternalBitmap("collapse"))
        Append("ExpandChilds", image=GetInternalBitmap("expand_children"))
        Append("CollapseChilds", image=GetInternalBitmap("collapse_children"))
        Append("ExpandAll", image=GetInternalBitmap("expand_all"))
        Append("CollapseAll", image=GetInternalBitmap("collapse_all"))
        subm = menu
        menu = wx.Menu()

        Append("Undo")
        Append("Redo")
        menu.AppendSeparator()
        Append("Cut")
        Append("Copy")
        Append("Python")
        Append("Paste")
        Append("Delete")
        menu.AppendSeparator()
        menu.AppendMenu(wx.ID_ANY, text=text.ExpandCollapseMenu, submenu=subm)
        menu.AppendSeparator()
        Append("AddPlugin", image=ADD_PLUGIN_ICON)
        Append("AddFolder", image=ADD_FOLDER_ICON)
        Append("AddMacro", image=ADD_MACRO_ICON)
        Append("AddEvent", image=ADD_EVENT_ICON)
        Append("AddAction", image=ADD_ACTION_ICON)
        menu.AppendSeparator()
        Append("Configure")
        Append("Rename")
        Append("Execute")
        menu.AppendSeparator()
        Append("Disabled", kind=wx.ITEM_CHECK)
        return menu
コード例 #8
0
 def __init__(self, parent):
     wx.PyWindow.__init__(self, parent)
     self.font = wx.Font(40, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_ITALIC,
                         wx.FONTWEIGHT_BOLD)
     self.SetBackgroundColour((255, 255, 255))
     self.logo1 = GetInternalBitmap("opensource-55x48")
     self.logo2 = GetInternalBitmap("python-powered")
     self.logo3 = GetInternalBitmap("logo2")
     self.image = GetInternalImage("logo")
     self.bmpWidth = self.image.GetWidth()
     self.bmpHeight = self.image.GetHeight()
     self.time = clock()
     self.count = 0
     self.Bind(wx.EVT_SIZE, self.OnSize)
     self.Bind(wx.EVT_TIMER, self.UpdateDrawing)
     self.OnSize(None)
     self.timer = wx.Timer(self)
     self.timer.Start(10)
コード例 #9
0
    def CreateToolBar(self):
        """
        Creates the toolbar of the frame.
        """
        toolBar = wx.ToolBar(self, style=wx.TB_FLAT)
        toolBar.SetToolBitmapSize((16, 16))
        text = Text.Menu

        def Append(ident, image):
            toolBar.AddSimpleTool(ID[ident], image, getattr(text, ident))

        Append("New", GetInternalBitmap("New"))
        Append("Open", GetInternalBitmap("Open"))
        Append("Save", GetInternalBitmap("Save"))
        toolBar.AddSeparator()
        Append("Cut", GetInternalBitmap("Cut"))
        Append("Copy", GetInternalBitmap("Copy"))
        Append("Python", GetInternalBitmap("Python"))
        Append("Paste", GetInternalBitmap("Paste"))
        toolBar.AddSeparator()
        Append("Undo", GetInternalBitmap("Undo"))
        Append("Redo", GetInternalBitmap("Redo"))
        toolBar.AddSeparator()
        Append("AddPlugin", ADD_PLUGIN_ICON)
        Append("AddFolder", ADD_FOLDER_ICON)
        Append("AddMacro", ADD_MACRO_ICON)
        Append("AddEvent", ADD_EVENT_ICON)
        Append("AddAction", ADD_ACTION_ICON)
        toolBar.AddSeparator()
        Append("Disabled", GetInternalBitmap("Disabled"))
        toolBar.AddSeparator()
        # the execute button must be added with unique id, because otherwise
        # the menu command OnCmdExecute will be used in conjunction to
        # our special mouse click handlers
        toolBar.AddSimpleTool(ID_TOOLBAR_EXECUTE, GetInternalBitmap("Execute"),
                              getattr(text, "Execute"))
        toolBar.AddSeparator()
        Append("Expand", GetInternalBitmap("expand"))
        Append("Collapse", GetInternalBitmap("collapse"))
        Append("ExpandChilds", GetInternalBitmap("expand_children"))
        Append("CollapseChilds", GetInternalBitmap("collapse_children"))
        Append("ExpandAll", GetInternalBitmap("expand_all"))
        Append("CollapseAll", GetInternalBitmap("collapse_all"))

        toolBar.EnableTool(wx.ID_SAVE, self.document.isDirty)
        toolBar.Realize()
        self.SetToolBar(toolBar)

        toolBar.Bind(wx.EVT_LEFT_DOWN, self.OnToolBarLeftDown)
        toolBar.Bind(wx.EVT_LEFT_UP, self.OnToolBarLeftUp)
        return toolBar
コード例 #10
0
    def CreateMenuBar(self):
        """
        Creates the main menu bar and all its menus.
        """
        text = Text.Menu
        menuBar = wx.MenuBar()

        def Append(ident, hotkey="", kind=wx.ITEM_NORMAL, image=None):
            label = getattr(text, ident, ident)
            item = wx.MenuItem(menu, ID[ident], label + hotkey, "", kind)
            if image:
                item.SetBitmap(image)
            menu.AppendItem(item)
            func = getattr(self, "OnCmd" + ident)

            def FuncWrapper(dummyEvent):
                func()

            self.Bind(wx.EVT_MENU, FuncWrapper, item)
            return item

        # file menu
        menu = wx.Menu()
        menuBar.Append(menu, text.FileMenu)
        Append("New", "\tCtrl+N")
        Append("Open", "\tCtrl+O")
        Append("Save", "\tCtrl+S").Enable(False)
        Append("SaveAs", "\tShift+Ctrl+S")
        menu.AppendSeparator()
        Append("Options", "\tCtrl+P")
        menu.AppendSeparator()
        Append("Restart", "\tShift+Ctrl+~")
        Append("RestartAsAdmin")
        menu.AppendSeparator()
        Append("Exit")

        # edit menu
        menu = wx.Menu()
        menuBar.Append(menu, text.EditMenu)
        Append("Undo", "\tCtrl+Z")
        Append("Redo", "\tCtrl+Y")
        menu.AppendSeparator()
        Append("Cut", "\tCtrl+X")
        Append("Copy", "\tCtrl+C")
        Append("Python", "\tShift+Ctrl+C")
        Append("Paste", "\tCtrl+V")
        # notice that we add a ascii zero byte at the end of the hotkey.
        # this way we prevent the normal accelerator to happen. We will later
        # catch the key ourself.
        oldLogging = wx.Log.EnableLogging(False)  # suppress warning
        Append("Delete", "\tDel\x00")
        wx.Log.EnableLogging(oldLogging)
        menu.AppendSeparator()
        Append("Find", "\tCtrl+F")
        Append("FindNext", "\tF3")

        # view menu
        menu = wx.Menu()
        menuBar.Append(menu, text.ViewMenu)
        Append("HideShowToolbar", kind=wx.ITEM_CHECK).Check(Config.showToolbar)
        menu.AppendSeparator()
        Append("Expand", image=GetInternalBitmap("expand"))
        Append("Collapse", image=GetInternalBitmap("collapse"))
        Append("ExpandChilds", image=GetInternalBitmap("expand_children"))
        Append("CollapseChilds", image=GetInternalBitmap("collapse_children"))
        Append("ExpandAll", image=GetInternalBitmap("expand_all"))
        Append("CollapseAll", image=GetInternalBitmap("collapse_all"))
        menu.AppendSeparator()
        item = Append("ExpandOnEvents", kind=wx.ITEM_CHECK)
        item.Check(Config.expandOnEvents)
        menu.AppendSeparator()
        Append("LogMacros", kind=wx.ITEM_CHECK).Check(eg.config.logMacros)
        Append("LogActions", kind=wx.ITEM_CHECK).Check(eg.config.logActions)
        Append("LogDebug", kind=wx.ITEM_CHECK).Check(eg.config.logDebug)
        menu.AppendSeparator()
        Append("IndentLog", kind=wx.ITEM_CHECK).Check(Config.indentLog)
        Append("LogDate", kind=wx.ITEM_CHECK).Check(Config.logDate)
        Append("LogTime", kind=wx.ITEM_CHECK).Check(Config.logTime)
        menu.AppendSeparator()
        Append("ClearLog")

        # configuration menu
        menu = wx.Menu()
        menuBar.Append(menu, text.ConfigurationMenu)
        Append("AddPlugin", "\tShift+Ctrl+P", image=ADD_PLUGIN_ICON)
        Append("AddFolder", "\tShift+Ctrl+N", image=ADD_FOLDER_ICON)
        Append("AddMacro", "\tShift+Ctrl+M", image=ADD_MACRO_ICON)
        Append("AddEvent", "\tShift+Ctrl+E", image=ADD_EVENT_ICON)
        Append("AddAction", "\tShift+Ctrl+A", image=ADD_ACTION_ICON)
        menu.AppendSeparator()
        Append("Configure", "\tReturn")
        Append("Rename", "\tF2")
        Append("Execute", "\tF5")
        menu.AppendSeparator()
        Append("Disabled", "\tCtrl+D", kind=wx.ITEM_CHECK)

        # help menu
        menu = wx.Menu()
        menuBar.Append(menu, text.HelpMenu)
        Append("HelpContents", "\tF1")
        menu.AppendSeparator()
        Append("WebHomepage")
        Append("WebForum")
        Append("WebWiki")
        menu.AppendSeparator()
        Append("CheckUpdate")
        menu.AppendSeparator()
        Append("PythonShell", "\tShift+Ctrl+I")
        Append("WIT")
        menu.AppendSeparator()
        Append("About")

        self.SetMenuBar(menuBar)
        return menuBar
コード例 #11
0
class WindowDragFinder(wx.PyWindow):
    def __init__(self, parent, startFunc, endFunc):
        self.startFunc = startFunc
        self.endFunc = endFunc

        self.text = eg.plugins.Window.FindWindow.text
        wx.PyWindow.__init__(self, parent, -1, style=wx.SIMPLE_BORDER)
        self.SetBackgroundColour(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)
        )
        self.lastTarget = None

        # load images
        self.dragBoxBitmap = GetInternalBitmap("findert")
        image = GetInternalImage('findertc')
        image.SetMaskColour(255, 0, 0)

        # since this image didn't come from a .cur file, tell it where the
        # hotspot is
        image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 15)
        image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 16)

        # make the image into a cursor
        self.cursor = wx.CursorFromImage(image)

        # the image of the drag target
        dragBoxImage = wx.StaticBitmap(self, -1, self.dragBoxBitmap)
        dragBoxImage.SetMinSize(self.dragBoxBitmap.GetSize())
        dragBoxImage.Bind(wx.EVT_LEFT_DOWN, self.OnDragboxClick)
        self.dragBoxImage = dragBoxImage

        # some description for the drag target
        dragBoxText = wx.StaticText(
            self,
            -1,
            self.text.drag2,
            style=wx.ALIGN_CENTRE
        )
        x1, y1 = dragBoxText.GetBestSize()
        dragBoxText.SetLabel(self.text.drag1)
        x2, y2 = dragBoxText.GetBestSize()
        dragBoxText.SetMinSize((max(x1, x2), max(y1, y2)))
        #dragBoxText.Bind(wx.EVT_LEFT_DOWN, self.OnDragboxClick)
        self.dragBoxText = dragBoxText

        self.Bind(wx.EVT_SIZE, self.OnSize)

        # put our drag target together
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(dragBoxImage, 0, wx.ALIGN_CENTER_VERTICAL)
        sizer.Add(dragBoxText, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL)
        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        sizer.Fit(self)
        self.SetMinSize(self.GetSize())
        wx.CallAfter(self.dragBoxImage.SetBitmap, self.dragBoxBitmap)

    @eg.LogIt
    def AcceptsFocusFromKeyboard(self):
        return False

    def GetValue(self):
        return self.lastTarget

    def OnDrag(self, event):
        # get the mouse coordinates
        point = GetCursorPos()
        # find the window under cursor
        hwnd = BestWindowFromPoint(point)
        # do we have targeted a new window?
        if hwnd != self.lastTarget:
            if self.lastTarget is not None:
                # unhighlight previous window
                HighlightWindow(self.lastTarget)
            _, pid = GetWindowThreadProcessId(hwnd)
            if pid == eg.processId:
                self.lastTarget = None
            else:
                HighlightWindow(hwnd)
                self.lastTarget = hwnd
        event.Skip()

    @eg.LogIt
    def OnDragboxClick(self, event):
        """ Handle left-click on findtool
        """
        if self.HasCapture():
            event.Skip()
            return
        self.startFunc()

        #nothing targeted in the beginning
        self.lastTarget = None

        wx.SetCursor(self.cursor)

        # hide the image while dragging
        self.dragBoxImage.Hide()
        self.dragBoxText.SetLabel(self.text.drag2)
        self.Layout()

        # from now on we want all mouse motion events
        self.Bind(wx.EVT_MOTION, self.OnDrag)
        # and the left up event
        self.Bind(wx.EVT_LEFT_UP, self.OnDragEnd)

        # and call Skip in for handling focus events etc.
        event.ResumePropagation(wx.EVENT_PROPAGATE_MAX)
        event.Skip()
        # start capturing the mouse exclusivly
        self.CaptureMouse()

    def OnDragEnd(self, dummyEvent):
        # unbind the unneeded events
        self.Unbind(wx.EVT_MOTION)
        self.Unbind(wx.EVT_LEFT_UP)

        # stop processing the mouse capture
        self.ReleaseMouse()

        if self.lastTarget is not None:
            # unhighlight last window if we have highlighted one
            HighlightWindow(self.lastTarget)

        self.endFunc()

        # revert box to normal image
        self.dragBoxText.SetLabel(self.text.drag1)
        self.dragBoxImage.Show()
        self.Layout()
        self.dragBoxImage.SetBitmap(self.dragBoxBitmap)

    def OnSize(self, dummyEvent):
        """
        Handles the wx.EVT_SIZE events.
        """
        if self.GetAutoLayout():
            self.Layout()
            self.dragBoxImage.SetBitmap(self.dragBoxBitmap)
コード例 #12
0
class AnimatedWindow(wx.PyWindow):
    def __init__(self, parent):
        wx.PyWindow.__init__(self, parent)
        self.font = wx.Font(40, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_ITALIC,
                            wx.FONTWEIGHT_BOLD)
        self.SetBackgroundColour((255, 255, 255))
        self.logo1 = GetInternalBitmap("opensource-55x48")
        self.logo2 = GetInternalBitmap("python-powered")
        self.logo3 = GetInternalBitmap("logo2")
        self.image = GetInternalImage("logo")
        self.bmpWidth = self.image.GetWidth()
        self.bmpHeight = self.image.GetHeight()
        self.time = clock()
        self.count = 0
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_TIMER, self.UpdateDrawing)
        self.OnSize(None)
        self.timer = wx.Timer(self)
        self.timer.Start(10)

    def AcceptsFocus(self):
        return False

    def AcceptsFocusFromKeyboard(self):
        return False

    def Draw(self, deviceContext):
        deviceContext.BeginDrawing()
        deviceContext.DrawBitmap(self.backbuffer, 0, 0, False)
        t = clock() / 2.0
        y3 = self.y3
        x3 = self.x3
        y = (sin(t) + sin(1.8 * t)) * y3 + y3 * 2.0
        x = (sin(t * 0.8) + sin(1.9 * t)) * x3 + x3 * 2.0
        alpha = sin(t) / 2.0 + 0.5
        image = self.image.AdjustChannels(1.0, 1.0, 1.0, alpha)
        bmp = wx.BitmapFromImage(image, 24)
        deviceContext.DrawBitmap(bmp, x, y, True)
        deviceContext.EndDrawing()

    def MakeBackground(self):
        self.backbuffer = wx.EmptyBitmap(self.width, self.height)
        deviceContext = wx.MemoryDC()
        deviceContext.SelectObject(self.backbuffer)
        deviceContext.BeginDrawing()
        deviceContext.SetBackground(wx.Brush(self.GetBackgroundColour()))
        deviceContext.Clear()  # make sure you clear the bitmap!
        deviceContext.SetFont(self.font)
        deviceContext.SetTextForeground((128, 128, 128))

        width1 = self.logo1.GetWidth()
        width2 = self.logo2.GetWidth()
        height1 = self.logo1.GetHeight()
        height2 = self.logo2.GetHeight()
        height = max(height1, height2)

        deviceContext.DrawBitmap(
            self.logo1, self.width - width1 - width2,
            self.height - height + (height - height1) // 2, True)
        deviceContext.DrawBitmap(
            self.logo2, self.width - width2,
            self.height - height + (height - height2) // 2, True)
        deviceContext.DrawBitmap(self.logo3,
                                 (self.width - self.logo3.GetWidth()) // 2,
                                 (self.height - self.logo3.GetHeight()) // 3,
                                 True)
        deviceContext.EndDrawing()

    def OnSize(self, dummyEvent):
        self.width, self.height = self.GetClientSizeTuple()
        self.dcBuffer = wx.EmptyBitmap(self.width, self.height)
        self.y3 = (self.height - self.bmpHeight) / 4.0
        self.x3 = (self.width - self.bmpWidth) / 4.0
        self.MakeBackground()
        self.UpdateDrawing()

    def UpdateDrawing(self, dummyEvent=None):
        deviceContext = wx.BufferedDC(wx.ClientDC(self), self.dcBuffer)
        self.Draw(deviceContext)
コード例 #13
0
    def CreateMenuBar(self):
        """
        Creates the main menu bar and all its menus.
        """
        text = Text.Menu
        menuBar = wx.MenuBar()

        def Append(ident, hotkey="", kind=wx.ITEM_NORMAL, image=None):
            label = getattr(text, ident, ident)
            item = wx.MenuItem(menu, ID[ident], label + hotkey, "", kind)
            if image:
                item.SetBitmap(image)
            menu.AppendItem(item)
            func = getattr(self, "OnCmd" + ident)

            def FuncWrapper(dummyEvent):
                func()

            self.Bind(wx.EVT_MENU, FuncWrapper, item)
            return item

        # file menu
        menu = wx.Menu()
        menuBar.Append(menu, text.FileMenu)
        Append("New", "\tCtrl+N")
        Append("Open", "\tCtrl+O")
        Append("Save", "\tCtrl+S").Enable(False)
        Append("SaveAs")
        menu.AppendSeparator()
        Append("Options", "\tCtrl+P")
        Append("Editconfig", "\tShift+Ctrl+W")
        Append("ProgramFiles", "\tShift+Ctrl+Q")
        Append("GhostFiles", "\tShift+Ctrl+G")
        Append("Pycharm", "\tShift+Ctrl+Y")
        menu.AppendSeparator()
        Append("Restart")
        Append("RestartAsAdmin", "\tShift+Ctrl+~")
        menu.AppendSeparator()
        Append("Exit")

        # edit menu
        menu = wx.Menu()
        menuBar.Append(menu, text.EditMenu)
        Append("Undo", "\tCtrl+Z")
        Append("Redo", "\tCtrl+Y")
        menu.AppendSeparator()
        Append("Cut", "\tCtrl+X")
        Append("Copy", "\tCtrl+C")
        Append("Python", "\tShift+Ctrl+C")
        Append("Paste", "\tCtrl+V")
        # notice that we add a ascii zero byte at the end of the hotkey.
        # this way we prevent the normal accelerator to happen. We will later
        # catch the key ourself.
        oldLogging = wx.Log.EnableLogging(False)  # suppress warning
        Append("Delete", "\tDel\x00")
        wx.Log.EnableLogging(oldLogging)
        menu.AppendSeparator()
        Append("Find", "\tCtrl+F")
        Append("FindNext", "\tShift+Ctrl+F")

        # view menu
        menu = wx.Menu()
        menuBar.Append(menu, text.ViewMenu)
        Append("HideShowToolbar", kind=wx.ITEM_CHECK).Check(Config.showToolbar)
        Append("TogAtop", kind=wx.ITEM_CHECK).Check(Config.TogAtop)
        menu.AppendSeparator()
        Append("Expand", image=GetInternalBitmap("expand"))
        Append("Collapse", image=GetInternalBitmap("collapse"))
        Append("ExpandChilds", image=GetInternalBitmap("expand_children"))
        Append("CollapseChilds", image=GetInternalBitmap("collapse_children"))
        Append("ExpandAll", image=GetInternalBitmap("expand_all"))
        Append("CollapseAll",
               "\tShift+Ctrl+Home",
               image=GetInternalBitmap("collapse_all"))
        menu.AppendSeparator()
        item = Append("ExpandOnEvents", kind=wx.ITEM_CHECK)
        item.Check(Config.expandOnEvents)
        menu.AppendSeparator()
        Append("LogMacros", kind=wx.ITEM_CHECK).Check(eg.config.logMacros)
        Append("LogActions", kind=wx.ITEM_CHECK).Check(eg.config.logActions)
        Append("LogDebug", kind=wx.ITEM_CHECK).Check(eg.config.logDebug)
        menu.AppendSeparator()
        Append("IndentLog", kind=wx.ITEM_CHECK).Check(Config.indentLog)
        Append("LogDate", kind=wx.ITEM_CHECK).Check(Config.logDate)
        Append("LogTime", kind=wx.ITEM_CHECK).Check(Config.logTime)
        menu.AppendSeparator()
        Append("ClearLog", "\tCtrl+L")

        # configuration menu
        menu = wx.Menu()
        menuBar.Append(menu, text.ConfigurationMenu)
        Append("AddPlugin", "\tShift+Ctrl+P", image=ADD_PLUGIN_ICON)
        Append("AddFolder", "\tShift+Ctrl+N", image=ADD_FOLDER_ICON)
        Append("AddMacro", "\tShift+Ctrl+M", image=ADD_MACRO_ICON)
        Append("AddEvent", "\tShift+Ctrl+E", image=ADD_EVENT_ICON)
        Append("AddAction", "\tShift+Ctrl+A", image=ADD_ACTION_ICON)
        menu.AppendSeparator()
        Append("Configure", "\tReturn")
        Append("Rename", "\tF2")
        Append("Execute", "\tCtrl+Return")
        menu.AppendSeparator()
        Append("Disabled", "\tCtrl+D", kind=wx.ITEM_CHECK)

        # build menu
        menu = wx.Menu()
        Append("Script1")
        Append("Script2")
        Append("Script3")
        Append("Script4")
        subm = menu
        menu = wx.Menu()
        Append("Index1", "\tF6")
        Append("Index2")
        Append("Index3")
        Append("Index4")
        #menu.AppendSeparator()
        #menu.AppendMenu(wx.ID_ANY, text=text.ScriptsmMenu, submenu=subm)
        subm2 = menu

        menu = wx.Menu()
        menuBar.Append(menu, text.BuildMenu)
        Append("ColorCodes")
        Append("IconLibrary")
        Append("GuidGenerator")
        menu.AppendSeparator()
        menu.AppendMenu(wx.ID_ANY, text=text.ScriptsmMenu, submenu=subm)
        menu.AppendSeparator()
        menu.AppendMenu(wx.ID_ANY, text=text.IndexsmMenu, submenu=subm2)
        menu.AppendSeparator()
        Append("FlaskDoc")
        Append("Wxdoc")
        Append("ScptransferDoc")

        # build menu
        menu = wx.Menu()
        Append("Vortexhomepage")
        Append("VortexMulewall")
        Append("Vortex425riverside")
        Append("VortexCapitol")
        Append("VortexAudi")
        submVortex = menu
        menu = wx.Menu()
        Append("Amphomepage")
        Append("AmpMulewall")
        Append("Ampriverside")
        Append("AmpCapitol")
        Append("AmpAudi")
        submAmp = menu

        menu = wx.Menu()
        Append("Sharepointhomepage")
        Append("SharepointHaywardbaker")
        Append("SharepointMulewall")
        Append("Sharepointriverside")
        Append("SharepointCapitol")
        Append("SharepointAudi")
        submSharepoint = menu
        menu = wx.Menu()
        menuBar.Append(menu, text.JobMenu)
        Append("JobSelector")
        Append("Alarmtools")
        menu.AppendSeparator()
        menu.AppendMenu(wx.ID_ANY, text=text.AmpMenu, submenu=submAmp)
        menu.AppendMenu(wx.ID_ANY, text=text.VortexMenu, submenu=submVortex)
        Append("Quickview")
        menu.AppendSeparator()
        menu.AppendMenu(wx.ID_ANY,
                        text=text.SharepointMenu,
                        submenu=submSharepoint)
        menu.AppendSeparator()
        Append("Certify")
        Append("ScreenConnect")

        # help menu
        menu = wx.Menu()
        menuBar.Append(menu, text.HelpMenu)
        Append("Workspace", "\tF1")
        menu.AppendSeparator()
        Append("WebHomepage", "\tF7")
        Append("WebForum", "\tF3")
        Append("Webserver", "\tF4")
        menu.AppendSeparator()
        Append("CheckUpdate")
        menu.AppendSeparator()
        Append("Terminal", "\tShift+Ctrl+T")
        Append("PythonShell", "\tShift+Ctrl+I")
        Append("WIT")
        menu.AppendSeparator()
        Append("About")

        self.SetMenuBar(menuBar)
        return menuBar