Python 3.x 使用Wx创建一个用户界面,其中图像从中加载,并使用wxmplot在其上绘制绘图

Python 3.x 使用Wx创建一个用户界面,其中图像从中加载,并使用wxmplot在其上绘制绘图,python-3.x,matplotlib,wxpython,ipython,wxwidgets,Python 3.x,Matplotlib,Wxpython,Ipython,Wxwidgets,使用以下程序,我在panel1中获得背景图像的输出。。 和面板2中的按钮。 1) 我想要背景图像上的绘图。 2) 输入来自面板2。 如何将打印链接到背景图像 导入wx 将numpy作为np导入 从wxmplot导入PlotApp class MyFrame(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, wx.DefaultPositi

使用以下程序,我在panel1中获得背景图像的输出。。 和面板2中的按钮。 1) 我想要背景图像上的绘图。 2) 输入来自面板2。 如何将打印链接到背景图像

导入wx 将numpy作为np导入 从wxmplot导入PlotApp

class MyFrame(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(1200,600))
        splitter = wx.SplitterWindow(self, -1)

        self.panel1 = wx.Panel(splitter, -1)
        panel2 = wx.Panel(splitter, -1)

        self.panel1.SetBackgroundColour(wx.LIGHT_GREY)
        panel2.SetBackgroundColour(wx.WHITE)

        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
        usernameLbl = wx.StaticText(panel2, label="Enter Angle:")
        self.username = wx.TextCtrl(panel2)
        self.addWidgets(usernameLbl, self.username)

        disbtn = wx.Button(panel2, label='Submit', pos=(90,40))
        disbtn.Bind(wx.EVT_BUTTON, self.onClick)

        panel2.SetSizer(self.mainSizer)
        self.Show()  

        self.sld = wx.Slider(panel2, -1, 45, 0, 360, (60,100), (250, -1),
                              wx.SL_AUTOTICKS | wx.SL_HORIZONTAL | wx.SL_LABELS)
        btn1 = wx.Button(panel2, 8, 'Adjust',pos=(90,150))
        wx.EVT_BUTTON(self, 8, self.OnAdjust)
        btn2 = wx.Button(panel2, 9, 'Close',pos=(180,150))
        wx.EVT_BUTTON(self, 9, self.OnClose)


        #img = wx.EmptyImage(400,400)
        img = wx.Image('image path')

        self.bitmap = wx.Bitmap('image path')
        wx.EVT_PAINT(self, self.OnPaint)
        self.Centre()


        self.imageCtrl = wx.StaticBitmap(self.panel1, wx.ID_ANY, 
                                        wx.BitmapFromImage(img))

        splitter.SplitVertically(self.panel1, panel2)

    def OnPaint(self, event):
        dc = wx.PaintDC(self)
        dc.DrawBitmap(self.bitmap, 60,20)


    def OnAdjust(self, event):
        val = self.sld.GetValue()
        print int(val)
    def OnClose(self, event):
        self.Close()

    def addWidgets(self, lbl, txt):
        """"""
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(lbl, 1, wx.ALL|wx.CENTER, 5)
        sizer.Add(txt, 2, wx.ALL|wx.EXPAND, 5)
        self.mainSizer.Add(sizer, 0, wx.ALL|wx.EXPAND)

    def onClick(self,event):
        #global app
        pai1 = (self.username.GetValue())
        self.username.Remove(0,len(pai1))
        pai=int(pai1)
        print pai
        th = np.linspace(0,2*np.pi,500)
        p=(np.cos(2*th)*np.cos(3*th))
        x = (p * np.cos(th+np.radians(pai)))
        y = (p * np.sin(th+np.radians(pai)))
        app.plot(self.panel1,x, y, label='PLOT', marker='.')

class MyApp(wx.App):
    def OnInit(self):
        frame = MyFrame(None, -1, 'splitterwindow.py')
        frame.Show(True)
        self.SetTopWindow(frame)
        return True


app = MyApp(0)
app.MainLoop()

这更像是一个wxmplot或matplotlib问题,您可能需要更新标记。