Does anyone here know both WxLua and WxPython?
I'm wondering how the syntax of WxLua differs from that of the current version of WxPython.
For instance, here's a sample wxPython program. How would one do this sort of thing in WxLua? (This code portrays an input and an output screen, sort of like a command-line; if you press enter with no input, it will output "Hello World"; cls and clear will clear the screen, and anything else will output whatever you typed; also try resizing the window.)
import wx
class MyFrame(wx.Frame):
writeHeight = 50 #this is the height of the box, or prompt, which you write in.
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title)
mainPanel = wx.Panel(self, -1)
self.read = wx.TextCtrl(self,-1,"",wx.Point(15,95),wx.Size(469,118),wx.TE_MULTILINE)
self.read.SetForegroundColour(wx.Colour(210,193,136))
self.read.SetBackgroundColour(wx.Colour(0,0,0))
self.read.SetFont(wx.Font(20,74,90,90,0, "Courier New"))
self.read.SetEditable(False)
self.write = wx.TextCtrl(self, -1, "", (0,self.GetClientSize().GetHeight()-self.writeHeight), (self.GetClientSize().GetWidth(),self.writeHeight))
self.write.SetForegroundColour(wx.Colour(210,193,136))
self.write.SetBackgroundColour(wx.Colour(0,0,0))
self.write.SetFont(wx.Font(20,74,90,90,0, "Verdana"))
self.Bind(wx.EVT_SIZE, self.AdjustSize, self)
self.write.SetFocus()
self.write.Bind(wx.EVT_KEY_DOWN, self.EvaluatePrompt, self.write)
def AdjustSize(self, evt):
width=self.GetClientSize().GetWidth()
height=self.GetClientSize().GetHeight()-self.writeHeight
self.read.SetSize((width, height))
self.read.Move((0,0))
writeVerticalPos = self.GetClientSize().GetHeight()-self.writeHeight
self.write.Move((0,writeVerticalPos))
self.write.SetSize((self.GetClientSize().GetWidth(),self.writeHeight))
def EvaluatePrompt(self, evt):
evt.Skip()
if evt.GetKeyCode()==wx.WXK_RETURN or evt.GetKeyCode()==wx.WXK_NUMPAD_ENTER:
prompt = self.write.GetValue()
#START IF STATEMENTS:
if prompt == "":
self.read.SetValue("Hello world!" + "\n")
elif prompt.lower()=="cls" or prompt.lower()=="clear":
self.read.SetValue("")
else:
self.read.AppendText(prompt + "\n")
self.write.SelectAll()
app = wx.PySimpleApp()
f = MyFrame(None, "Hello World Program")
f.Show()
app.MainLoop()
PS: Feel free to use this code as you will (commercially or not). It's generic enough in my book not to make a big deal out of it.