Ejemplo n.º 1
0
 def __init__(self, parent, id):
     wx.Frame.__init__(self,
                       None,
                       -1,
                       "%s's annoucement" % id,
                       size=(400, 300),
                       style=wx.DEFAULT_FRAME_STYLE ^
                       (wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
     self.SetIcon(Image['announcement'].GetIcon())
     self.parent = parent  #Clientwindow
     self.id = id
     self.text = wx.TextCtrl(self,
                             style=wx.TE_READONLY | wx.TE_MULTILINE
                             | wx.TE_RICH)
     self.style_date = wx.TextAttr(
         '#000000', self.text.GetBackgroundColour(),
         wx.Font(8, wx.ROMAN, wx.ITALIC, wx.NORMAL))
     self.style_content = wx.TextAttr(
         '#5b9bd5', self.text.GetBackgroundColour(),
         wx.Font(14, wx.ROMAN, wx.NORMAL, wx.BOLD))
     self.Bind(wx.EVT_CLOSE, self.onClose)
     self.Show()
Ejemplo n.º 2
0
 def loadFile(self):
     if not os.path.isfile(self.note_path):
         return
     with open(self.note_path, 'r') as out:
         font_style = wx.TextAttr()
         char = out.read(1)
         while char:
             if not self.handleFlag(font_style, char):
                 self.note_field.WriteText(char)
             char = out.read(1)
     style = self.note_field.GetDefaultStyle()
     style.SetFont(self.fonts['normal'])
     self.note_field.SetDefaultStyle(style)
Ejemplo n.º 3
0
	def emit(self, record: logging.LogRecord):
		"""
		receive, format, colorize and display a log message
		:param record: logging.LogRecord object
		"""

		if record.levelno == logging.INFO:
			logWindow.instance.text.SetDefaultStyle( wx.TextAttr( wx.Colour(0, 80, 255) ) )  # blue/cyan
		#
		elif record.levelno == logging.WARNING:
			logWindow.instance.text.SetDefaultStyle( wx.TextAttr( wx.Colour(255, 125, 0) ) )  # orange
		#
		elif record.levelno == logging.ERROR:
			logWindow.instance.text.SetDefaultStyle( wx.TextAttr( wx.Colour(255, 0, 0) ) )  # red
		#
		elif record.levelno == logging.DEBUG:
			logWindow.instance.text.SetDefaultStyle( wx.TextAttr( wx.Colour(128, 128, 128) ) )  # grey
		#
		elif record.levelno == logging.CRITICAL:
			logWindow.instance.text.SetDefaultStyle( wx.TextAttr( wx.Colour(255, 255, 255) ) )  # white
		# display the log message
		logWindow.instance.text.AppendText( self.format(record) )
Ejemplo n.º 4
0
 def EvtKeyUp(self, event):
     vkCode = event.GetKeyCode()
     if vkCode not in self._trappedKeys:
         event.Skip()
         return
     self._trappedKeys.discard(vkCode)
     if not self._trappedKeys and self._gesture is not None:
         text = unichr(self._gesture | 0x2800)
         self.brailleInput.WriteText(text)
         self.brailleInput.SetDefaultStyle(wx.TextAttr(wx.RED))
         self.SetStatusText(text)
         self._gesture = None
     return False
    def OnIndentLess(self, evt):
        attr = wx.TextAttr()
        attr.SetFlags(wx.TEXT_ATTR_LEFT_INDENT)
        ip = self.rtc.GetInsertionPoint()
        if self.rtc.GetStyle(ip, attr):
            r = rt.RichTextRange(ip, ip)
            if self.rtc.HasSelection():
                r = self.rtc.GetSelectionRange()

        if attr.GetLeftIndent() >= 100:
            attr.SetLeftIndent(attr.GetLeftIndent() - 100)
            attr.SetFlags(wx.TEXT_ATTR_LEFT_INDENT)
            self.rtc.SetStyle(r, attr)
Ejemplo n.º 6
0
 def writeOutput(self, text, color=None, with_nl=True):
     pos0 = self.output.GetLastPosition()
     if with_nl and not text.endswith('\n'):
         text = '%s\n' % text
     self.output.WriteText(text)
     if color is not None:
         style = self.output.GetDefaultStyle()
         bgcol = style.GetBackgroundColour()
         sfont = style.GetFont()
         pos1 = self.output.GetLastPosition()
         self.output.SetStyle(pos0, pos1, wx.TextAttr(color, bgcol, sfont))
     self.output.SetInsertionPoint(self.output.GetLastPosition())
     self.output.Refresh()
Ejemplo n.º 7
0
 def __init__(self, parent):
     wx.Panel.__init__(self,parent, -1, style=wx.NO_FULL_REPAINT_ON_RESIZE)
     self.tb=wx.TextCtrl(self, 1, style=wx.TE_MULTILINE|wx.TE_RICH2|wx.NO_FULL_REPAINT_ON_RESIZE|wx.TE_DONTWRAP|wx.TE_READONLY)
     f=wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL )
     ta=wx.TextAttr(font=f)
     self.tb.SetDefaultStyle(ta)
     self.sizer=wx.BoxSizer(wx.VERTICAL)
     self.sizer.Add(self.tb, 1, wx.EXPAND)
     self.SetSizer(self.sizer)
     self.SetAutoLayout(True)
     self.sizer.Fit(self)
     wx.EVT_IDLE(self, self.OnIdle)
     self.outstandingtext=""
Ejemplo n.º 8
0
 def __init__(self, parent):
     super(TopRight, self).__init__(parent)
     self.term = wx.TextCtrl(self,
                             size=(200, 100),
                             style=wx.TE_MULTILINE | wx.TE_READONLY
                             | wx.TE_RICH)
     self.term.SetDefaultStyle(wx.TextAttr(wx.GREEN))
     self.term.SetBackgroundColour(wx.BLACK)
     self.sizer = wx.BoxSizer(wx.VERTICAL)
     self.sizer.Add(self.term, 1, wx.EXPAND)
     self.SetSizer(self.sizer)
     self.term.WriteText("hello")
     self.term.Update
Ejemplo n.º 9
0
 def write(bytes):
     if "[ERROR]" in bytes:
         color = "red"
     elif "[DEBUG]" in bytes:
         color = "gray"
     elif "[WARNING]" in bytes:
         color = "blue"
     else:
         color = "black"
         
     self.m_log.SetDefaultStyle(wx.TextAttr(color, "white"))
         
     self.m_log.AppendText(bytes)
Ejemplo n.º 10
0
    def showMessage(self, title, text, type=0):
        if type == 1:
            titleColor = wx.Colour(0, 0, 255)
        elif type == 2:
            titleColor = wx.Colour(0, 0, 255)
        else:
            titleColor = wx.Colour(0, 128, 64)
        titleFont = wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False)
        textFont = wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False)

        self.content_text.SetDefaultStyle(
            wx.TextAttr(titleColor, wx.NullColour, titleFont))
        self.content_text.AppendText(title + '\n')

        self.content_text.SetDefaultStyle(
            wx.TextAttr(wx.BLACK, wx.NullColour, textFont))
        self.content_text.AppendText(text + '\n')

        self.content_text.SetDefaultStyle(
            wx.TextAttr(wx.BLACK, wx.NullColour,
                        wx.Font(3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False)))
        self.content_text.AppendText('\n')
