------------只要够努力,人生最坏的结局不过是大器晚成!!!

https://blog.csdn.net/xyisv/article/details/78576932

https://blog.csdn.net/tianmaxingkong_/article/details/53326463

 

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2018/10/27 15:19
# @Author  : ystraw
# @Site    :
# @File    : Calculator.py
# @Software: PyCharm Community Edition
# @function:

import wx
import math

class Calculator(wx.Frame):
    def __init__(self, update):
        wx.Frame.__init__(self, None, -1, 'ystraw_onw',
                size=(400, 500),  pos=(500, 100))
        self.panel = wx.Panel(self) #创建画
        self.update = update
        #创建输入文本框
        self.textprint = wx.TextCtrl(self.panel, wx.NewId(), 'ysong', size = (400, 55),  style=wx.TE_MULTILINE | wx.TE_READONLY)
        #创建button
        button = wx.Button(self.panel, wx.NewId(), 'one' , size=(100, 100), pos = (50 , 100))  # 将按钮添加到画板
        self.Bind(wx.EVT_BUTTON, self.exchang, button)

    def exchang(self, event):
        button = event.GetEventObject()
        self.textprint.SetValue('one')
        self.update(2)

class frame2(wx.Frame):
    def __init__(self, update):
        wx.Frame.__init__(self, None, -1, 'ystraw_two',
                size=(400, 500),  pos=(500, 100))
        self.panel = wx.Panel(self) #创建画
        self.update = update
        #创建输入文本框
        self.textprint = wx.TextCtrl(self.panel, wx.NewId(), 'yyy', size = (400, 55),  style=wx.TE_MULTILINE | wx.TE_READONLY)
        #创建button
        button = wx.Button(self.panel, wx.NewId(), 'two' , size=(100, 100), pos = (50 , 100))  # 将按钮添加到画板
        self.Bind(wx.EVT_BUTTON, self.exchang, button)

    def exchang(self, event):
        button = event.GetEventObject()
        self.textprint.SetValue('two')
        self.update(1)

class MyApp(wx.App):
  def OnInit(self):
    #创建窗口时要讲下面的函数一起传过去,这样在其它函数里面才能调用公共的函数,起到信息共享的效果
    self.myframe = Calculator(self.update)
    self.myframe2 = frame2(self.update)
    self.SetTopWindow(self.myframe)
    self.myframe.Show(True)
    self.myframe2.Show(True)
    return True
  #作为多个窗口之间的媒介
  def update(self, type):
      if type == 1:
         self.myframe.Show(False)
      else:
          self.myframe2.Show(False)
if __name__ == '__main__':
    app = MyApp(0)
    app.MainLoop()

  

posted on 2018-11-05 21:57  ystraw  阅读(431)  评论(0编辑  收藏  举报

不经一番切孤寒,怎得梅花扑鼻香