示例#1
0
 def createFonts(self):
     self.fonts = {}
     font = Font()
     font.SetFaceName("Monospace")
     font.SetPointSize(10)
     self.fonts['monospace'] = font
     return
示例#2
0
def createFont(name='mono', face="Monospace", size=10):
    # make font
    font = Font()
    font.SetFaceName(face)
    font.SetPointSize(size)
    # add to dictionary
    _fonts[name] = font
    # done
    return
示例#3
0
 def _createFont(self, name, face, size):
     # make font
     font = Font()
     font.SetFaceName(face)
     font.SetPointSize(size)
     # add to dictionary
     self._fonts[name] = font
     # done
     return
示例#4
0
 def createFonts(self):
     # FONTS
     self.fonts = {}
     # monospace
     font = Font()
     font.SetFaceName("Monospace")
     font.SetPointSize(10)
     self.fonts['monospace'] = font
     # done
     return
示例#5
0
文件: core.py 项目: nilanjan/map
 def setFontFromDC(self, dc):
     font = dc.GetFont()
     self.c_font = font
     self.c_bold_font = Font(self.c_font)
     self.c_bold_font.MakeBold()
     if self.c_font.IsFixedWidth():
         wx_str = 'm'  # Some character... it's fixed pitch
         size = dc.GetTextExtent(wx_str)
         self.c_char_width, self.c_char_height = size
         assert self.c_char_width != None
         assert self.c_char_height != None
示例#6
0
文件: 2048.py 项目: absop/2048
    def DrawTabs(self, dc, score, best, arrow):
        dc.DrawRoundedRectangle(self.boundary, 8.0)

        dc.SetFont(Font(FontInfo(20).Bold(2)))
        dc.SetTextForeground(self.title_name_color)
        dc.DrawLabel("SCORE", self.score_caption, wx.ALIGN_CENTER)
        dc.DrawLabel("BEST", self.best_caption, wx.ALIGN_CENTER)
        dc.DrawLabel("KEY", self.arrow_caption, wx.ALIGN_CENTER)

        dc.SetFont(Font(FontInfo(16).Bold(2)))
        dc.SetTextForeground(self.title_value_color)
        dc.DrawLabel(score, self.score_content, wx.ALIGN_CENTER)
        dc.DrawLabel(best, self.best_content, wx.ALIGN_CENTER)
        dc.DrawLabel(arrow, self.arrow_content, wx.ALIGN_CENTER)
示例#7
0
    def __init__(self, pyutObject=None, width: float = 0, height: float = 0):
        """
        Constructor

        @param PyutObject pyutObject : Associated PyutObject
        @param int width  : Initial width
        @param int height : Initial height
        @since 1.0
        @author Philippe Waelti <*****@*****.**>
        """
        RectangleShape.__init__(self, 0, 0, width, height)

        self.logger: Logger = getLogger(__name__)
        self._pyutObject = pyutObject
        """
        Associated PyutObject
        """
        # Default font
        self._defaultFont: Font = Font(DEFAULT_FONT_SIZE, FONTFAMILY_SWISS,
                                       FONTSTYLE_NORMAL, FONTWEIGHT_NORMAL)

        # Connected links
        self._oglLinks = []
        # added by P.Dabrowski 20051202 : it's the command to undo/redo a modification on this object.
        self._modifyCommand = None
示例#8
0
    def __init__(self, pyutClass: PyutClass = None, w: int = 0, h: int = 0):
        """

        Args:
            pyutClass:  a PyutClass object
            w:  Width of the shape
            h:  Height of the shape
        """
        if pyutClass is None:
            pyutObject = PyutClass()
        else:
            pyutObject = pyutClass

        width: int = w
        height: int = h

        # Use preferences to get initial size if not specified
        # Note: auto_resize_shape_on_edit must be False for this size to actually stick
        preferences: PyutPreferences = PyutPreferences()

        if w == 0:
            width = preferences.classDimensions.width
        if h == 0:
            height = preferences.classDimensions.height

        super().__init__(pyutObject, width=width, height=height)

        self._nameFont: Font = Font(DEFAULT_FONT_SIZE, FONTFAMILY_SWISS,
                                    FONTSTYLE_NORMAL, FONTWEIGHT_BOLD)
        self.logger: Logger = getLogger(__name__)