Ejemplo n.º 11
0
    def _setStyle(self, style):
        """!Sets default style of textCtrl.

        @param style "title"/"value"
        """
        if style == "title":
            self.font.SetWeight(wx.FONTWEIGHT_BOLD)
        elif style == "value":
            self.font.SetWeight(wx.FONTWEIGHT_NORMAL)
        else:
            return

        self.textCtrl.SetDefaultStyle(wx.TextAttr(font=self.font))
Ejemplo n.º 12
0
	def _mixin_on_find(self, evt):

		# reset style of previous match
		if self.__mixin_find_replace_last_match_attr is not None:
			self.SetStyle (
				self.__mixin_find_replace_last_match_start,
				self.__mixin_find_replace_last_match_end,
				self.__mixin_find_replace_last_match_attr
			)

		# find current match
		search_term = self.__mixin_find_replace_data.GetFindString().lower()
		match_start = self.Value.lower().find(search_term, self.__mixin_find_replace_last_match_end)
		if match_start == -1:
			# wrap around
			self.__mixin_find_replace_last_match_start = 0
			self.__mixin_find_replace_last_match_end = 0
			wx.Bell()
			return

		# remember current match for next time around
		attr = wx.TextAttr()
		if self.GetStyle(match_start, attr):
			self.__mixin_find_replace_last_match_attr = attr
		else:
			self.__mixin_find_replace_last_match_attr = None
		self.__mixin_find_replace_last_match_start = match_start
		self.__mixin_find_replace_last_match_end = match_start + len(search_term)

		# react to current match
		self.Freeze()
		self.SetStyle (
			self.__mixin_find_replace_last_match_start,
			self.__mixin_find_replace_last_match_end,
			wx.TextAttr("red", "black")
		)
		self.ShowPosition(0)
		self.ShowPosition(self.__mixin_find_replace_last_match_end)
		self.Thaw()
