Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9002365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:33:40+00:00 2026-06-16T00:33:40+00:00

I’m starting a simple little GUI for grading my student’s python source code. Is

  • 0

I’m starting a simple little GUI for grading my student’s python source code. Is there an easy way to automatically format display of the python code within a GUI? For example, pulling the color formatting from some editor?

I’ve started with Python tkk (just for a little extra python practice, I teach it but don’t use it much) but I have no objections switching languages if it is easier in this aspect.

The output will a webpage with all the grades etc, but will show the python code using Google Prettify (unless someone has a better suggestion), so I don’t need to keep the color scheme, just want it displayed to make grading easier.

Many thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:33:41+00:00Added an answer on June 16, 2026 at 12:33 am

    Just remembered that wxPython comes with SciTe bundled in:

    #!/usr/bin/env python
    
    import wx
    from wx import stc
    import keyword
    
    class PyDialog(wx.Dialog):
        def __init__(self):
            wx.Dialog.__init__(self, None, -1, 'Python Code')
            sizer = wx.BoxSizer(wx.VERTICAL)
    
            self.stc = stc.StyledTextCtrl(self, -1)
            self.stc.SetSizeHints(400, 400)
            self.stc.SetLexer(stc.STC_LEX_PYTHON)
            self.stc.SetKeyWords(0, " ".join(keyword.kwlist))
            self.stc.SetMarginType(1, stc.STC_MARGIN_NUMBER)
            # Python styles
            self.stc.StyleSetSpec(wx.stc.STC_P_DEFAULT, 'fore:#000000')
            # Comments
            self.stc.StyleSetSpec(wx.stc.STC_P_COMMENTLINE,  'fore:#008000,back:#F0FFF0')
            self.stc.StyleSetSpec(wx.stc.STC_P_COMMENTBLOCK, 'fore:#008000,back:#F0FFF0')
            # Numbers
            self.stc.StyleSetSpec(wx.stc.STC_P_NUMBER, 'fore:#008080')
            # Strings and characters
            self.stc.StyleSetSpec(wx.stc.STC_P_STRING, 'fore:#800080')
            self.stc.StyleSetSpec(wx.stc.STC_P_CHARACTER, 'fore:#800080')
            # Keywords
            self.stc.StyleSetSpec(wx.stc.STC_P_WORD, 'fore:#000080,bold')
            # Triple quotes
            self.stc.StyleSetSpec(wx.stc.STC_P_TRIPLE, 'fore:#800080,back:#FFFFEA')
            self.stc.StyleSetSpec(wx.stc.STC_P_TRIPLEDOUBLE, 'fore:#800080,back:#FFFFEA')
            # Class names
            self.stc.StyleSetSpec(wx.stc.STC_P_CLASSNAME, 'fore:#0000FF,bold')
            # Function names
            self.stc.StyleSetSpec(wx.stc.STC_P_DEFNAME, 'fore:#008080,bold')
            # Operators
            self.stc.StyleSetSpec(wx.stc.STC_P_OPERATOR, 'fore:#800000,bold')
            # Identifiers. I leave this as not bold because everything seems
            # to be an identifier if it doesn't match the above criterae
            self.stc.StyleSetSpec(wx.stc.STC_P_IDENTIFIER, 'fore:#000000')
    
            # Caret color
            self.stc.SetCaretForeground("BLUE")
            # Selection background
            self.stc.SetSelBackground(1, '#66CCFF')
    
            sizer.Add(self.stc, 0, wx.EXPAND)
    
            button = wx.Button(self, -1, 'Open...')
            self.Bind(wx.EVT_BUTTON, self.OnOpen, button)
            sizer.Add(button)
    
            self.SetSizer(sizer)
            sizer.Fit(self)
    
        def OnOpen(self, evt):
            dlg = wx.FileDialog(
                self,
                message = 'Choose File',
                wildcard = 'Python source (*.py)|*.py',
                style = wx.OPEN)
    
            if dlg.ShowModal() != wx.ID_OK:
                return
    
            with open(dlg.GetPath()) as fo:
                self.stc.SetText(fo.read())
    
            dlg.Destroy()
    
    
    if __name__ == '__main__':
        app = wx.PySimpleApp()
        dlg = PyDialog()
        with open(__file__) as fo:
            dlg.stc.SetText(fo.read())
        dlg.ShowModal()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I know there's a lot of other questions out there that deal with this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm making a simple page using Google Maps API 3. My first. One marker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.