Bonjour

Du coup, j'ai créé une class qui sera mon principal GUI. Elle s’appelle main_windows. Dans la GUI principal, en cliquant le bouton button_1, le programme va appeler une deuxieme GUI qui va demander à l'utilisateur de rentrer des valeurs dont on a besoin après. le module pour la GUI s'appelle sub_windows et il se situer dans un autre endroit.

De plus, j'ai créé une class qui s'appele Model pour faciliter la stockage des attributes.

ma question c'est comment de la GUI principale, je peux appeler la deuxieme GUI et en meme temps envoyer le class Model à la deuxieme GUI.

voici les codes
pour le module de la premiere GUI :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
 
#!/usr/bin/env python
# -*- coding: CP1252 -*-
#
# generated by wxGlade 0.6.8 (standalone edition) on Thu Apr 21 09:14:23    2016
#
 
import wx
 
# begin wxGlade: dependencies
import gettext
# end wxGlade
 
# begin wxGlade: extracode
# end wxGlade
class Model():
    def __init__ (self)
        self.a = None
        self.b = None
 
class MyParentFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyParentFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.label_1 = wx.StaticText(self, wx.ID_ANY, _("Main_Windows"))
        self.button_1 = wx.Button(self, wx.ID_ANY, _("Enter Value"))
        self.button_2 = wx.Button(self, wx.ID_ANY, _("Add\n"))
        self.label_4 = wx.StaticText(self, wx.ID_ANY, _("Results"),    style=wx.ALIGN_CENTRE)
        self.button_3 = wx.Button(self, wx.ID_ANY, _("button_3"))
 
        self.__set_properties()
        self.__do_layout()
 
        self.Bind(wx.EVT_BUTTON, self.to_sub_windows, self.button_1)
        self.Bind(wx.EVT_BUTTON, self.addition, self.button_2)
 
 
 
    # end wxGlade
 
def __set_properties(self):
    # begin wxGlade: MyParentFrame.__set_properties
    self.SetTitle(_("frame_1"))
    self.label_1.SetFont(wx.Font(15, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "MS Shell Dlg 2"))
    self.label_4.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "MS Shell Dlg 2"))
    # end wxGlade
 
def __do_layout(self):
    # begin wxGlade: MyParentFrame.__do_layout
    sizer_1 = wx.BoxSizer(wx.VERTICAL)
    grid_sizer_1 = wx.GridSizer(5, 5, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add(self.label_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add(self.button_2, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add(self.label_4, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add(self.button_3, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    sizer_1.Add(grid_sizer_1, 1, wx.EXPAND, 0)
    self.SetSizer(sizer_1)
    sizer_1.Fit(self)
    self.Layout()
 
    def to_sub_windows(self)
 
        #What shoud I put here to call the sub_windows?
        __________
 
    # end wxGlade
 
    def addition(self, Model)
 
        self.c = Model.a.GetValue() + Model.b.GetValue()
 
 
 
    # end wxGlade
 
    # end of class MyParentFrame
if __name__ == "__main__":
    gettext.install("app") # replace with the appropriate catalog name
 
    app = wx.PySimpleApp(0)
    wx.InitAllImageHandlers()
    frame_1 = MyParentFrame(None, wx.ID_ANY, "")
    app.SetTopWindow(frame_1)
    frame_1.Show()
    app.MainLoop()
et le module pour la deuxieme GUI :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
 
import wx
 
# begin wxGlade: dependencies
import gettext
# end wxGlade
 
# begin wxGlade: extracode
# end wxGlade
 
 
class SubFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: SubFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.label_1 = wx.StaticText(self, wx.ID_ANY, _("Sub Window"), style=wx.ALIGN_CENTRE)
         self.label_2 = wx.StaticText(self, wx.ID_ANY, _("A"), style=wx.ALIGN_CENTRE)
         self.text_ctrl_1 = wx.TextCtrl(self, wx.ID_ANY, "")
         self.label_3 = wx.StaticText(self, wx.ID_ANY, _("B"), style=wx.ALIGN_CENTRE)
         self.text_ctrl_2 = wx.TextCtrl(self, wx.ID_ANY, "")
         self.button_1 = wx.Button(self, wx.ID_ANY, _("OK"))
 
         self.__set_properties()
         self.__do_layout()
 
         self.Bind(wx.EVT_BUTTON, self.submit, self.button_1)
         # end wxGlade
 
def __set_properties(self):
    # begin wxGlade: SubFrame.__set_properties
    self.SetTitle(_("frame_1"))
    self.label_1.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "MS Shell Dlg 2"))
    self.label_2.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "MS Shell Dlg 2"))
    self.label_3.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "MS Shell Dlg 2"))
    # end wxGlade
 
def __do_layout(self):
    # begin wxGlade: SubFrame.__do_layout
    sizer_1 = wx.BoxSizer(wx.VERTICAL)
    grid_sizer_1 = wx.GridSizer(5, 5, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add(self.label_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add(self.label_2, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add(self.text_ctrl_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add(self.label_3, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add(self.text_ctrl_2, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add(self.button_1, 0, 0, 0)
    # grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    grid_sizer_1.Add((20, 20), 0, 0, 0)
    sizer_1.Add(grid_sizer_1, 1, wx.EXPAND, 0)
    self.SetSizer(sizer_1)
    sizer_1.Fit(self)
    self.Layout()
    # end wxGlade
 
    def submit(self, event):  # wxGlade: SubFrame.<event_handler>
 
          What should I put here to send the value a, b from this module to   the module main_windows
          print "Event handler 'submit' not implemented!"
          event.Skip()
 
  # end of class SubFrame
if __name__ == "__main__":
     gettext.install("app") # replace with the appropriate catalog name
 
    app = wx.PySimpleApp(0)
    wx.InitAllImageHandlers()
    frame_1 = SubFrame(None, wx.ID_ANY, "")
    app.SetTopWindow(frame_1)
    frame_1.Show()
    app.MainLoop()
merci en avance