示例#9
0
    def __init__(self, pyutObject: PyutSDInstance, x: int, y: int, text: str, parent=None):
        """
        """
        self._pyutObject = pyutObject

        self._defaultFont = Font(OglInstanceName.TEXT_SHAPE_FONT_SIZE, FONTFAMILY_TELETYPE, FONTSTYLE_ITALIC, FONTWEIGHT_NORMAL)

        TextShape.__init__(self, x, y, text, parent=parent, font=self._defaultFont)
示例#10
0
    def __init__(self, parent):
        BaseWindowPanel.__init__(self,
                                 parent,
                                 bg_color=Colour.BLACK,
                                 fg_color=Colour.WHITE)

        self._caption_label = StaticText(self,
                                         pos=(70, 5),
                                         size=(20, 0),
                                         label=u"This month, we spent")
        self._caption_label.SetFont(
            Font(13, FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL, FONTWEIGHT_NORMAL))

        self._display = LEDNumberCtrl(self,
                                      pos=(0, 30),
                                      size=(320, 90),
                                      style=LED_ALIGN_RIGHT)
        self._display.SetValue("0.00")

        self._date_display = LEDNumberCtrl(self,
                                           pos=(110, 150),
                                           size=(210, 40),
                                           style=LED_ALIGN_RIGHT)
        self._date_display.SetValue("--.--.--")

        self._clock_display = LEDNumberCtrl(self,
                                            pos=(110, 190),
                                            size=(210, 50),
                                            style=LED_ALIGN_RIGHT)
        self._clock_display.SetValue("--.--.--")

        self.open_button = Button(self,
                                  -1,
                                  "Add",
                                  pos=(10, 125),
                                  size=(70, 35))
        self.open_button.SetBackgroundColour(Colour.DARK_GREEN)
        self.open_button.SetForegroundColour(Colour.WHITE)

        self.list_button = Button(self,
                                  -1,
                                  "List",
                                  pos=(10, 160),
                                  size=(70, 35))
        self.list_button.SetBackgroundColour(get_colour(0x333333))
        self.list_button.SetForegroundColour(Colour.WHITE)

        self.close_button = Button(self,
                                   -1,
                                   "Close",
                                   pos=(10, 195),
                                   size=(70, 35))
        self.close_button.SetBackgroundColour(Colour.DARK_RED)
        self.close_button.SetForegroundColour(Colour.WHITE)

        self._timer = Timer(self)
        self._timer.Start(100)
        self.Bind(EVT_TIMER, self.on_clock_update, self._timer)
示例#11
0
文件: 2048.py 项目: absop/2048
 def DrawCells(self, dc):
     for row in range(4):
         for col in range(4):
             rect = wx.Rect(col * 120, row * 120, 120, 120)
             dc.SetBrush(wx.Brush(self.background(row, col)))
             dc.DrawRoundedRectangle(rect, 10.0)
             if self.grid.cells[row][col]:
                 number = "%d" % self.grid.cells[row][col]
                 dc.SetFont(Font(FontInfo([16, 20][len(number) < 5])))
                 dc.DrawLabel(number, rect, wx.ALIGN_CENTER)
