Пример #1
0
 def OnInit(self):
     import wx, sys
     from Priithon.py import shell
     wx.InitAllImageHandlers()
     self.frame = shell.ShellFrame(
         title="priithon on %s" % wx.GetHostName(),
         introText=' !!! Welcome to Priithon !!! \n' +
         '(Python %s on %s)' %
         (sys.version.replace('\n', ' '), sys.platform),
         introStatus='Priithon: %s' % sys.argv)
     self.frame.SetSize((750, 525))
     self.frame.Show()
     self.SetTopWindow(self.frame)
     self.frame.shell.SetFocus()
     return True
Пример #2
0
        def OnInit(self):
            import wx,sys
            #from wx.py import shell
            from Priithon import shell
            introText=' !!! Welcome to Priithon !!! \n'
            self.frame = shell.PriShellFrame(introText=introText,#ShellFrame(
                title="priithon on %s" % wx.GetHostName())#, 20141127

            intro = 'Priithon: %s' % sys.argv
            self.frame.SetStatusText(intro.replace('\n', ', '))
        
            from Priithon import fileDropPopup
            self.frame.shell.SetDropTarget( fileDropPopup.FileDropTarget(self.frame, self.frame.shell) )
            self.frame.SetSize((750, 525))
            self.frame.Show()
            self.SetTopWindow(self.frame)
            self.frame.shell.SetFocus()
            return True
Пример #3
0
def drawFooter(c, page, srcFile, no):
    #2013.10.10
    srcFile = srcFile.decode('utf8')  #?
    line = "Page %d-%d     %s  :  %s    %s" % (no, page, wx.GetHostName(),
                                               wx.GetUserName(), srcFile)
    t = time.localtime()
    ctime = '%04d-%02d-%02d %02d:%02d:%02d' % (t.tm_year, t.tm_mon, t.tm_mday,
                                               t.tm_hour, t.tm_min, t.tm_sec)

    c.setFont("MyFont", 8)
    c.line(5, 25, 590, 25)
    c.drawString(10, 10, line)
    c.drawRightString(585, 10, ctime)

    c.line(5, 810, 590, 810)
    line = u"2014级程序设计原理与C语言"
    c.drawString(10, 820, line)
    line = "Principles of Programming for grade 2014"
    c.drawRightString(585, 820, line)
Пример #4
0
        def OnInit(self):
            import wx, sys, os
            #from .py import shell
            # absolute import
            # ValueError: Attempted relative import in non-package
            # NOTE: this is where Priithon is beeing started - i.e. we are not yet "inside" the Priithon module
            from Priithon.py import shell

            wx.InitAllImageHandlers()
            title = "priithon on %s (pid: %s)" % (wx.GetHostName(),
                                                  os.getpid())
            print title  # to know which terminal window belongs to which Priithon
            self.frame = shell.ShellFrame(
                title=title,
                introText=' !!! Welcome to Priithon !!! \n' +
                '(Python %s on %s)' %
                (sys.version.replace('\n', ' '), sys.platform),
                introStatus='Priithon: %s' % sys.argv)
            self.frame.SetSize((750, 525))
            self.frame.Show()
            self.SetTopWindow(self.frame)
            self.frame.shell.SetFocus()
            return True
Пример #5
0
def 程序_取计算机名():
    "返回当前应用程序对象"
    return wx.GetHostName()
Пример #6
0
from . import all
for n in all.__dict__:
    if not n.startswith('_'):
        exec "%s = all.%s" % (n,n)
del n, all
#</hack>

def _sebsDisplHook(v):
    if not v is None: # != None:
        import __main__ #global _
        #_ = v
        __main__._ = v
        print U.myStr(v)
        
import sys
sys.displayhook = _sebsDisplHook
#print "debug: Pr/includeAll"
#if sys.argv[1:]:
#    import string
#    print "start->eval:", sys.argv[1:]
#    eval(string.join(sys.argv[1:]))

