Esempio n. 1
0
    def __init__(self, parent):
        self.parent = parent
        super(LoginPanel, self).__init__(parent=self.parent)
        # panel sizer
        self.sizer = wx.BoxSizer(wx.HORIZONTAL)

        # generation of the left side of the frame
        self.panel_l = wx.Panel(parent)
        self.profiles = profiledb.list_all()
        self.profile_listbox = wx.ListBox(self.panel_l, choices=self.profiles, style=wx.LB_SINGLE)
        self.profile_listbox.SetSelection(0)
        btn_ok = wx.Button(self.panel_l, label='Ok')
        btn_new = wx.Button(self.panel_l, label='Create new profile')
        self.sizer_l = wx.BoxSizer(wx.VERTICAL)
        self.sizer_l.AddMany([(self.profile_listbox, 1, wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5),
                              ((-1, 100)),
                              (btn_ok, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5),
                              ((-1, 15)),
                              (btn_new, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5),
                              ((-1, 20))])
        self.panel_l.SetSizer(self.sizer_l)
        self.panel_l.SetBackgroundColour(wx.Colour(48, 94, 232, 150))
        # self.panel_l.Fit()

        # generation of the right side of the frame
        self.panel_r = wx.Panel(parent)
        self.sizer_r = wx.BoxSizer(wx.VERTICAL)
        self.player_info = wx.StaticText(self.panel_r, label="")
        self.player_info.SetLabel(get_stats(self.panel_r,
                                            self.profiles[self.profile_listbox.GetSelection()]))
        btn_del = wx.Button(self.panel_r, label='Delete profile')
        self.sizer_r.AddMany([(self.player_info, 1, wx.ALL | wx.EXPAND, 5),
                              ((-1, 100)),
                              (btn_del, 0, wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.ALIGN_CENTER_HORIZONTAL, 5),
                              ((-1, 20))])
        self.panel_r.SetSizer(self.sizer_r)
        self.panel_r.SetBackgroundColour(wx.Colour(255, 102, 0, 200))
        # self.panel_r.Fit()

        # event handling
        self.profile_listbox.Bind(wx.EVT_LISTBOX, self.change_text)
        btn_ok.Bind(wx.EVT_BUTTON, self.on_ok)
        btn_new.Bind(wx.EVT_BUTTON, self.new_profile)
        btn_del.Bind(wx.EVT_BUTTON, self.delete_profile)

        # adding to frame sizer
        self.sizer.AddMany([(self.panel_l, 1, wx.EXPAND | wx.ALL, 2),
                            ((-1, 10)),
                            (self.panel_r, 1, wx.EXPAND | wx.ALL, 2)])
        self.SetSizer(self.sizer)
Esempio n. 2
0
 def change_text(self, evt):
     self.player_info.SetLabel(
         get_stats(self.panel_r, profiledb.list_all()[self.profile_listbox.GetSelection()]))