зарание извиняюсь за кривость названия темы …
в общем есть форма (окно) wx python, python 2.7
#!/usr/bin/env python # -*- coding: utf-8 -*- # generated by wxGlade 0.6.5 (standalone edition) on Sun May import wx # begin wxGlade: extracode # end wxGlade class MyFrame(wx.Frame): def __init__(self, *args, **kwds): # begin wxGlade: MyFrame.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.panel_1 = wx.Panel(self, -1) self.panel_2 = wx.Panel(self, -1) self.panel_8 = wx.Panel(self, -1) self.panel_3 = wx.Panel(self, -1) self.button_1 = wx.Button(self, -1, _(u"выбрать прозрачность от 0 до 255")) self.panel_7 = wx.Panel(self, -1) self.panel_4 = wx.Panel(self, -1) self.panel_5 = wx.Panel(self, -1) self.panel_6 = wx.Panel(self, -1) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_BUTTON, self.clk_open_window, self.button_1) # end wxGlade def __set_properties(self): # begin wxGlade: MyFrame.__set_properties self.SetTitle(_(u"базовое окно")) # end wxGlade def __do_layout(self): # begin wxGlade: MyFrame.__do_layout sizer_1 = wx.BoxSizer(wx.VERTICAL) grid_sizer_1 = wx.GridSizer(3, 3, 0, 0) grid_sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0) grid_sizer_1.Add(self.panel_2, 1, wx.EXPAND, 0) grid_sizer_1.Add(self.panel_8, 1, wx.EXPAND, 0) grid_sizer_1.Add(self.panel_3, 1, wx.EXPAND, 0) grid_sizer_1.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_1.Add(self.panel_7, 1, wx.EXPAND, 0) grid_sizer_1.Add(self.panel_4, 1, wx.EXPAND, 0) grid_sizer_1.Add(self.panel_5, 1, wx.EXPAND, 0) grid_sizer_1.Add(self.panel_6, 1, wx.EXPAND, 0) sizer_1.Add(grid_sizer_1, 1, wx.EXPAND, 0) self.SetSizer(sizer_1) sizer_1.Fit(self) self.Layout() # end wxGlade def clk_open_window(self, event): # wxGlade: MyFrame.<event_handler> frm1 = MyFrame1(None, -1, "") frm1.Show() # test проверка на срабатывание функции # self.qwerty(200) print "Event handler `clk_open_window' not implemented!" event.Skip() def qwerty(self, var): #выставить прозрачность окну MyFrame.SetTransparent(self, var) # проверка на срабатывание print("i work? transpose???", var) # end of class MyFrame class MyFrame1(wx.Frame): def __init__(self, *args, **kwds): # begin wxGlade: MyFrame1.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.panel_14 = wx.Panel(self, -1) self.panel_10 = wx.Panel(self, -1) self.spin_ctrl_1 = wx.SpinCtrl(self, -1, "255", min=0, max=255) self.panel_13 = wx.Panel(self, -1) self.button_2 = wx.Button(self, -1, _(u"пременить")) self.panel_12 = wx.Panel(self, -1) self.panel_11 = wx.Panel(self, -1) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_BUTTON, self.clk_transpose, self.button_2) # end wxGlade def __set_properties(self): # begin wxGlade: MyFrame1.__set_properties self.SetTitle(_(u"прозрачность")) # end wxGlade def __do_layout(self): # begin wxGlade: MyFrame1.__do_layout sizer_2 = wx.BoxSizer(wx.VERTICAL) sizer_3 = wx.BoxSizer(wx.VERTICAL) sizer_4 = wx.BoxSizer(wx.HORIZONTAL) sizer_3.Add(self.panel_14, 1, wx.EXPAND, 0) sizer_4.Add(self.panel_10, 1, wx.EXPAND, 0) sizer_4.Add(self.spin_ctrl_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0) sizer_4.Add(self.panel_13, 1, wx.EXPAND, 0) sizer_4.Add(self.button_2, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0) sizer_4.Add(self.panel_12, 1, wx.EXPAND, 0) sizer_3.Add(sizer_4, 1, wx.EXPAND, 0) sizer_3.Add(self.panel_11, 1, wx.EXPAND, 0) sizer_2.Add(sizer_3, 1, wx.EXPAND, 0) self.SetSizer(sizer_2) sizer_2.Fit(self) self.Layout() # end wxGlade def clk_transpose(self, event): # wxGlade: MyFrame1.<event_handler> spn = int(self.spin_ctrl_1.GetValue()) print spn #!!! ПОЧЕМУ ОНО НЕ СРАБАТЫВАЕТ ??? MyFrame(None, -1, "").qwerty(spn) #!!! print "Event handler `clk_transpose' not implemented!" event.Skip() # end of class MyFrame1 class MyApp(wx.App): def OnInit(self): wx.InitAllImageHandlers() frame_1 = MyFrame(None, -1, "") self.SetTopWindow(frame_1) frame_1.Show() return 1 # end of class MyApp if __name__ == "__main__": import gettext gettext.install("app") # replace with the appropriate catalog name app = MyApp(0) app.MainLoop()
class A: def __init__(self, b_object: B): self.b = b_object def do_something(self): self.b.opacity += 1 b = B() a = A(b) a.do_something()