示例#12
0
def StorageToFont(s):
    font = Font(s.size, FONTFAMILY_DEFAULT,
                wx.FONTSTYLE_ITALIC if s.italic else wx.FONTSTYLE_NORMAL,
                wx.FONTWEIGHT_BOLD if s.bold else wx.FONTWEIGHT_NORMAL,
                s.underline, s.face)

    fgc = s.foregroundcolor
    bgc = s.backgroundcolor

    return font, fgc, bgc
 def _setBrailleFont(self, font: wx.Font) -> wx.Font:
     fonts.importFonts()
     fontName = "FreeMono-FixedBraille"
     # Ideally the raw characters should align with the braille dots.
     #
     # On most systems, it seems that Windows will fall back to using "Segoe UI Symbol" font.
     # The width of BRAILLE_SPACE_CHARACTER ('no pins up') does not match the other braille characters.
     # This causes variations in the length of the braille text, particularly when the cursor is flashing.
     # The other disadvantage of using this font is that it is difficult to get its width to match the width
     # of the raw text characters.
     # These issues are solved by using a custom font (FreeMono-FixedBraille), which due to its free (GPL 3)
     # status, allowed us to modify it, and fix the visual issues that it also had.
     #
     # Remaining visual issues:
     # Some words when translated to braille have more characters than the raw text.
     # This may be because there is a leading "number" or "capital letter" cell.
     # Currently we do not handle this.
     font.SetPointSize(20)
     font.SetFaceName(fontName)
     return font
示例#14
0
    def __init__(self, dpi=(1, 1)):
        width = 300 * dpi[0]
        height = 80 * dpi[1]
        screenSize = DisplaySize()
        x = screenSize[0] - width - 10 * dpi[0],
        y = screenSize[1] - height - 100 * dpi[1]
        Frame.__init__(self,
                       parent=None,
                       id=ID_ANY,
                       pos=Point(x[0], y),
                       size=Size(width, height),
                       style=SIMPLE_BORDER | TRANSPARENT_WINDOW | STAY_ON_TOP
                       | FRAME_NO_TASKBAR,
                       name=EmptyString)

        bSizer4 = BoxSizer(VERTICAL)

        self.msgTitle = StaticText(self, ID_ANY, u"MyLabel", DefaultPosition,
                                   DefaultSize, 0)
        self.msgTitle.Wrap(-1)

        self.msgTitle.SetFont(
            Font(13, FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL, FONTWEIGHT_BOLD,
                 False, EmptyString))

        bSizer4.Add(self.msgTitle, 0, ALL, 5)

        self.msgContent = StaticText(self, ID_ANY, u"MyLabel", DefaultPosition,
                                     DefaultSize, 0)
        self.msgContent.Wrap(-1)

        self.msgContent.SetFont(
            Font(12, FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL, FONTWEIGHT_NORMAL,
                 False, EmptyString))

        bSizer4.Add(self.msgContent, 0, EXPAND, 5)

        self.SetSizer(bSizer4)
        self.Layout()
        # colorWhite = Colour(255, 255, 255)
        self.SetBackgroundColour(Colour(240, 240, 240))
示例#15
0
def font_attrs_from_storage(s):
    font = Font(s['size'],
                FONTFAMILY_DEFAULT,
                wx.FONTSTYLE_ITALIC if s['italic'] else wx.FONTSTYLE_NORMAL,
                wx.FONTWEIGHT_BOLD  if s['bold'] else wx.FONTWEIGHT_NORMAL,
                s['underline'],
                s['face'])

    fgc  = s['foregroundcolor']
    bgc  = s['backgroundcolor']

    return font, fgc, bgc
示例#16
0
def safefont(name, size, bold = False):
    weight = FONTWEIGHT_BOLD if bold else FONTWEIGHT_NORMAL

    try:
        return Font(size, FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL, weight, False, name)
    except:
        print_exc()

        font = default_font()
        font.SetPointSize(size)
        font.SetWeight(weight)
        return font