#20051117-TODO: CHECK if good idea  U.naSetArrayPrintMode(precision=4, suppress_small=0)

import wx
if hasattr(sys,'argv') and wx.GetApp() is not None: # CHECK: in embedded wxPython sys,.argv not defined
    # sys.app not defined yet
    wx.GetApp().GetTopWindow().SetTitle("priithon on %s" % wx.GetHostName())
del wx
del sys
Пример #7
0
def test(srcFiles, values={}, passwd='C2014', outfile=None):

    srcFiles = sorted(srcFiles, key=basename)

    registerFont(UnicodeCIDFont('STSong-Light'))

    from reportlab.pdfbase import ttfonts
    #    font = ttfonts.TTFont('MyFont', r'C:\Windows\Fonts\simhei.ttf')
    font = ttfonts.TTFont('MyFont', r'msyhbd.ttf')
    #    font = ttfonts.TTFont('MyFont', 'msyhbd.ttf')
    registerFont(font)

    user = values.get('user', '')
    if user: user = user.encode('utf8')

    name = values.get('name', '').encode('utf8')

    password = values.get('passwd', '')
    if password.strip(): passwd = password.encode('utf8')  #?

    if values.get('lab', '') != '':
        labv = int(values.get('lab', '0'))
    else:
        labv = 0
    if 0 < labv < 20: lab = ('Lab%d' % labv).encode('utf8')
    else: lab = u''

    #    if user.startswith('10132130') and 0<labv<20:
    #    2013.10.10
    if user.startswith('101') and len(user) == 11 and 0 < labv < 20:
        #    2013.10.10
        #       outfile = (os.getcwd()+'/'+user.encode('utf8')+'_'+'%02d.c'%labv).encode('utf8')
        #?
        outfile = (os.getcwdu() + u'/' + user.encode('utf8') + u'_' +
                   u'%02d.PDF' % labv)

    if outfile == None:

        #      if srcFiles[0].rfind('.')!=-1:
        #         pdffile = srcFiles[0][:srcFiles[0].rfind('.')]
        #      else: pdffile = srcFiles[0]
        #    2013.10.10
        bname = basename(srcFiles[0])
        if bname.rfind('.') != -1:
            pdffile = bname[:bname.rfind('.')]
        else:
            pdffile = bname
        pdffile = os.getcwd() + '/' + pdffile
        #    2013.10.10
        pdffile = unicode(pdffile.decode('utf8'))  #?

    else:
        if outfile.rfind('.') != -1:
            pdffile = outfile[:outfile.rfind('.')]
        else:
            pdffile = outfile

#    2013.10.10
#    pdffile --> pdffile.encode('gbk')

    if passwd == "C2014": c = Canvas(pdffile.encode('utf8') + '.pdf')
    else:
        c = Canvas(pdffile.encode('utf8')+'.pdf',\
                encrypt=pdfencrypt.StandardEncryption\
                (passwd,ownerPassword='******',canPrint=0,canCopy=0))

#    c = Canvas(pdffile+'.pdf')
    c.showOutline()

    c.setAuthor(u"LU")
    c.setTitle(u"2014级程序设计原理与C语言作业")
    c.setSubject(u"作业")
    c.setCreator(u"C2PDF")
    c.setKeywords(['C语言', '程序设计', '作业', '2014级'])

    blank = "", ""
    line1 = u"课程名", u"2014级程序设计原理与C语言" + '      ' + u"Principles of Programming & C"
    chost = u"机器名", wx.GetHostName()
    cuser = u"用户名", wx.GetUserName()
    ID = u"学号", user
    USER = u"姓名", name
    grade = u"成绩", u" "
    labName = u"作业名", lab
    lines = (line1, chost, cuser, ID, USER, blank, labName, grade)

    c.setFont("MyFont", 12)
    x, y, delta = 50, 800, 20
    for line in lines:
        c.drawString(x, y, line[0])
        from reportlab.lib.colors import pink, black, red, blue, green

        if line[0] == u"成绩":
            #        c.saveState()
            c.setFillColor(red)
            c.setFont("MyFont", 20)
            y -= 15
            c.drawString(x + 70, y, line[1])
            c.setFont("MyFont", 12)
            c.setFillColor(black)


