Ver Mensaje Individual
  #2 (permalink)  
Antiguo 25/02/2009, 19:43
iozk
 
Fecha de Ingreso: mayo-2008
Mensajes: 499
Antigüedad: 16 años
Puntos: 1
Respuesta: ayuda!!! con codigo

Código pythom:
Ver original
  1. ]
  2.  
  3.        
  4.  
  5. for flag,text in table:
  6.             if flag & modType:
  7.              
  8.  
  9.   st = st + text + " "
  10.  
  11.         if not st:
  12.             st =
  13.  
  14. 'UNKNOWN'
  15.  
  16.         return st
  17.  
  18.  
  19.  
  20.  
  21. #-------------------------------------------------------------------
  22.  
  23. ---
  24.  
  25. _USE_PANEL = 1
  26.  
  27. def runTest(frame, nb, log):
  28.     if not
  29.  
  30. _USE_PANEL:
  31.         ed = p = MySTC(nb, -1, log)
  32.  
  33.     else:
  34.         p
  35.  
  36. = wx.Panel(nb, -1, style=wx.NO_FULL_REPAINT_ON_RESIZE)
  37.         ed =
  38.  
  39. MySTC(p, -1, log)
  40.         s = wx.BoxSizer(wx.HORIZONTAL)
  41.        
  42.  
  43. s.Add(ed, 1, wx.EXPAND)
  44.         p.SetSizer(s)
  45.        
  46.  
  47. p.SetAutoLayout(True)
  48.  
  49.  
  50.     #ed.SetBufferedDraw(False)
  51.    
  52.  
  53. #ed.StyleClearAll()
  54.     #ed.SetScrollWidth(800)
  55.    
  56.  
  57. #ed.SetWrapMode(True)
  58.     #ed.SetUseAntiAliasing(False)    
  59.    
  60.  
  61. #ed.SetViewEOL(True)
  62.  
  63.     #ed.CmdKeyClear(stc.STC_KEY_BACK,
  64.     #    
  65.  
  66.            stc.STC_SCMOD_CTRL)
  67.    
  68.  
  69. #ed.CmdKeyAssign(stc.STC_KEY_BACK,
  70.     #                
  71.  
  72. stc.STC_SCMOD_CTRL,
  73.     #                stc.STC_CMD_DELWORDLEFT)
  74.  
  75.  
  76.  
  77.   ed.SetText(demoText)
  78.  
  79.     if wx.USE_UNICODE:
  80.         import
  81.  
  82. codecs
  83.         decode = codecs.lookup("utf-8")[1]
  84.  
  85.        
  86.  
  87. ed.GotoPos(ed.GetLength())
  88.         ed.AddText("\n\nwx.StyledTextCtrl
  89.  
  90. can also do Unicode:\n")
  91.         uniline = ed.GetCurrentLine()
  92.      
  93.  
  94.   unitext, l = decode('\xd0\x9f\xd0\xb8\xd1\x82\xd0\xbe\xd0\xbd - '
  95.  
  96.  
  97.                            
  98.  
  99. '\xd0\xbb\xd1\x83\xd1\x87\xd1\x88\xd0\xb8\xd0\xb9 '
  100.                  
  101.  
  102.            '\xd1\x8f\xd0\xb7\xd1\x8b\xd0\xba
  103.  
  104. \xd0\xbf\xd1\x80\xd0\xbe\xd0\xb3\xd1\x80\xd0\xb0\xd0\xbc\xd0\xbc\xd0
  105.  
  106. \xb8\xd1\x80\xd0\xbe\xd0\xb2\xd0\xb0\xd0\xbd\xd0\xb8\xd1\x8f!\n\n')
  107.  
  108.  
  109.        ed.AddText('\tRussian: ')
  110.         ed.AddText(unitext)
  111.        
  112.  
  113. ed.GotoPos(0)
  114.     #else:
  115.     #    
  116.  
  117. #ed.StyleSetFontEncoding(stc.STC_STYLE_DEFAULT,
  118.  
  119. wx.FONTENCODING_KOI8)
  120.     #    #text =
  121.  
  122. u'\u041f\u0438\u0442\u043e\u043d -
  123.  
  124. \u043b\u0443\u0447\u0448\u0438\u0439 \u044f\u0437\u044b\u043a
  125.  
  126. \n\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e
  127.  
  128. \u0432\u0430\u043d\u0438\u044f!'
  129.     #    #text =
  130.  
  131. text.encode('koi8-r')
  132.     #    
  133.  
  134. #ed.StyleSetFontEncoding(stc.STC_STYLE_DEFAULT,
  135.  
  136. wx.FONTENCODING_BIG5)
  137.     #    #text = u'Python
  138.  
  139. \u662f\u6700\u597d\u7684\u7de8\u7a0b\u8a9e\u8a00\uff01'
  140.     #    
  141.  
  142. #text = text.encode('big5')
  143.     #    ed.GotoPos(ed.GetLength())
  144.    
  145.  
  146. #    ed.AddText('\n\n' + text)
  147.        
  148.     ed.EmptyUndoBuffer()
  149.  
  150.    
  151.  
  152.  # make some styles
  153.     ed.StyleSetSpec(stc.STC_STYLE_DEFAULT,
  154.  
  155. "size:%d,face:%s" % (pb, face3))
  156.     ed.StyleClearAll()
  157.    
  158.  
  159. ed.StyleSetSpec(1, "size:%d,bold,face:%s,fore:#0000FF" % (pb,
  160.  
  161. face1))
  162.     ed.StyleSetSpec(2, "face:%s,italic,fore:#FF0000,size:%d"
  163.  
  164. % (face2, pb))
  165.     ed.StyleSetSpec(3, "face:%s,bold,size:%d" %
  166.  
  167. (face2, pb))
  168.     ed.StyleSetSpec(4, "face:%s,size:%d" % (face1,
  169.  
  170. pb-1))
  171.  
  172.     # Now set some text to those styles...  Normally this
  173.  
  174. would be
  175.     # done in an event handler that happens when text needs
  176.  
  177. displayed.
  178.     ed.StartStyling(98, 0xff)
  179.     ed.SetStyling(6, 1)  #
  180.  
  181. set style for 6 characters using style 1
  182.  
  183.     ed.StartStyling(190,
  184.  
  185. 0xff)
  186.     ed.SetStyling(20, 2)
  187.  
  188.     ed.StartStyling(310, 0xff)
  189.    
  190.  
  191. ed.SetStyling(4, 3)
  192.     ed.SetStyling(2, 0)
  193.     ed.SetStyling(10,
  194.  
  195. 4)
  196.  
  197.  
  198.     # line numbers in the margin
  199.     ed.SetMarginType(0,
  200.  
  201. stc.STC_MARGIN_NUMBER)
  202.     ed.SetMarginWidth(0, 22)
  203.    
  204.  
  205. ed.StyleSetSpec(stc.STC_STYLE_LINENUMBER, "size:%d,face:%s" % (pb-2,
  206.  
  207. face1))
  208.  
  209.     # setup some markers
  210.     ed.SetMarginType(1,
  211.  
  212. stc.STC_MARGIN_SYMBOL)
  213.     ed.MarkerDefine(0,
  214.  
  215. stc.STC_MARK_ROUNDRECT, "#CCFF00", "RED")
  216.     ed.MarkerDefine(1,
  217.  
  218. stc.STC_MARK_CIRCLE, "FOREST GREEN", "SIENNA")
  219.    
  220.  
  221. ed.MarkerDefine(2, stc.STC_MARK_SHORTARROW, "blue", "blue")
  222.    
  223.  
  224. ed.MarkerDefine(3, stc.STC_MARK_ARROW, "#00FF00", "#00FF00")
  225.  
  226.     #
  227.  
  228. put some markers on some lines
  229.     ed.MarkerAdd(17, 0)
  230.    
  231.  
  232. ed.MarkerAdd(18, 1)
  233.     ed.MarkerAdd(19, 2)
  234.     ed.MarkerAdd(20, 3)
  235.  
  236.  
  237.    ed.MarkerAdd(20, 0)
  238.  
  239.  
  240.     # and finally, an indicator or two
  241.    
  242.  
  243. ed.IndicatorSetStyle(0, stc.STC_INDIC_SQUIGGLE)
  244.    
  245.  
  246. ed.IndicatorSetForeground(0, wx.RED)
  247.     ed.IndicatorSetStyle(1,
  248.  
  249. stc.STC_INDIC_DIAGONAL)
  250.     ed.IndicatorSetForeground(1, wx.BLUE)
  251.    
  252.  
  253.  ed.IndicatorSetStyle(2, stc.STC_INDIC_STRIKE)
  254.    
  255.  
  256. ed.IndicatorSetForeground(2, wx.RED)
  257.  
  258.     ed.StartStyling(836,
  259.  
  260. stc.STC_INDICS_MASK)
  261.     ed.SetStyling(10, stc.STC_INDIC0_MASK)
  262.    
  263.  
  264. ed.SetStyling(8, stc.STC_INDIC1_MASK)
  265.     ed.SetStyling(10,
  266.  
  267. stc.STC_INDIC2_MASK | stc.STC_INDIC1_MASK)
  268.  
  269.  
  270.     # some test
  271.  
  272. stuff...
  273.     if debug:
  274.         print "GetTextLength(): ",
  275.  
  276. ed.GetTextLength(), len(ed.GetText())
  277.         print "GetText(): ",
  278.  
  279. repr(ed.GetText())
  280.         print
  281.         print "GetStyledText(98,
  282.  
  283. 104): ", repr(ed.GetStyledText(98, 104)), len(ed.GetStyledText(98,
  284.  
  285. 104))
  286.         print
  287.         print "GetCurLine(): ",
  288.  
  289. repr(ed.GetCurLine())
  290.         ed.GotoPos(5)
  291.         print
  292.  
  293. "GetCurLine(): ", repr(ed.GetCurLine())
  294.         print
  295.         print
  296.  
  297. "GetLine(1): ", repr(ed.GetLine(1))
  298.         print
  299.        
  300.  
  301. ed.SetSelection(25, 35)
  302.         print "GetSelectedText(): ",
  303.  
  304. repr(ed.GetSelectedText())
  305.         print "GetTextRange(25, 35): ",
  306.  
  307. repr(ed.GetTextRange(25, 35))
  308.         print "FindText(0, max,
  309.  
  310. 'indicators'): ",
  311.         print ed.FindText(0, ed.GetTextLength(),
  312.  
  313. "indicators")
  314.         if wx.USE_UNICODE:
  315.             end =
  316.  
  317. ed.GetLength()
  318.             start = ed.PositionFromLine(uniline)
  319.      
  320.  
  321.        print "GetTextRange(%d, %d): " % (start, end),
  322.            
  323.  
  324. print repr(ed.GetTextRange(start, end))
  325.  
  326.  
  327.    
  328.  
  329. wx.CallAfter(ed.GotoPos, 0)
  330.     return p
  331.  
  332.  
  333.  
  334. #-------------------------------------------------------------------
  335.  
  336. ---
  337.  
  338.  
  339. overview = """\
  340. <html><body>
  341. Once again, no docs yet.  
  342.  
  343. <b>Sorry.</b>  But <a href="data/stc.h.html">this</a>
  344. and <a
  345.  
  346. href="http://www.scintilla.org/ScintillaDoc.html">this</a> should
  347. be
  348.  
  349. helpful.
  350. </body><html>
  351. """
  352.  
  353.  
  354. if __name__ == '__main__':
  355.     import
  356.  
  357. sys,os
  358.     import run
  359.     run.main(['',
  360.  
  361. os.path.basename(sys.argv[0])] + sys.argv[1:])