示例#17
0
    def __init__(self, srcShape, pyutLink, dstShape):
        """

        Args:
            srcShape:   Source shape
            pyutLink:   Conceptual links associated with the graphical links.
            dstShape:   Destination shape
        """
        super().__init__(srcShape, pyutLink, dstShape)

        self.logger: Logger = getLogger(__name__)
        # Add labels
        self._labels: TextShapes = cast(TextShapes, {})
        srcPos = srcShape.GetPosition()
        destPos = dstShape.GetPosition()

        linkLength: float = self._computeLinkLength(srcPosition=srcPos,
                                                    destPosition=destPos)
        dx, dy = self._computeDxDy(srcPosition=srcPos, destPosition=destPos)

        # cenLblX = -dy * 5 / linkLength
        # cenLblY = dx * 5 / linkLength
        cenLblX, cenLblY = self._computeMidPoint(srcPosition=srcPos,
                                                 destPosition=destPos)
        self.logger.debug(
            f'linkLength:  {linkLength:.2f}  cenLblX: {cenLblX:.2f} cenLblY: {cenLblY:.2f} dx: {dx}  dy: {dy}'
        )

        srcLblX = 20 * dx / linkLength  # - dy*5/l
        srcLblY = 20 * dy / linkLength  # + dx*5/l
        dstLblX = -20 * dx / linkLength  # + dy*5/l
        dstLblY = -20 * dy / linkLength  # - dy*5/l

        self._defaultFont = Font(OglAssociation.TEXT_SHAPE_FONT_SIZE,
                                 FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL,
                                 FONTWEIGHT_NORMAL)

        # Initialize label objects
        self._labels[CENTER] = self.AddText(cenLblX,
                                            cenLblY,
                                            "",
                                            font=self._defaultFont)
        self._labels[SRC_CARD] = self._srcAnchor.AddText(
            srcLblX, srcLblY, "", font=self._defaultFont)
        self._labels[DEST_CARD] = self._dstAnchor.AddText(
            dstLblX, dstLblY, "", font=self._defaultFont)
        self.updateLabels()
        self.SetDrawArrow(False)

        self.__hackCenterLabelPosition(cenLblX, cenLblY)
示例#18
0
    def __init__(self, pyutClass: PyutClass = None, w: float = DEFAULT_CLASS_WIDTH, h: float = DEFAULT_CLASS_HEIGHT):
        """

        Args:
            pyutClass:  a PyutClass object
            w:  Width of the shape
            h:  Height of the shape
        """
        if pyutClass is None:
            pyutObject = PyutClass()
        else:
            pyutObject = pyutClass
        super().__init__(pyutObject, w, h)

        self.logger:    Logger = getLogger(__name__)
        self._nameFont: Font   = Font(DEFAULT_FONT_SIZE, FONTFAMILY_SWISS, FONTSTYLE_NORMAL, FONTWEIGHT_BOLD)
示例#19
0
def _get_font_info(current_font: wx.Font, font_size: float = 1, bold=False) -> wx.Font:
    font = wx.Font()

    if font_size != 1:
        current_font_size = current_font.GetPointSize()
        new_font_size = int(font_size * current_font_size)
        _LOGGER.debug(
            "Debug ratio of %s results in absolute font size of %s",
            font_size,
            new_font_size,
        )
        font.SetPointSize(new_font_size)

    if bold:
        font.MakeBold()

    return font
示例#20
0
    def __init__(self, pyutObject=None, width: int = 0, height: int = 0):
        """

        Args:
            pyutObject: Associated PyutObject
            width:      Initial width
            height:     Initial height
        """
        self._pyutObject = pyutObject
        RectangleShape.__init__(self, 0, 0, width, height)

        # Default font
        self._defaultFont: Font = Font(DEFAULT_FONT_SIZE, FONTFAMILY_SWISS,
                                       FONTSTYLE_NORMAL, FONTWEIGHT_NORMAL)
        self._prefs: PyutPreferences = PyutPreferences()

        self._oglLinks: List[OglLink] = []  # Connected links
        self._modifyCommand = None
示例#21
0
    def __init__(self, parent, title, categories):
        BaseWindowPanel.__init__(self,
                                 parent,
                                 bg_color=Colour.BLACK,
                                 fg_color=Colour.WHITE)

        # Title Label
        self._title_label = StaticText(self,
                                       pos=(85, 10),
                                       size=(100, 30),
                                       label=title)
        self._title_label.SetFont(
            Font(20, FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL, FONTWEIGHT_NORMAL))

        # Cancel Button
        self._cancel_button = Button(self,
                                     -1,
                                     "Cancel",
                                     pos=(10, 10),
                                     size=(70, 30))
        self._cancel_button.SetBackgroundColour(Colour.DARK_RED)
        self._cancel_button.SetForegroundColour(Colour.WHITE)

        # Confirm Button
        self._confirm_button = Button(self,
                                      -1,
                                      "OK",
                                      pos=(240, 10),
                                      size=(70, 30))
        self._confirm_button.SetBackgroundColour(Colour.DARK_GREEN)
        self._confirm_button.SetForegroundColour(Colour.WHITE)

        # List Views
        self._list_control = ListBox(self, pos=(10, 50), size=(295, 170))
        self._list_control.SetBackgroundColour(Colour.BLACK)
        self._list_control.SetForegroundColour(Colour.WHITE)
        self._list_control.SetItems([CategoryInputWindowPanel.EMPTY_ITEM] +
                                    categories)

        # Event
        self.Bind(EVT_BUTTON, self._confirm_button_click, self._confirm_button)
        self.Bind(EVT_BUTTON, self._cancel_button_click, self._cancel_button)