Ejemplo n.º 13
0
    def MarkText(self, code, index, selection=None):
        readPanel = self._readPanel if code is None else self._comparePanel[
            utils.MakeKey(code, index)]
        s, t = readPanel.Body.GetSelection(
        ) if selection is None else selection
        font = readPanel.Body.GetFont()

        if 'wxMac' in wx.PlatformInfo:
            readPanel.Body.SetStyle(
                s, t,
                wx.TextAttr(
                    'blue', utils.LoadThemeBackgroundHex(constants.READ),
                    wx.Font(font.GetPointSize() + 2, font.GetFamily(),
                            font.GetStyle(), wx.FONTWEIGHT_BOLD, False,
                            font.GetFaceName())))
        else:
            readPanel.Body.SetStyle(
                s, t,
                wx.TextAttr(utils.LoadThemeForegroundHex(constants.READ),
                            'yellow', font))

        return s, t
Ejemplo n.º 14
0
 def set_field_background(field: wx.TextCtrl, color: wx.Colour) -> None:
     """
     Set background color for a field.
     :param field: wx.TextCtrl.
     :param color: The wx.Color to set.
     :return: None
     """
     field.SetBackgroundColour(color)
     style_carrier = wx.TextAttr()
     # Set color for the current text separately, it does not work with just background color
     field.GetStyle(0, style_carrier)
     style_carrier.SetBackgroundColour(color)
     field.SetStyle(0, len(field.GetValue()), style_carrier)
Ejemplo n.º 15
0
    def highlightText(box, p1, p2=None):
        """Update the highlighting in a text entry box"""
        logging.info("Highlight text")
        logging.debug("p1: %s, p2: %s" % (p1, p2))

        # Path value, optionally relative to a second path
        a = FilePicker.split_path(p1, p2)
        logging.debug(str(a))

        # Set entire length of the box to default colour
        box.SetStyle(0, len(p1), wx.TextAttr(None, "white"))

        # Then recolour both boxes to reflect path existence
        for k in range(len(a)):
            # If this path section exists, colour it white
            if a[k][3]:
                box.SetStyle(a[k][1], a[k][1] + a[k][2],
                             wx.TextAttr(None, "white"))
            # If path section doesn't exist, colour it yellow
            else:
                box.SetStyle(a[k][1], a[k][1] + a[k][2],
                             wx.TextAttr(None, "#FFFF00"))
Ejemplo n.º 16
0
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          u'这是Static Text Example',
                          size=(400, 300))

        box_sizer = wx.WrapSizer()
        self.SetAutoLayout(True)
        self.SetSizer(box_sizer)

        ########## Label ##########
        static_text = wx.StaticText(self,
                                    -1,
                                    u'这是个Label',
                                    style=wx.ALIGN_CENTER)
        static_text.SetForegroundColour('red')  #颜色
        wx_font = wx.Font(18, wx.DECORATIVE, wx.ITALIC, wx.BOLD)
        static_text.SetFont(wx_font)
        box_sizer.Add(static_text)

        ########## 单行文本框 ##########
        input_text = wx.TextCtrl(self, -1, u'input', size=(175, -1))
        input_text.SetInsertionPoint(0)
        box_sizer.Add(input_text)

        ########## 多行文本框 ##########
        self.area_text = wx.TextCtrl(self,
                                     -1,
                                     u'textArea多行文本,可Ctrl+A',
                                     size=(200, 100),
                                     style=(wx.TE_MULTILINE | wx.TE_AUTO_SCROLL
                                            | wx.TE_DONTWRAP))
        self.area_text.SetInsertionPoint(0)
        self.area_text.Bind(wx.EVT_KEY_UP, self.OnSelectAll)
        box_sizer.Add(self.area_text)

        ########## 富文本框 ##########
        self.rich_text = wx.TextCtrl(self,
                                     -1,
                                     u'rich富文本',
                                     size=(200, 100),
                                     style=(wx.TE_MULTILINE | wx.TE_AUTO_SCROLL
                                            | wx.TE_DONTWRAP | wx.TE_RICH2))
        self.rich_text.SetInsertionPoint(0)
        #设置文本样式  len(rich_text.GetValue())
        f = wx.Font(18, wx.ROMAN, wx.ITALIC, wx.BOLD, True)  #创建一个字体
        self.rich_text.SetStyle(0, self.rich_text.GetLastPosition(),
                                wx.TextAttr("red", "green", f))

        box_sizer.Add(self.rich_text)
