对象没有属性'create_main_panel'

时间:2019-01-01 16:16:36

标签: python wxpython wxpython-phoenix

我正在处理以前由其他人编写的代码。

在计算机上运行以下代码:

from wx import PySimpleApp, Size, TE_PROCESS_ENTER, Frame, Panel, 
SUNKEN_BORDER, StaticBox, PlatformInfo, TE_PROCESS_ENTER
from wx import BoxSizer, HORIZONTAL, TextCtrl, StaticText, Slider, 
SL_AUTOTICKS, SL_LABELS, EXPAND, ALL, CheckBox, WINDOW_VARIANT_SMALL
from wx import StaticBoxSizer, VERTICAL, LEFT, TOP, LEFT, RIGHT, GROW, 
Platform, PlatformInfo, GridSizer, Button, EVT_BUTTON
from wx import Slider, SL_AUTOTICKS, SL_LABELS, 
EVT_COMMAND_SCROLL_THUMBTRACK, SpinCtrl, EVT_SPINCTRL, 
ALIGN_CENTER_VERTICAL, ALIGN_CENTER_HORIZONTAL
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as NavigationToolbar
from matplotlib.pyplot import figure as Figure
from scipy import random, double, reshape, savetxt
import my_libs as my
from networkx import read_graphml, spring_layout, Graph, 
to_scipy_sparse_matrix, get_node_attributes, 
get_edge_attributes,draw_networkx, write_graphml

class MyFrame(Frame):
    def __init__(self, parent, ID, title):
        Frame.__init__(self, parent, ID, title, size=(1200, 700))

    ##set default values###########
    ##network##
        self.timesteps=20
        self.groupfile = 'groups.txt'
        self.nodefile = 'homes.txt'
        self.radius=5000
        self.P = 4
        self.W = 20
        self.Mvals = [0.45, 0.333, 0.15, 0.056, 0.008, 0.003]
        self.Pedge = [1.0]
        self.xmlfile = 'new_graph.xml'
        self.randseed = ''
        self.basename='new_data.txt'
        ##dynamics##
        self.a0=0
        self.b0=100
        self.c0=0   
        self.thresh0=30
        self.personal0=50
        self.scale0=10
    ###############################             

        self.create_main_panel()

导致以下错误:

  

AttributeError:“ MyFrame”对象没有属性“ create_main_panel”

有人知道如何解决此问题吗?

1 个答案:

答案 0 :(得分:0)

这仅仅是一个更大程序的开始。就目前而言,您无需采取任何措施来解决此问题,除非找到原始程序员的self.create_main_panel(),my_lib以及可能更多的代码,然后安装缺少的导入库(使用pip),例如mathplotlib,肮脏的等等。

以下代码可使代码最少运行,但只会产生一个空框架。

import wx
from    wx import Frame

class MyFrame(Frame):
    def __init__(self, parent, ID, title):
        Frame.__init__(self, parent, ID, title, size=(1200, 700))

    ##set default values###########
    ##network##
        self.timesteps=20
        self.groupfile = 'groups.txt'
        self.nodefile = 'homes.txt'
        self.radius=5000
        self.P = 4
        self.W = 20
        self.Mvals = [0.45, 0.333, 0.15, 0.056, 0.008, 0.003]
        self.Pedge = [1.0]
        self.xmlfile = 'new_graph.xml'
        self.randseed = ''
        self.basename='new_data.txt'
        ##dynamics##
        self.a0=0
        self.b0=100
        self.c0=0
        self.thresh0=30
        self.personal0=50
        self.scale0=10
    ###############################

        # self.create_main_panel()

if __name__ == '__main__':
    app = wx.App()
    frame = MyFrame(None, wx.ID_ANY, 'Any Title')
    frame.Show(True)
    app.MainLoop()