示例#22
0
    def __init__(self, srcShape, pyutLink, dstShape):
        """

        Args:
            srcShape:   Source shape
            pyutLink:   Conceptual links associated with the graphical links.
            dstShape:   Destination shape
        """
        super().__init__(srcShape, pyutLink, dstShape)

        self._centerLabel: OglAssociationLabel = OglAssociationLabel()
        self._sourceCardinality: OglAssociationLabel = OglAssociationLabel()
        self._destinationCardinality: OglAssociationLabel = OglAssociationLabel(
        )

        self._defaultFont: Font = Font(OglAssociation.TEXT_SHAPE_FONT_SIZE,
                                       FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL,
                                       FONTWEIGHT_NORMAL)

        self.SetDrawArrow(False)
示例#23
0
    def __init__(self, parent, file_path, load_file=False):
        Panel.__init__(self, parent)
        self.grandparent = self.GetGrandParent()

        self.__file_path = file_path

        sizer = BoxSizer(VERTICAL)
        self.txt_test_file_path = TextCtrl(self,
                                           value=self.__file_path,
                                           style=TE_READONLY)
        sizer.Add(self.txt_test_file_path, 0, flag=FLAG_ALL_AND_EXPAND)

        self.txt_content = TextCtrl(self, style=TE_MULTILINE | HSCROLL)
        self.txt_content.Bind(EVT_KEY_DOWN, self.__on_text_change)
        if load_file:
            self.txt_content.LoadFile(self.__file_path)
        font_size = self.txt_content.GetFont().GetPointSize()
        self.txt_content.SetFont(
            Font(font_size, FONTFAMILY_TELETYPE, NORMAL, NORMAL))
        sizer.Add(self.txt_content, 1, flag=FLAG_ALL_AND_EXPAND)

        self.SetSizer(sizer)
示例#24
0
    def __init__(self, parent):
        BaseWindowPanel.__init__(self,
                                 parent,
                                 bg_color=Colour.BLACK,
                                 fg_color=Colour.WHITE)

        self._title_label = StaticText(self,
                                       pos=(110, 10),
                                       size=(100, 30),
                                       label=u"Entries")
        self._title_label.SetFont(
            Font(20, FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL, FONTWEIGHT_NORMAL))

        self._back_button = Button(self,
                                   -1,
                                   "< Back",
                                   pos=(10, 10),
                                   size=(70, 30))
        self._back_button.SetBackgroundColour(get_colour(0x333333))
        self._back_button.SetForegroundColour(Colour.WHITE)

        self._delete_button = Button(self,
                                     -1,
                                     "Del",
                                     pos=(240, 10),
                                     size=(70, 30))
        self._delete_button.SetBackgroundColour(Colour.RED)
        self._delete_button.SetForegroundColour(Colour.WHITE)

        self._list_control = ListBox(self, pos=(10, 50), size=(295, 170))
        self._list_control.SetBackgroundColour(Colour.BLACK)
        self._list_control.SetForegroundColour(Colour.WHITE)

        self._items = GlobalStorage.get_storage().get_items()
        self._list_control.SetItems(
            GlobalStorage.get_storage().get_string_list(self._items))

        self.Bind(EVT_BUTTON, self._back_button_click, self._back_button)
        self.Bind(EVT_BUTTON, self._delete_button_click, self._delete_button)
