Hello I’m trying to create a simple dialog extending the Eto.Forms.Form
as a base class and adding a couple arguments in the constructor for width
and height
maybe i need to learn more about inheritance but my basic examples seems like they should work
I haven’t gone through the entire Inheritance Hierarchy yet to check for issues…
System.Object
Eto.Widget
Eto.Forms.BindableWidget
Eto.Forms.Control
Eto.Forms.Container
Eto.Forms.Panel
Eto.Forms.Window
Eto.Forms.Form
but… I’ve tried several variations of class initialization with no luck always getting the same error:
Message: WebDialog() takes at most 2 arguments (3 given)
Test 1 (Failed)
This was the most obvious and basic…
import Eto.Forms as forms
import Eto.Drawing as drawing
class WebDialog(forms.Form):
def __init__(self, width=400, height=200):
self.Size = drawing.Size(width, height)
self.Title = "Test WebDialog"
if __name__ == "__main__":
dialog = WebDialog(500, 500)
dialog.Show()
Test 2 (Failed)
Trying *args
and **kwargs
…
import Eto.Forms as forms
import Eto.Drawing as drawing
class WebDialog(forms.Form):
def __init__(self, *args, **kwargs):
width = kwargs.get('width', 400)
height = kwargs.get('height', 200)
self.Size = drawing.Size(width, height)
self.Title = "Test WebDialog"
if __name__ == "__main__":
dialog = WebDialog(width=500, height=500)
dialog.Show()
Test 3 (Failed)
I tried explicitly initializing the base class at the beginning of the constructor…
import Eto.Forms as forms
import Eto.Drawing as drawing
class WebDialog(forms.Form):
def __init__(self, width=400, height=200):
forms.Form.__init__(self)
self.Size = drawing.Size(width, height)
self.Title = "Test WebDialog"
if __name__ == "__main__":
dialog = WebDialog(500, 500)
dialog.Show()
Test 4 (Failed)
I thought ok let me just use super()
to call the initializer of the base class forms.Form
and override the __init__
to ensure that the base class is properly initialized…
import Eto.Forms as forms
import Eto.Drawing as drawing
class WebDialog(forms.Form):
def __init__(self, width=400, height=200):
super(WebDialog, self).__init__()
self.Size = drawing.Size(width, height)
self.Title = "Test WebDialog"
if __name__ == "__main__":
dialog = WebDialog(width=500, height=500)
dialog.Show()
Test 5 (Something happens at least)
So if you call the WebDialog
class without passing the args the class will at least initalize.
import Eto.Forms as forms
import Eto.Drawing as drawing
class WebDialog(forms.Form):
def __init__(self, width=400, height=200):
self.Size = drawing.Size(width, height)
self.Title = "Test WebDialog"
if __name__ == "__main__":
dialog = WebDialog() # Called without args works
dialog.Show()
Other Things I’ve tried… with no luck.
- Reseting the Script Engine
- Explicitly delcaring the constructor like so:
class WebDialog(forms.Form):
def __new__(cls, width=400, height=200):
return super(WebDialog, cls).__new__(cls)
def __init__(self, width=400, height=200):
super(WebDialog, self).__init__()
Any help would be super awesome.