Ejemplo n.º 17
0
    def __init__(self,
                 wxparent=None,
                 writer=None,
                 _larch=None,
                 prompt=None,
                 historyfile=None,
                 output=None,
                 input=None):
        self._larch = _larch
        self.textstyle = None

        self.prompt = prompt
        self.input = input
        self.output = output

        if _larch is None:
            self._larch = larch.Interpreter(historyfile=historyfile,
                                            writer=self)
            self._larch.run_init_scripts()
        self.writer = self._larch.writer
        self.symtable = self._larch.symtable
        # if self.output is not None:
        #    self.encoding = sys.stdout.encoding
        #    sys.stdout = self

        self.objtree = wxparent.objtree

        self.set_textstyle(mode='text')
        self._larch("_sys.display.colors['text2'] = {'color': 'blue'}",
                    add_history=False)

        self._larch.add_plugin('wx', wxparent=wxparent)
        self.symtable.set_symbol('_builtin.force_wxupdate', False)
        self.symtable.set_symbol('_sys.wx.inputhook', inputhook)
        self.symtable.set_symbol('_sys.wx.ping', inputhook.ping)
        self.symtable.set_symbol('_sys.wx.force_wxupdate', False)
        self.symtable.set_symbol('_sys.wx.wxapp', output)
        self.symtable.set_symbol('_sys.wx.parent', wx.GetApp().GetTopWindow())

        if self.output is not None:
            style = self.output.GetDefaultStyle()
            bgcol = style.GetBackgroundColour()
            sfont = style.GetFont()

            self.textstyle = wx.TextAttr('black', bgcol, sfont)

        self.SetPrompt(True)
        self.flush_timer = wx.Timer(wxparent)
        self.needs_flush = True
        wxparent.Bind(wx.EVT_TIMER, self.onFlushTimer, self.flush_timer)
        self.flush_timer.Start(500)
Ejemplo n.º 18
0
def get_innodb_page_type(text, detail,cn):
    dia = win32ui.CreateFileDialog(1)
    dia.SetOFNInitialDir('C:/')
    dia.DoModal()

    filename = dia.GetPathName()
    if (filename):
        text.Clear()
        f = open(filename, 'rb')
        fsize = os.path.getsize(f.name) // INNODB_PAGE_SIZE
        ret = {}
        back = ''
        lang = include.CN_words if cn else include.EN_words
        innodb_page_type = include.CN_type if cn else include.EN_type
        text.SetDefaultStyle(wx.TextAttr(wx.BLACK))
        text.AppendText(lang['NUM'] % fsize)
        for i in range(fsize):
            page = f.read(INNODB_PAGE_SIZE)
            page_offset = mach_read_from_n(page, FIL_PAGE_OFFSET, 4)
            page_type = mach_read_from_n(page, FIL_PAGE_TYPE, 2)

            if detail:
                if page_type == '45bf':
                    page_level = mach_read_from_n(page, FIL_PAGE_DATA + PAGE_LEVEL, 2)
                    back += lang['TREE'] % (page_offset, innodb_page_type[page_type], page_level)
                else:
                    back += lang['NORMAL'] % (page_offset, innodb_page_type[page_type])

            if not ret.get(page_type):
                ret[page_type] = 1
            else:
                ret[page_type] = ret[page_type] + 1


        for type in ret:
            text.AppendText("\n%s: %s" % (innodb_page_type[type], ret[type]))
        text.SetDefaultStyle(wx.TextAttr('rgb(77,77,77)'))
        text.AppendText(back)