示例#25
0
    def __init__(self, parent: Window):
        """

        Args:
            parent:  parent window
        """
        super().__init__(parent, style=SUNKEN_BORDER)

        self._diagram = Diagram(self)

        self.__keepMoving: bool = False
        self._selectedShapes: List[Shape] = [
        ]  # list of the shapes that are selected

        self._lastMousePosition: Tuple[int, int] = cast(Tuple[int, int], None)
        self._selector: RectangleShape = cast(RectangleShape,
                                              None)  # rectangle selector shape

        self._clickedShape: Shape = cast(Shape, None)  # last clicked shape
        self._moving: bool = False  # a drag has been initiated

        self._xOffset: float = 0.0  # abscissa offset between the view and the model
        self._yOffset: float = 0.0  # ordinate offset between the view and the model
        self._zoomStack: List[float] = []  # store all zoom factors applied

        self._zoomLevel = 0  # number of zoom factors applied
        self._maxZoomFactor = 6  # can zoom in beyond 600%
        self._minZoomFactor = 0.2  # can zoom out beyond 20%
        self._defaultZoomFactor = 1.5  # used when only a point is selected

        # margins define a perimeter around the work area that must remains
        # blank and hidden. if we scroll beyond the limits, the diagram is
        # resized.
        # self._leftMargin   = DEFAULT_MARGIN_VALUE
        # self._rightMargin  = DEFAULT_MARGIN_VALUE
        # self._topMargin    = DEFAULT_MARGIN_VALUE
        # self._bottomMargin = DEFAULT_MARGIN_VALUE
        self._isInfinite = False  # to know if the frame is infinite or not

        # paint related
        w, h = self.GetSize()
        self.__workingBitmap = Bitmap(w, h)  # double buffering
        self.__backgroundBitmap = Bitmap(w, h)

        DEFAULT_FONT_SIZE = 12
        self._defaultFont = Font(DEFAULT_FONT_SIZE, FONTFAMILY_DEFAULT,
                                 FONTSTYLE_NORMAL, FONTWEIGHT_NORMAL)
        self.SetBackgroundColour(WHITE)
        self._prefs: PyutPreferences = PyutPreferences()

        # Mouse events
        self.Bind(EVT_LEFT_DOWN, self.OnLeftDown)
        self.Bind(EVT_LEFT_UP, self.OnLeftUp)
        self.Bind(EVT_LEFT_DCLICK, self.OnLeftDClick)
        self.Bind(EVT_MIDDLE_DOWN, self.OnMiddleDown)
        self.Bind(EVT_MIDDLE_UP, self.OnMiddleUp)
        self.Bind(EVT_MIDDLE_DCLICK, self.OnMiddleDClick)
        self.Bind(EVT_RIGHT_DOWN, self.OnRightDown)
        self.Bind(EVT_RIGHT_UP, self.OnRightUp)
        self.Bind(EVT_RIGHT_DCLICK, self.OnRightDClick)
        self.Bind(EVT_PAINT, self.OnPaint)

        if self._prefs.debugDiagramFrame is True:

            self._debugDialog: DlgDebugDiagramFrame = DlgDebugDiagramFrame(
                self, ID_ANY)
            self._debugDialog.startMonitor()
            self._debugDialog.Show(True)
示例#26
0
def FontFromFacename(facename):
    return Font(10, FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL, FONTWEIGHT_NORMAL,
                False, facename)
示例#27
0
 def TupleToFont(t):
     return Font(*t)
示例#28
0
    def TupleToFont(t):
        t = list(t)
        if len(t) >= 7:
            t[6] = wx.FontEncoding(t[6])

        return Font(*t)
