Good morning brothers,
I am new to Wxpython and’m breaking my head on a matter.
I created a calculator and one of calculations, I am trying to create a button that prompts the user to enter the radicand and the index, but in a single wx.Textctrl.
Follows the source code. I reduced to be more objective.
-- coding: cp1252 --
import wx
import math
class MyFrame(wx.Frame):
def init(self, parent, id):
wx.Frame.init(self, parent, id, title = ‘Test’, size = (400, 300), style = wx.DEFAULT_FRAME_STYLE)
self.panel = wx.Panel(self)
self.panel.SetBackgroundColour(’#E6E6FA’)
self.display = wx.TextCtrl(self.panel, -1, ‘’, (10,10),(360, 60), style = wx.TE_RIGHT)
self.display.SetFont(wx.Font(28, wx.DEFAULT, wx.NORMAL, wx.BOLD))
self.display.SetMaxLength(13)
self.calc = wx.Button(self.panel, 10,‘Root’, (10, 210),(70, 30))
self.calc2 = wx.Button(self.panel, 11,‘Root2’, (80,210),(70, 30))
self.Bind(wx.EVT_BUTTON, self.OnRoot,id=10)
self.Bind(wx.EVT_BUTTON, self.OnRoot2,id=11)
def OnRoot(self, event): #This it’s ok
a = self.display.GetValue()
b = math.sqrt(float(a))
self.display.Clear()
self.display.AppendText(str(b))
def OnRoot2(self, event): #But in here i am not knowing to resolve
a = self.display.GetValue()
self.display.Clear()
“”"
def Root(self, a, b): This it’s a calculation possibly, but i don’t know how put two arguments in a Textctrl.
return a**1.0/b
“”"
if name==‘main’:
frame = wx.App()
frm = MyFrame(parent= None, id = -1)
frm.Center()
frm.Show()
frame.MainLoop()
Please, help me…
A great day for all!!!