def __init__(self, keys, algorithms, parent=None, title="Select a Key", HandleNewKey=NullCoroutine): super().__init__(parent, title=title, size=(550, 250), style=wx.RESIZE_BORDER | wx.DEFAULT_DIALOG_STYLE) self.algorithms = algorithms self.HandleNewKey = HandleNewKey self.key_label = wx.StaticText(self, label="Key:") self.combo = KeySelectCombo(keys, parent=self) self.checkbox_default = wx.CheckBox(self, label="Save as Default") self.error_message = wx.StaticText(self, label="") self.error_message.SetForegroundColour(Colour("Red")) self.submit = wx.Button(self, label="Submit") self.submit.SetId(wx.ID_OK) self.submit.SetFocus() self.cancel = wx.Button(self, label="Cancel") self.cancel.SetId(wx.ID_CANCEL) self.newkey = wx.Button(self, label="Create New") vbox = wx.BoxSizer(wx.VERTICAL) vbox.AddSpacer(40) vbox.Add(self.key_label, 0, wx.EXPAND | wx.RIGHT | wx.LEFT, border=20) hbox1 = wx.BoxSizer(wx.HORIZONTAL) hbox1.Add(self.combo, 1, wx.EXPAND) hbox1.Add(self.newkey, 0) vbox.Add(hbox1, 0, wx.RIGHT | wx.LEFT | wx.EXPAND, border=20) vbox.AddSpacer(20) vbox.Add(self.checkbox_default, 0, wx.RIGHT | wx.LEFT | wx.ALIGN_RIGHT, border=20) vbox.Add(self.error_message, 0, wx.RIGHT | wx.LEFT, border=20) vbox.AddStretchSpacer(1) button_sizer = wx.BoxSizer(wx.HORIZONTAL) #button_sizer = wx.StdDialogButtonSizer() button_sizer.Add(self.cancel) button_sizer.Add(self.submit) vbox.Add(button_sizer, 1, wx.ALIGN_RIGHT | wx.RIGHT | wx.LEFT | wx.BOTTOM, border=20) self.SetSizer(vbox) self.Layout() AsyncBind(wx.EVT_BUTTON, self.OnNewKey, self.newkey)
def __init__(self, parent=None, title="2FA Required", Handle2FACoroutine=NullCoroutine): super(Dialog2FA, self).__init__(parent, title=title, size=(350, 250), style=wx.RESIZE_BORDER|wx.DEFAULT_DIALOG_STYLE) self.Handle2FACoroutine = Handle2FACoroutine self.panel = Panel2FA(self) self.error_message = wx.StaticText(self, label="") self.error_message.SetForegroundColour(Colour("Red")) self.submit = wx.Button(self, label="Submit") AsyncBind(wx.EVT_BUTTON, self.OnSubmit, self.submit) #self.submit.SetId(wx.ID_OK) vbox = wx.BoxSizer(wx.VERTICAL) vbox.AddSpacer(40) vbox.Add(self.panel, 1, wx.EXPAND|wx.RIGHT|wx.LEFT, border=20 ) vbox.Add(self.error_message, 0, wx.RIGHT|wx.LEFT, border=20 ) vbox.AddStretchSpacer(1) vbox.Add(self.submit, 0, wx.ALIGN_RIGHT|wx.RIGHT|wx.LEFT|wx.BOTTOM, border=20) self.SetSizer(vbox) self.Layout()
def __init__(self, parent=None, title="Crypt Client", HandleLogin=NullCoroutine, HandleCreateAccountStep1=NullCoroutine, HandleCreateAccountStep2=NullCoroutine): super(LoginDialog, self).__init__(parent, title=title, size=(380, 450), style=wx.RESIZE_BORDER|wx.DEFAULT_DIALOG_STYLE) self.title = wx.StaticText(self) font = self.title.GetFont() font.SetPointSize(16) self.title.SetFont(font) self.login_panel = LoginPanel(self) self.error_message = wx.StaticText(self, label="") self.error_message.SetForegroundColour(Colour("Red")) self.create_account_panel_step1 = CreateAccountPanelStep1(self) self.create_account_panel_step2 = CreateAccountPanelStep2(self) self.link = HyperlinkCtrl(self, label="Go to Login") self.SetState(LoginState.Login) #vbox.Add(self.login, 0, wx.ALIGN_RIGHT) #self.create_acount_link = HyperlinkCtrl(self, label="Create new account") self.submit = wx.Button(self, label="Submit") vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(self.title, 0, wx.TOP|wx.RIGHT|wx.LEFT, border=20 ) vbox.AddSpacer(10) vbox.Add(self.create_account_panel_step1, 3, wx.EXPAND|wx.RIGHT|wx.LEFT, border=20 ) vbox.Add(self.create_account_panel_step2, 3, wx.EXPAND|wx.RIGHT|wx.LEFT, border=20 ) vbox.Add(self.login_panel, 3, wx.EXPAND|wx.RIGHT|wx.LEFT, border=20 ) vbox.Add(self.error_message, 0, wx.RIGHT|wx.LEFT, border=20 ) vbox.AddStretchSpacer(0) vbox.Add(self.link, 0, wx.EXPAND|wx.RIGHT|wx.LEFT, border=20) vbox.Add(self.submit, 0, wx.ALIGN_RIGHT|wx.RIGHT|wx.LEFT|wx.BOTTOM, border=20) self.SetSizer(vbox) self.link.Bind(EVT_HYPERLINK, lambda event: self.OnLink()) #self.create_account_panel_step1.login_link.Bind(EVT_HYPERLINK, lambda event: self.SetState(LoginState.Login)) #self.create_account_panel.create_account.Bind(wx.EVT_BUTTON, self.SubmitCreateAccount) AsyncBind(wx.EVT_BUTTON, self.Submit, self.submit) #AsyncBind(wx.EVT_BUTTON, self.SubmitLogin, self.login_panel.login) self.HandleCreateAccountStep1 = HandleCreateAccountStep1 self.HandleCreateAccountStep2 = HandleCreateAccountStep2 self.HandleLogin = HandleLogin self.Layout()
def ShowSuccess(self, message): self.error_message.SetForegroundColour(Colour(0,128,0)) self.error_message.SetLabel(message)
def ShowError(self, message): self.error_message.SetForegroundColour(Colour("Red")) self.error_message.SetLabel(message)
def __init__(self, parent=None, title="New Key", algorithms=[], HandleNewKey=NullCoroutine): super().__init__(parent, title=title, size=(550, 300), style=wx.RESIZE_BORDER | wx.DEFAULT_DIALOG_STYLE) self.HandleNewKey = HandleNewKey self.key_label_label = wx.StaticText(self, label="Label:") self.key_label = wx.TextCtrl(self) self.algorithm_label = wx.StaticText(self, label="Algorithm:") self.algorithm = wx.ComboBox(self, choices=algorithms, style=wx.CB_READONLY) self.security_label = wx.StaticText(self, label="Security:") self.security = wx.ComboBox(self, choices=[str(i) for i in range(1, 5)], style=wx.CB_READONLY) self.gauge = wx.Gauge(self) self.gauge.Hide() self.error_message = wx.StaticText(self, label="") self.error_message.SetForegroundColour(Colour("Red")) self.submit = wx.Button(self, label="Submit") self.submit.SetId(wx.ID_OK) self.submit.SetFocus() AsyncBind(wx.EVT_BUTTON, self.OnSubmit, self.submit) self.cancel = wx.Button(self, label="Cancel") self.cancel.SetId(wx.ID_CANCEL) # spacers vbox = wx.BoxSizer(wx.VERTICAL) vbox.AddSpacer(40) vbox.Add(self.key_label_label, 0, wx.EXPAND | wx.RIGHT | wx.LEFT, border=20) vbox.Add(self.key_label, 0, wx.EXPAND | wx.RIGHT | wx.LEFT, border=20) vbox.Add(self.algorithm_label, 0, wx.EXPAND | wx.RIGHT | wx.LEFT, border=20) vbox.Add(self.algorithm, 0, wx.EXPAND | wx.RIGHT | wx.LEFT, border=20) vbox.Add(self.security_label, 0, wx.EXPAND | wx.RIGHT | wx.LEFT, border=20) vbox.Add(self.security, 0, wx.EXPAND | wx.RIGHT | wx.LEFT, border=20) vbox.AddSpacer(20) vbox.Add(self.gauge, 0, wx.EXPAND | wx.RIGHT | wx.LEFT, border=20) vbox.Add(self.error_message, 0, wx.RIGHT | wx.LEFT, border=20) vbox.AddStretchSpacer(1) button_sizer = wx.BoxSizer(wx.HORIZONTAL) button_sizer.Add(self.cancel) button_sizer.Add(self.submit) vbox.Add(button_sizer, 1, wx.ALIGN_RIGHT | wx.RIGHT | wx.LEFT | wx.BOTTOM, border=20) self.SetSizer(vbox) self.Layout()