示例#29
0
    def __init__(self, parent, dpi=(1, 1)):
        Frame.__init__(self,
                       parent,
                       id=ID_ANY,
                       title=u" mHosts - v" + Settings.version(),
                       pos=DefaultPosition,
                       size=Size(700 * dpi[0], 500 * dpi[1]),
                       style=DEFAULT_FRAME_STYLE | SYSTEM_MENU | TAB_TRAVERSAL)
        self.SetIcon(Icon(iconPath, BITMAP_TYPE_ICO))
        self.SetSizeHints(Size(500 * dpi[0], 350 * dpi[1]))
        self.menuBar = MenuBar(0)
        self.menuFile = Menu()
        self.menuItemNew = MenuItem(self.menuFile, ID_ANY, u"新建(&N)",
                                    EmptyString, ITEM_NORMAL)
        self.menuItemImport = MenuItem(self.menuFile, ID_ANY, u"导入(&I)",
                                       EmptyString, ITEM_NORMAL)
        if sys.platform != "linux":
            self.menuItemImport.Enable(False)
        self.menuFile.Append(self.menuItemNew)
        self.menuFile.Append(self.menuItemImport)

        self.menuFile.AppendSeparator()

        self.menuItemExit = MenuItem(self.menuFile, ID_ANY, u"退出(&Q)",
                                     EmptyString, ITEM_NORMAL)
        self.menuFile.Append(self.menuItemExit)

        self.menuBar.Append(self.menuFile, u"文件(&F)")

        self.menuHelp = Menu()

        self.menuItemSettings = MenuItem(self.menuHelp, ID_ANY, u"首选项(&P)",
                                         EmptyString, ITEM_NORMAL)
        if sys.platform != "linux":
            self.menuItemSettings.Enable(False)
        self.menuHelp.Append(self.menuItemSettings)

        self.menuItemHelpDoc = MenuItem(self.menuHelp, ID_ANY, u"帮助文档(&D)",
                                        EmptyString, ITEM_NORMAL)
        self.menuHelp.Append(self.menuItemHelpDoc)

        self.menuItemCheckUpdate = MenuItem(self.menuHelp, ID_ANY, u"检查更新(&U)",
                                            EmptyString, ITEM_NORMAL)
        self.menuHelp.Append(self.menuItemCheckUpdate)

        self.menuItemAbout = MenuItem(self.menuHelp, ID_ANY, u"关于(&A)",
                                      EmptyString, ITEM_NORMAL)
        self.menuHelp.Append(self.menuItemAbout)

        self.menuBar.Append(self.menuHelp, u"帮助(&H)")

        self.SetMenuBar(self.menuBar)

        self.statusBar = StatusBar(self, ID_ANY, STB_SIZEGRIP)
        statusBarFont = Font(10, FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL,
                             FONTWEIGHT_NORMAL, False, EmptyString)
        self.statusBar.SetFont(statusBarFont)
        self.SetStatusBar(self.statusBar)

        bSizer1 = BoxSizer(HORIZONTAL)

        self.images = {}

        self.imageList = ImageList(width=12, height=12)
        iconList = GetIcons().items()
        for name, bitmap in iconList:
            self.images[name] = self.imageList.Add(bitmap)

        self.hostsTree = TreeCtrl(self, ID_ANY, Point(0, 0),
                                  Size(180 * dpi[0], -1), TR_DEFAULT_STYLE)
        self.hostsTree.SetImageList(self.imageList)
        bSizer1.Add(self.hostsTree, 0, EXPAND, 5)

        # self.hostsListView = CheckListBox(self, size=Size(size[0] / 9, -1))
        # bSizer1.Add(self.hostsListView, 0, EXPAND, 5)

        # WARNING: wxPython code generation isn't supported for this widget yet.
        self.codeEditor = CodeView(self, dpi)
        bSizer1.Add(self.codeEditor, 1, EXPAND, 5)

        self.SetSizer(bSizer1)
        self.Layout()

        self.Centre(BOTH)

        # Connect Events
        self.Bind(EVT_MENU, self.OnMenuClicked, id=self.menuItemNew.GetId())
        self.Bind(EVT_MENU, self.OnMenuClicked, id=self.menuItemExit.GetId())
        self.Bind(EVT_MENU, self.OnMenuClicked, id=self.menuItemAbout.GetId())
        self.Bind(EVT_MENU,
                  self.OnMenuClicked,
                  id=self.menuItemHelpDoc.GetId())
        self.Bind(EVT_MENU,
                  self.OnMenuClicked,
                  id=self.menuItemSettings.GetId())
        self.Bind(EVT_MENU, self.OnMenuClicked, id=self.menuItemImport.GetId())
        self.Bind(EVT_MENU,
                  self.OnMenuClicked,
                  id=self.menuItemCheckUpdate.GetId())