Ejemplo n.º 19
0
 def WriteResults(self):
     self.resultCtrl.Clear()
     outStr = ""
     for i in range(self.koh.MaxClass):
         cnt = 0
         for j in range(self.koh.NPatterns):
             if self.koh.Membership[j] == i:
                 cnt += 1
         addStr = "Class " + str(i) + ": " + str(cnt) + "\n"
         outStr += addStr
         textattr = wx.TextAttr(self.colors[i])
         self.resultCtrl.AppendText(addStr)
         self.resultCtrl.SetStyle(
             len(outStr) - len(addStr), len(outStr), textattr)
Ejemplo n.º 20
0
 def PrintText(self):  # {{{
     #print self.display
     self.output.Clear()
     for i in self.display:
         if type(i) == type(u""):
             self.output.WriteText(i)
         else:
             col1 = wx.Colour(i[0], i[1], i[2])
             col2 = wx.Colour(i[3], i[4], i[5])
             dastyle = wx.TextAttr()
             dastyle.SetTextColour(col1)
             dastyle.SetBackgroundColour(col2)
             self.output.SetDefaultStyle(dastyle)
     self.output.ShowPosition(0)
Ejemplo n.º 21
0
    def end_proc(self):
        """
        At the end of the process
        """
        if STATUS_ERROR == 1:
            self.OutText.SetDefaultStyle(wx.TextAttr(wx.Colour(210, 24, 20)))
            self.OutText.AppendText(_('\n Sorry, tasks failed !\n'))
            self.button_stop.Enable(False)
            self.button_close.Enable(True)

        elif CHANGE_STATUS == 1:
            self.OutText.SetDefaultStyle(wx.TextAttr(wx.Colour(164, 30, 164)))
            self.OutText.AppendText(_('\n Interrupted Process !\n'))
            self.button_stop.Enable(False)
            self.button_close.Enable(True)

        else:
            self.OutText.SetDefaultStyle(wx.TextAttr(wx.Colour(30, 62, 164)))
            self.OutText.AppendText(_('\n Done !\n'))
            self.labPerc.SetLabel("Percentage: 100%")
            self.button_stop.Enable(False)
            self.button_close.Enable(True)
            self.barProg.SetValue(0)
Ejemplo n.º 22
0
    def SendMessage(self, val, log=None, state="", color=0):
        colors = [(255, 255, 255), (255, 0, 0), (0, 255, 0)]

        log_lock.acquire()
        beg = self.Log.GetLastPosition()
        end = self.Log.GetLastPosition() + len(val)
        self.Log.SetStyle(beg, end, wx.TextAttr(colors[color], 'black'))
        self.Log.AppendText(val)
        self.Log.ShowPosition(end)
        log_lock.release()

        if log: log.write(val)
        if state in ("PASS", "FAIL", "START"):
            self.ShowResult(state)
Ejemplo n.º 23
0
    def OnBold(self, event):
        page = self.getCurrentPage()
        if page:
            start, end = page.GetSelection()
            font = page.GetFont()
            if event.IsChecked():
                font.SetWeight(wx.BOLD)
            else:
                font.SetWeight(wx.NORMAL)

            attr = wx.TextAttr(font=font)
            page.SetStyle(start, end, attr)

        event.Skip()
Ejemplo n.º 24
0
 def on_timer(self, event):
     state = self.state
     if state.close_event.wait(0.001):
         self.timer.Stop()
         self.Destroy()
         return
     while state.child_pipe_recv.poll():
         obj = state.child_pipe_recv.recv()
         if isinstance(obj, Value):
             # request to set a status field
             if not obj.name in self.values:
                 # create a new status field
                 value = wx.StaticText(self.panel, -1, obj.text)
                 # possibly add more status rows
                 for i in range(len(self.status), obj.row + 1):
                     self.status.append(wx.BoxSizer(wx.HORIZONTAL))
                     self.vbox.Insert(len(self.status) - 1,
                                      self.status[i],
                                      0,
                                      flag=wx.ALIGN_LEFT | wx.TOP)
                     self.vbox.Layout()
                 self.status[obj.row].Add(value, border=5)
                 self.status[obj.row].AddSpacer(20)
                 self.values[obj.name] = value
             value = self.values[obj.name]
             value.SetForegroundColour(obj.fg)
             value.SetBackgroundColour(obj.bg)
             value.SetLabel(obj.text)
             self.panel.Layout()
         elif isinstance(obj, Text):
             '''request to add text to the console'''
             self.pending.append(obj)
             for p in self.pending:
                 # we're scrolled at the bottom
                 oldstyle = self.control.GetDefaultStyle()
                 style = wx.TextAttr()
                 style.SetTextColour(p.fg)
                 style.SetBackgroundColour(p.bg)
                 self.control.SetDefaultStyle(style)
                 self.control.AppendText(p.text)
                 self.control.SetDefaultStyle(oldstyle)
             self.pending = []
         elif isinstance(obj, mp_menu.MPMenuTop):
             if obj is not None:
                 self.SetMenuBar(None)
                 self.menu = obj
                 self.SetMenuBar(self.menu.wx_menu())
                 self.Bind(wx.EVT_MENU, self.on_menu)
             self.Refresh()
             self.Update()
