Skip to content
Snippets Groups Projects
Commit 53a71a13 authored by Heiko Raible's avatar Heiko Raible
Browse files

Update main.py

parent d8fa6177
No related branches found
No related tags found
1 merge request!13Update main.py
......@@ -13,6 +13,7 @@ class StatisticalGrammarChecker(wx.App):
frame.Show()
return True
class Frame(wx.Frame):
"""
Main Frame
......@@ -23,7 +24,7 @@ class Frame(wx.Frame):
def __init__(self):
# init
style = wx.SYSTEM_MENU | wx.CAPTION | wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX | wx.CLOSE_BOX | wx.CLIP_CHILDREN | wx.RESIZE_BORDER
super(Frame, self).__init__(parent=None, title="Statistical Grammar Checker", style=style, size=(600, 600))
super(Frame, self).__init__(parent=None, title="Statistical Grammar Checker", style=style, size=(600, 500))
# create panels
self.sizer = wx.BoxSizer()
......@@ -34,6 +35,7 @@ class Frame(wx.Frame):
# center frame
self.Center()
class Panel(wx.Panel):
def __init__(self, parent):
super(Panel, self).__init__(parent)
......@@ -59,7 +61,7 @@ class Panel(wx.Panel):
# create sizer
vboxsizer = wx.BoxSizer(wx.VERTICAL)
example_text = "We has all learned a lot in the last semester!"
example_text = ""
self.text_input = RichTextCtrl(parent=self, value=example_text, style=wx.TE_MULTILINE)
vboxsizer.Add(self.text_input, proportion=1, flag=wx.EXPAND | wx.ALL - wx.BOTTOM, border=5)
......@@ -75,7 +77,10 @@ class Panel(wx.Panel):
# THREADS
def grammar_check_thread(self):
# disable button
wx.CallAfter(self.button.SetLabel, "checking..")
wx.CallAfter(self.button.Enable, False)
# variables
output_text = ""
# get input
input_text = self.text_input.GetValue()
......@@ -104,6 +109,9 @@ class Panel(wx.Panel):
for color, highlights_list in highlights.items():
for highlight in highlights_list:
wx.CallAfter(self.text_output.SetStyle, highlight[0], highlight[1], wx.TextAttr(colText=wx.WHITE, colBack=wx.Colour(150, 0, 0) if color=="red" else wx.Colour(0, 150, 0)))
# re-enable button
wx.CallAfter(self.button.SetLabel, "grammar check!")
wx.CallAfter(self.button.Enable, True)
if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment