Meine Lösung war es jetzt einfach eine Hilf's def zu machen:
Code: Alles auswählen
def putVar(self, Variable):
self.Variable = Variable
app = MyApp(redirect=False)
app.putVar( "BlaBla" )
app.MainLoop()
Code: Alles auswählen
def putVar(self, Variable):
self.Variable = Variable
app = MyApp(redirect=False)
app.putVar( "BlaBla" )
app.MainLoop()
Code: Alles auswählen
import wx
class VarApp(wx.App):
def __init__(self, *args, **kwargs):
wx.App.__init__(self, *args)
print kwargs
def OnInit(self):
sa = wx.PySimpleApp()
wx.PySimpleApp.OnInit(sa)
return True
a = VarApp(0, myvar='abc')
Code: Alles auswählen
import wx
class VarApp(wx.App):
def __init__(self, MyClass, *args, **kwargs):
wx.App.__init__(self, *args)
self.MyClass = MyClass
def OnInit(self):
[BlaBla]
a = VarApp( MyClass, redirect=False )
Nicht? Also bei mir geht das sehr wohl:jens hat geschrieben:Ist auch nicht schlecht... Allerdings will ich keine Variable, sondern ein Python-Objekt (eine Klasse) übergeben und das schein mit deiner Variante nicht zu funktionieren...
Code: Alles auswählen
import wx
class MyClass:
pass
class VarApp(wx.App):
def __init__(self, *args, **kwargs):
wx.App.__init__(self, *args)
print kwargs
def OnInit(self):
sa = wx.PySimpleApp()
wx.PySimpleApp.OnInit(sa)
return True
# Einmal mit der Klasse
a = VarApp(0, myclass=MyClass)
# und einmal mit einer Instanz einer Klasse
ci = MyClass()
b = VarApp(0, myclass=ci)
Code: Alles auswählen
class App(wx.App):
def __init__(self, XRCfile, *args, **kwargs):
self.XRCfile = XRCfile
wx.App.__init__(self, *args, **kwargs)
def OnInit(self):
self.res = wx.xrc.XmlResource( self.XRCfile, wx.xrc.XRC_NO_SUBCLASSING )
if self.res.GetVersion() == -1:
raise 'Datei "%s" nicht gefunden!!!' % self.XRCfile
XRCfile = "\\GUI\\app.xrc"
MyApp = App( XRCfile, redirect=False )
MyApp.MainLoop()