Ejemplo n.º 25
0
    def OnParagraphSpacingLess(self, evt):
        attr = wx.TextAttr()
        attr.SetFlags(wx.TEXT_ATTR_PARA_SPACING_AFTER)
        ip = self.rtc.GetInsertionPoint()
        if self.rtc.GetStyle(ip, attr):
            r = rt.RichTextRange(ip, ip)
            if self.rtc.HasSelection():
                r = self.rtc.GetSelectionRange()

            if attr.GetParagraphSpacingAfter() >= 20:
                attr.SetParagraphSpacingAfter(attr.GetParagraphSpacingAfter() -
                                              20)
                attr.SetFlags(wx.TEXT_ATTR_PARA_SPACING_AFTER)
                self.rtc.SetStyle(r, attr)
Ejemplo n.º 26
0
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'Text Entry Example', 
                size=(300, 250))
        panel = wx.Panel(self, -1) 
        multiLabel = wx.StaticText(panel, -1, "Multi-line")
        multiText = wx.TextCtrl(panel, -1,
               "Here is a looooooooooooooong line of text set in the control.\n\n"
               "See that it wrapped, and that this line is after a blank",
               size=(200, 100), style=wx.TE_MULTILINE)
        multiText.SetInsertionPoint(0)

        richLabel = wx.StaticText(panel, -1, "Rich Text")
        richText = wx.TextCtrl(panel, -1, 
                "If supported by the native control, this is reversed, and this is a different font.",
                size=(200, 100), style=wx.TE_MULTILINE|wx.TE_RICH2)
        richText.SetInsertionPoint(0)
        richText.SetStyle(44, 52, wx.TextAttr("white", "black"))
        points = richText.GetFont().GetPointSize() 
        f = wx.Font(points + 3, wx.ROMAN, wx.ITALIC, wx.BOLD, True)
        richText.SetStyle(68, 82, wx.TextAttr("blue", wx.NullColour, f))
        sizer = wx.FlexGridSizer(cols=2, hgap=6, vgap=6)
        sizer.AddMany([multiLabel, multiText, richLabel, richText])
        panel.SetSizer(sizer)
Ejemplo n.º 27
0
    def OnButtonopenButton(self, event):  #打开按钮
        '''打开新条件'''
        #显示文件选择框
        dlg = wx.FileDialog(self,
                            message=u"打开新过滤条件",
                            defaultDir=os.getcwd(),
                            defaultFile="",
                            style=wx.OPEN)
        #点击“打开”按钮
        if dlg.ShowModal() == wx.ID_OK:
            #打开并读取文件
            if wx.Platform == '__WXMSW__':
                f = open(dlg.GetPath().encode('mbcs'), 'r')
            else:
                f = open(dlg.GetPath(), 'r')
            new_filters = f.read()
            f.close()
            #左侧窗口显示
            self.textCtrl1.Clear()
            self.textCtrl1.AppendText(new_filters.decode('utf-8'))
        #关闭
        dlg.Destroy()

        #比较新旧条件的不同,不同则标红
        for i in range(1, self.textCtrl1.GetNumberOfLines()):
            if self.textCtrl1.GetLineText(i) != self.textCtrl2.GetLineText(i):
                self.textCtrl1.SetStyle(self.textCtrl1.XYToPosition(0,i), \
                                        self.textCtrl1.XYToPosition(0,i)+len(self.textCtrl1.GetLineText(i)), \
                                        wx.TextAttr("RED"))
            else:
                self.textCtrl1.SetStyle(self.textCtrl1.XYToPosition(0,i), \
                                        self.textCtrl1.XYToPosition(0,i)+len(self.textCtrl1.GetLineText(i)), \
                                        wx.TextAttr("BLACK"))
        ##位置放在开始位置哦~
        self.textCtrl1.SetInsertionPoint(0)

        event.Skip()