示例#30
0
    def __init__(self, parent, dpi=(1, 1)):
        Dialog.__init__(self,
                        parent,
                        id=ID_ANY,
                        title=u"编辑/添加Hosts",
                        pos=Point(600, 600),
                        size=Size(394 * dpi[0], 210 * dpi[1]),
                        style=DEFAULT_DIALOG_STYLE | FRAME_FLOAT_ON_PARENT)
        self.__window = parent
        self.SetSizeHints(DefaultSize, DefaultSize)

        font = Font(10, FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL,
                    FONTWEIGHT_NORMAL, False, EmptyString)
        inputSize = Size(260 * dpi[0], -1)
        self.SetFont(font)
        fgSizer3 = FlexGridSizer(0, 2, 0, 0)
        fgSizer3.SetFlexibleDirection(BOTH)
        fgSizer3.SetNonFlexibleGrowMode(FLEX_GROWMODE_SPECIFIED)

        self.localRadio = RadioButton(self, ID_ANY, u"本地Hosts",
                                      DefaultPosition, DefaultSize, 0)
        self.localRadio.SetFont(font)
        fgSizer3.Add(self.localRadio, 0, ALL, 5)
        self.localRadio.Bind(EVT_RADIOBUTTON, self.OnRadioChange)

        self.onlineRadio = RadioButton(self, ID_ANY, u"在线Hosts",
                                       DefaultPosition, DefaultSize, 0)
        fgSizer3.Add(self.onlineRadio, 0, ALL, 5)
        self.onlineRadio.Bind(EVT_RADIOBUTTON, self.OnRadioChange)

        self.m_staticText4 = StaticText(self, ID_ANY, u"名称", DefaultPosition,
                                        DefaultSize, 0)
        self.m_staticText4.Wrap(-1)

        fgSizer3.Add(self.m_staticText4, 0, ALL, 5)

        self.nameInput = TextCtrl(self, ID_ANY, EmptyString, DefaultPosition,
                                  inputSize, 0)
        fgSizer3.Add(self.nameInput, 0, ALL, 5)

        self.m_staticText5 = StaticText(self, ID_ANY, u"地址", DefaultPosition,
                                        DefaultSize, 0)
        self.m_staticText5.Wrap(-1)

        fgSizer3.Add(self.m_staticText5, 0, ALL, 5)

        self.urlInput = TextCtrl(self, ID_ANY, u"http://", DefaultPosition,
                                 inputSize, 0)
        fgSizer3.Add(self.urlInput, 0, ALL, 5)

        self.m_staticText3 = StaticText(self, ID_ANY, u"图标", DefaultPosition,
                                        DefaultSize, 0)
        self.m_staticText3.Wrap(-1)

        fgSizer3.Add(self.m_staticText3, 0, ALL, 5)

        self.iconComboBox = ComboBox(self, ID_ANY, u"请选择图标", DefaultPosition,
                                     inputSize, list(GetIcons().keys()), 0)
        self.iconComboBox.SetFont(font)
        fgSizer3.Add(self.iconComboBox, 0, ALL, 5)

        self.cancelButton = Button(self, ID_ANY, u"取消", DefaultPosition,
                                   DefaultSize, 0)
        fgSizer3.Add(self.cancelButton, 0, ALL, 5)

        self.saveButton = Button(self, ID_ANY, u"保存", DefaultPosition,
                                 DefaultSize, 0)
        fgSizer3.Add(self.saveButton, 0, ALL, 5)

        self.SetSizer(fgSizer3)
        self.Layout()

        self.Centre(BOTH)

        self.cancelButton.Bind(EVT_BUTTON, self.OnButtonClicked)
        self.saveButton.Bind(EVT_BUTTON, self.OnButtonClicked)
        self.Bind(EVT_CLOSE, self.OnClose)