【问题标题】:Get access to another window textEntry (Python)访问另一个窗口 textEntry (Python)
【发布时间】:2015-06-16 23:47:21
【问题描述】:

我正在使用 PyCharm 和 Glade 用户界面设计器。 我的项目包含两个窗口:MainSecondarySecondary 窗口从 Main 开始。在 Secondary 窗口中进行一些操作后,我应该将其关闭。但在我将一些数据保存在list 之前。当 Secondary 窗口关闭时,我想用来自list 的数据填充 Main 窗口上的一些 textEntry

最好的处理方法是什么? 我是 Python 的新手。关闭辅助窗口时可能更好地捕捉信号?还是把textEntryof Main窗口直接填在另一个窗口的代码里?

【问题讨论】:

    标签: python gtk pycharm glade


    【解决方案1】:

    我认为您有两个选择,将列表或修改列表的函数传递给辅助窗口。

    例如,函数可以这样传递:

    class Main():
        def __init__(self):
          s = Secondary(self.modify_list)
          mylist = []
    
          .
          .
    
          s.run()
    
          .
          .
    
       def modify_list(self, new_values):
           mylist = new_values
    
    class Secondary():
       def __init__(self, modify_list):
           self.modify_list = modify_list
    
       .
       .
    
       def apply(self):
           new_text = self.entry.get_buffer()
           self.modify_list(new_text)
    

    如果这对你有用,请告诉我!

    【讨论】:

      猜你喜欢
      • 2016-08-31
      • 1970-01-01
      • 1970-01-01
      • 2019-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多