Ejemplo n.º 28
0
    def Refresh(self, data):
        self.SetTitle(data[0] + " - " + consts.appName + " v" +
                      consts.appVersion)
        self.projectDetails.Clear()
        self.projectDetails.AppendText(data[0] + '\n')
        if data[2] != '':
            self.projectDetails.AppendText(
                _("Operating System:") + '\t' + data[2] + '\n')
        if data[3] != '':
            self.projectDetails.AppendText(
                _("Version:") + '\t' + data[3] + '\n')
        if data[4] != '':
            self.projectDetails.AppendText(
                _("Kernel:") + '\t' + data[5] + '\n')
        if data[5] != '':
            self.projectDetails.AppendText(
                _("Architecture:") + '\t' + data[4] + '\n')
        self.projectDetails.AppendText(
            _("Drive Free Space:") + '\t' + lib.driveFreeSpace() + '\n')
        #self.projectDetails.AppendText("%s\n%s\t%s\n%s\t%s\n%s\t%s\n%s\t%s\n%s\t%s" %
        #    (data[0], os, data[2], v, data[3], k, data[4], a, data[5], f, lib.driveFreeSpace()))

        points = self.projectDetails.GetFont().GetPointSize()
        style = wx.Font(points, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                        wx.FONTWEIGHT_BOLD)
        self.projectDetails.SetStyle(
            0, len(data[0]), wx.TextAttr("black", wx.NullColour, style))

        # Get index file URLs.
        urls = project.projects[len(project.projects) - 1].getUrls()

        # Inquire whether latest package list should be downloaded
        #dlg = wx.MessageDialog(None, _('Download the latest package list?'),
        #                  _("Download latest?"), wx.YES_NO | wx.ICON_QUESTION)
        urls_string = '\n'.join(['\n'.join(x) for x in urls])
        dlg = ScrolledMessageDialog(None, _("Download Latest?"),
                                    _("Download the latest package lists?"),
                                    urls_string)

        result = dlg.ShowModal()
        dlg.Destroy()

        # Load package list
        self.SetStatusText(_("Loading packages") + "...", 0)

        if result == wx.ID_OK:
            frame = download(self, self.loadLocal, urls, True)
        else:
            self.loadLocal()
Ejemplo n.º 29
0
    def RemoveParticipant(self, pDesc):
        '''
        Remove a participant.
        '''
        if self.profileToId.has_key(pDesc.appId):
            id = self.profileToId[pDesc.appId]

            item = self.partListCtrl.FindItemData(-1, id)

            self.partListCtrl.DeleteItem(item)

            #Add event text
            message = pDesc.clientProfile.name + " left this session "

            # Add time to event message
            dateAndTime = strftime("%a, %d %b %Y, %H:%M:%S", localtime())
            message = message + " (" + dateAndTime + ")"

            # Events are coloured blue
            self.textCtrl.SetDefaultStyle(wx.TextAttr(wx.BLUE))
            self.textCtrl.AppendText(message + '\n')
            self.textCtrl.SetDefaultStyle(wx.TextAttr(wx.BLACK))

            self.__SetRightScroll()
Ejemplo n.º 30
0
    def AddParticipant(self, pDesc):
        '''
        Adds participant to list and displays an event message.
        '''

        # Ignore participants without client profile (a monitor for example)
        if pDesc.clientProfile == "None" or pDesc.clientProfile == None:
            return

        self.AddInitParticipant(pDesc)

        # Add event text
        message = pDesc.clientProfile.name + " joined this session "

        # Add time to event message
        dateAndTime = strftime("%a, %d %b %Y, %H:%M:%S", localtime())
        message = message + " (" + dateAndTime + ")"

        # Events are coloured blue
        self.textCtrl.SetDefaultStyle(wx.TextAttr(wx.BLUE))
        self.textCtrl.AppendText(message + '\n')
        self.textCtrl.SetDefaultStyle(wx.TextAttr(wx.BLACK))

        self.__SetRightScroll()