2016-05-22 16 views
0

Ich habe versucht, diese folgende Datei auszuführen, aber es hat nicht funktioniert. Es muss normalerweise eine grafische Benutzeroberfläche anzeigen, die mit der Bibliothek wxPython erstellt wurde.AttributeError: 'Modul' Objekt hat kein Attribut 'SystemSettings_GetFont'

import wx 

class GoToClass(wx.Frame): 
    def __init__(self, parent, id, title): 
     wx.Frame.__init__(self, parent, id, title, size=(390, 350)) 
     panel = wx.Panel(self, -1) 

    font = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT) 
    font.SetPointSize(9) 

    vbox = wx.BoxSizer(wx.VERTICAL) 

    hbox1 = wx.BoxSizer(wx.HORIZONTAL) 
    st1 = wx.StaticText(panel, -1, 'Class Name') 
    st1.SetFont(font) 
    hbox1.Add(st1, 0, wx.RIGHT, 8) 
    tc = wx.TextCtrl(panel, -1) 
    hbox1.Add(tc, 1) 
    vbox.Add(hbox1, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 10) 

    vbox.Add((-1, 10)) 

    hbox2 = wx.BoxSizer(wx.HORIZONTAL) 
    st2 = wx.StaticText(panel, -1, 'Matching Classes') 
    st2.SetFont(font) 
    hbox2.Add(st2, 0) 
    vbox.Add(hbox2, 0, wx.LEFT | wx.TOP, 10) 

    vbox.Add((-1, 10)) 

    hbox3 = wx.BoxSizer(wx.HORIZONTAL) 
    tc2 = wx.TextCtrl(panel, -1, style=wx.TE_MULTILINE) 
    hbox3.Add(tc2, 1, wx.EXPAND) 
    vbox.Add(hbox3, 1, wx.LEFT | wx.RIGHT | wx.EXPAND, 10) 

    vbox.Add((-1, 25)) 

    hbox4 = wx.BoxSizer(wx.HORIZONTAL) 
    cb1 = wx.CheckBox(panel, -1, 'Case Sensitive') 
    cb1.SetFont(font) 
    hbox4.Add(cb1) 
    cb2 = wx.CheckBox(panel, -1, 'Nested Classes') 
    cb2.SetFont(font) 
    hbox4.Add(cb2, 0, wx.LEFT, 10) 
    cb3 = wx.CheckBox(panel, -1, 'Non-Project classes') 
    cb3.SetFont(font) 
    hbox4.Add(cb3, 0, wx.LEFT, 10) 
    vbox.Add(hbox4, 0, wx.LEFT, 10) 

    vbox.Add((-1, 25)) 

    hbox5 = wx.BoxSizer(wx.HORIZONTAL) 
    btn1 = wx.Button(panel, -1, 'Ok', size=(70, 30)) 
    hbox5.Add(btn1, 0) 
    btn2 = wx.Button(panel, -1, 'Close', size=(70, 30)) 
    hbox5.Add(btn2, 0, wx.LEFT | wx.BOTTOM , 5) 
    vbox.Add(hbox5, 0, wx.ALIGN_RIGHT | wx.RIGHT, 10) 

    panel.SetSizer(vbox) 
    self.Centre() 
    self.Show(True) 

app = wx.App() 
GoToClass(None, -1, 'Go To Class') 
app.MainLoop() 

Dies ist der gesamte Nachrichtenfehler. Es besagt, dass der Fehler von der Zeile 12 kommt, das Attribut SystemSettings_GetFont kann nicht gefunden werden.

Traceback (most recent call last): File "C:/Python34/Test_wxPython/GotoClass.py", line 68, in <module> GoToClass(None, -1, 'Go To Class') File "C:/Python34/Test_wxPython/GotoClass.py", line 12, in __init__ font = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT) AttributeError: 'module' object has no attribute 'SystemSettings_GetFont'

+0

Warum denken Sie, dass Attribut vorhanden ist? –

+0

Dieses Attribut 'SystemSettings_GetFont' muss in der wxPython-Bibliothek gefunden werden. –

Antwort

4

Wie Sie python3.4 verwenden Sie phoenix verwenden. Wxpython phoenix geändert SystemSettings_GetFont zu SystemSettings.GetFont

+1

Weitere Informationen zu den Unterschieden zwischen Phoenix und Classic wxPython finden Sie im Migrationshandbuch unter http://wxpython.org/Phoenix/docs/html/MigrationGuide.html – RobinDunn

Verwandte Themen