#        c.restoreState()
        else:
            c.drawString(x + 70, y, line[1])
        y -= delta

    filelist = srcFiles
    s0 = "Table of Contents"
    c.bookmarkPage(s0, 'FitH')
    c.addOutlineEntry(s0, s0)
    for no, f in enumerate(filelist):

        #       c.addOutlineEntry(basename(f),f)
        #       2013.10.10
        c.addOutlineEntry(basename(f).decode('utf8'), f)  #?
        y -= delta
        #       c.drawString(x, y, "%2d: %s"%(no+1,f))
        #       2013.10.10
        c.drawString(x, y, "%2d: %s" % (no + 1, f.decode('utf8')))  #?
        c.linkRect("", f, (x, y + delta - 5, x + 400, y - 5), Border='[0 0 0]')

    t = time.localtime()
    ctime = '%04d-%02d-%02d %02d:%02d:%02d' % (t.tm_year, t.tm_mon, t.tm_mday,
                                               t.tm_hour, t.tm_min, t.tm_sec)
    c.drawString(x + 70, y - 2 * delta, ctime)

    c.showPage()

    for no, f in enumerate(filelist):
        outOneFile(f, c, no + 1)
    """
    from reportlab.lib.styles import getSampleStyleSheet
    from reportlab.platypus import Paragraph, Frame
    styles = getSampleStyleSheet()

    toc = TableOfContents()
    PS = ParagraphStyle
    toc.levelStyles = [
    PS(fontName='Times-Bold', fontSize=14, name='TOCHeading1',\
       leftIndent=20, firstLineIndent=-20, spaceBefore=5, leading=16),
    PS(fontSize=12, name='TOCHeading2',\
      leftIndent=40, firstLineIndent=-20, spaceBefore=0, leading=12) ]


    styleN = styles['Normal']
    styleH = styles['Heading1'] 
    styleH2 = styles['Heading2'] 
    story = [ ]

    story.append(Paragraph("This is a Heading<font size=54> abc[&alpha;] <greek>e</greek> <greek>p</greek> </font>",styleH))
    story.append(Spacer(inch,inch))
    story.append(Paragraph("This is a paragraph in <i>Normal</i> style.", styleN))
    story.append(Paragraph("This is a Heading2 style.", styleH2))
    toc.addEntry(0, 'txt', 1)
    toc.addEntry(1, 'txt1', 2)
    
    story.append(toc)
    f = Frame(inch, inch, 6*inch, 9*inch, showBoundary=1)
    f.addFromList(story,c)
    """
    c.save()
    #    print 'saved PDF file for '+pdffile

    return pdffile + u'.pdf'
import wx, os, json, platform

import keyring  #store passwords safely in the os

#see http://zetcode.com/wxpython/skeletons/ for tips

DEFAULT_DEVICE_NAME = "%s (%s %s)" % (wx.GetHostName(), platform.system(),
                                      platform.release())


class MenuBarMixin():
    """Cannot subclass wx.menu_bar directly, so make it a mixin"""

    quit_item_id = wx.NewId(
    )  #wx.ID_EXIT #causes something to appear in statusbar
    toggle_item_id = wx.NewId()
    about_item_id = wx.NewId()
    login_item_id = wx.NewId()

    def doMenuBar(self):
        menu_bar = wx.MenuBar()

        file_menu = wx.Menu()
        self.toggle_item = file_menu.Append(self.toggle_item_id,
                                            'Pause PasteBeam')
        quit_item = file_menu.Append(self.quit_item_id, 'Quit')
        menu_bar.Append(file_menu, '&File')

        edit_menu = wx.Menu()
        login_item = edit_menu.Append(self.login_item_id, 'Login')
        menu_bar.Append(edit_menu, '&Edit')