zoukankan      html  css  js  c++  java
  • 33-wxpython多个frame之间的信息共享

    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()
    

      

  • 相关阅读:
    顺时针打印二维矩阵
    hbase的rowKey设计原则
    关于这段时间学习 EntityFramework的 一点感悟
    一次排序序号的补充
    我的第一段jQuery代码
    非常郁闷的 .NET中程序集的动态加载
    关于EF6的记录Sql语句 与 EntityFramework.Extend 的诟病
    排序更改
    ZhyjEye 简介
    js数组去重的4个方法
  • 原文地址:https://www.cnblogs.com/zhumengdexiaobai/p/9911849.html
Copyright © 2011-2022 走看看