def __setup(self): ''' Setup all components. ''' # # Toogle buttons. self.buttonCryptMode.setCheckable(True) self.buttonCryptMode.setChecked(True) self.buttonCryptMode.setToolTip('Switch to Encryption mode') self.buttonCryptMode.setStyleSheet(D['STYLE_BUTTON']) self.buttonDecryptMode.setCheckable(True) self.buttonDecryptMode.setToolTip('Switch to Decryption mode') self.buttonDecryptMode.setStyleSheet(D['STYLE_BUTTON']) self.helpButton.setStyleSheet(D['STYLE_HELP_BUTTON']) self.minButton.setMaximumWidth(25) self.minButton.setMaximumHeight(25) self.minButton.setStyleSheet(D['STYLE_MIN_BUTTON']) self.closeButton.setMaximumWidth(25) self.closeButton.setMaximumHeight(25) self.closeButton.setStyleSheet(D['STYLE_CLOSE_BUTTON']) # Some styles. self.loadFile.setStyleSheet(D['STYLE_BUTTON']) self.saveFile.setStyleSheet(D['STYLE_BUTTON']) self.leftText.setStyleSheet(D['STYLE_L_TEXTEDIT']) self.rightText.setStyleSheet(D['STYLE_R_TEXTEDIT']) # Password fields. self.linePasswordL.setEchoMode(QtGui.QLineEdit.Password) self.linePasswordL.setToolTip('Password used for encrypting the text') self.linePasswordL.setMaxLength(99) self.linePasswordL.setStyleSheet(D['STYLE_LINEEDIT']) self.checkPwdL.setTristate(False) self.checkPwdL.setStyleSheet(D['STYLE_CHECKBOX']) self.linePasswordR.setEchoMode(QtGui.QLineEdit.Password) self.linePasswordR.setToolTip('Password used for decrypting the text') self.linePasswordR.setMaxLength(99) self.linePasswordR.setDisabled(True) self.linePasswordR.setStyleSheet(D['STYLE_LINEEDIT']) self.checkPwdR.setTristate(False) self.checkPwdR.setStyleSheet(D['STYLE_CHECKBOX']) # RSA Path. self.lineRSAPathL.setStyleSheet(D['STYLE_LINEEDIT']) self.lineRSAPathL.setToolTip('RSA Encryption requires both a password and the path to a public/ private RSA key') self.lineRSAPathL.hide() self.lineRSAPathR.setStyleSheet(D['STYLE_LINEEDIT']) self.lineRSAPathR.setToolTip('RSA Decryption requires both a password and the path to a public/ private RSA key') self.lineRSAPathR.hide() self.lineRSAPathR.setDisabled(True) self.buttonBrowseRSAL.setStyleSheet(D['STYLE_BUTTON']) self.buttonBrowseRSAL.hide() self.buttonBrowseRSAL.setMaximumWidth(60) self.buttonBrowseRSAR.setStyleSheet(D['STYLE_BUTTON']) self.buttonBrowseRSAR.hide() self.buttonBrowseRSAR.setMaximumWidth(60) self.buttonBrowseRSAR.setDisabled(True) # Formatted text. self.setFormatting.setTristate(False) self.setFormatting.setChecked(True) self.setFormatting.setToolTip('Encrypt this text as HTML') self.setFormatting.setStyleSheet(D['STYLE_CHECKBOX']) self.setTags.setTristate(False) self.setTags.setToolTip('Strip pre/enc/post tags') self.setTags.setStyleSheet(D['STYLE_CHECKBOX']) self.showHTML.setTristate(False) self.showHTML.setToolTip('Toogle view HTML source behind the formatted text') self.showHTML.setStyleSheet(D['STYLE_CHECKBOX']) # All combo boxes. MIN = 120 self.preProcess.setMinimumWidth(MIN) self.preProcess.setStyleSheet(D['STYLE_COMBOBOX']) self.comboCrypt.setMinimumWidth(MIN) self.comboCrypt.setStyleSheet(D['STYLE_COMBOBOX']) self.postProcess.setMinimumWidth(MIN) self.postProcess.setStyleSheet(D['STYLE_COMBOBOX']) self.preDecrypt.setMinimumWidth(MIN) self.preDecrypt.setStyleSheet(D['STYLE_COMBOBOX']) self.comboDecrypt.setMinimumWidth(MIN) self.comboDecrypt.setStyleSheet(D['STYLE_COMBOBOX']) self.postDecrypt.setMinimumWidth(MIN) self.postDecrypt.setStyleSheet(D['STYLE_COMBOBOX']) # Pre combo-boxes. self.preProcess.setToolTip('Select pre-process') self.postDecrypt.setToolTip('Select post-decrypt') for scramble in SCRAMBLE: self.preProcess.addItem(scramble, scramble) self.postDecrypt.addItem(scramble, scramble) # Encryption/ decryption combo-boxes. self.comboCrypt.setToolTip('Select encryption algorithm; it will use the provided password') self.comboDecrypt.setToolTip('Select encryption algorithm; it will use the provided password') for enc in ENC.keys(): self.comboCrypt.addItem(enc, enc) self.comboDecrypt.addItem(enc, enc) # Post combo-boxes. self.postProcess.setToolTip('Select post-process') self.preDecrypt.setToolTip('Select pre-decrypt') for encode in ENCODE: self.postProcess.addItem(encode, encode) self.preDecrypt.addItem(encode, encode)
def __init__(self): wx.Frame.__init__(self, parent=None, title='Scrambled Egg GUI', size=(800, 600)) self.SetMinSize((800, 300)) panel = wx.Panel(self) hbox = wx.BoxSizer(wx.HORIZONTAL) self.statusBar = self.CreateStatusBar() self.statusBar.SetStatusText('Ready') self.SE = ScrambledEgg() # Left vertical layout leftbag = wx.BoxSizer(wx.VERTICAL) # Combo bag left cbagl = wx.BoxSizer(wx.HORIZONTAL) self.preProcess = wx.ComboBox(panel, -1, SCRAMBLE[0], size=(130, -1), choices=SCRAMBLE, style=wx.CB_READONLY) # Left side self.comboCrypt = wx.ComboBox(panel, -1, ENC.keys()[0], size=(130, -1), choices=ENC.keys(), style=wx.CB_READONLY) # Left side self.postProcess = wx.ComboBox(panel, -1, ENCODE[0], size=(130, -1), choices=ENCODE, style=wx.CB_READONLY) # Left side # cbagl.Add(self.preProcess) cbagl.Add(self.comboCrypt) cbagl.Add(self.postProcess) self.buttonCryptMode = wx.ToggleButton(panel, label='Encryption Mode is Enabled') self.buttonCryptMode.SetValue(True) # Password bag left pbagl = wx.BoxSizer(wx.HORIZONTAL) self.linePasswordL = wx.TextCtrl(panel, -1, style=wx.TE_PASSWORD) # Left password line self.checkPwdL = wx.CheckBox(panel, -1, size=(85, -1), label='<- Pwd') # Left side # pbagl.Add(self.linePasswordL, proportion=5, flag=wx.EXPAND) pbagl.Add(self.checkPwdL, proportion=1, flag=wx.ALIGN_CENTER_VERTICAL) # Left check boxes bbagl = wx.BoxSizer(wx.HORIZONTAL) self.setTags = wx.CheckBox(panel, -1, size=(105, 25), label='Tags') # Left side self.setTags.SetValue(True) self.nrLettersL = wx.StaticText(panel, -1, '') # bbagl.Add(self.setTags, proportion=5, flag=wx.EXPAND) bbagl.Add(self.nrLettersL, proportion=1, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER_HORIZONTAL) self.leftText = wx.TextCtrl(panel, style=wx.TE_MULTILINE) # Plain text # Append in left vertical layout leftbag.Add(self.buttonCryptMode, border=3, flag=wx.EXPAND|wx.RIGHT|wx.BOTTOM) leftbag.Add(cbagl, border=3, flag=wx.EXPAND|wx.RIGHT|wx.BOTTOM) leftbag.Add(pbagl, border=3, flag=wx.EXPAND|wx.RIGHT|wx.BOTTOM) leftbag.Add(self.leftText, border=3, proportion=10, flag=wx.EXPAND|wx.RIGHT|wx.BOTTOM) leftbag.Add(bbagl, border=3, flag=wx.EXPAND|wx.RIGHT|wx.BOTTOM) # Right vertical layout rightbag = wx.BoxSizer(wx.VERTICAL) # Combo bag right cbagr = wx.BoxSizer(wx.HORIZONTAL) self.preDecrypt = wx.ComboBox(panel, -1, SCRAMBLE[0], size=(130, -1), choices=SCRAMBLE, style=wx.CB_READONLY) # Right side self.comboDecrypt = wx.ComboBox(panel, -1, ENC.keys()[0], size=(130, -1), choices=ENC.keys(), style=wx.CB_READONLY) # Right side self.postDecrypt = wx.ComboBox(panel, -1, ENCODE[0], size=(130, -1), choices=ENCODE, style=wx.CB_READONLY) # Right side cbagr.Add(self.preDecrypt) cbagr.Add(self.comboDecrypt) cbagr.Add(self.postDecrypt) self.buttonDecryptMode = wx.ToggleButton(panel, label='Decryption Mode') self.buttonDecryptMode.SetValue(False) # Password bag right pbagr = wx.BoxSizer(wx.HORIZONTAL) self.linePasswordR = wx.TextCtrl(panel, -1, style=wx.TE_PASSWORD) # Right password line self.checkPwdR = wx.CheckBox(panel, -1, size=(85, -1), label='<- Pwd') # Right side # pbagr.Add(self.linePasswordR, proportion=5, flag=wx.EXPAND) pbagr.Add(self.checkPwdR, proportion=1, flag=wx.ALIGN_CENTER_VERTICAL) # Right buttons bbagr = wx.BoxSizer(wx.HORIZONTAL) self.loadFile = wx.Button(panel, size=(105, 25), label='Import') # Right side self.saveFile = wx.Button(panel, size=(105, 25), label='Export') # Right side self.helpButton = wx.Button(panel, size=(105, 25), label='Help !') # Right side self.nrLettersR = wx.StaticText(panel, -1, '') # bbagr.Add(self.loadFile) bbagr.Add(self.saveFile) bbagr.Add(self.helpButton) bbagr.Add(self.nrLettersR, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER_HORIZONTAL) self.rightText = wx.TextCtrl(panel, style=wx.TE_MULTILINE) # Encrypted text # Append in right vertical layout rightbag.Add(self.buttonDecryptMode, border=3, flag=wx.EXPAND|wx.RIGHT|wx.BOTTOM) rightbag.Add(cbagr, border=3, flag=wx.EXPAND|wx.RIGHT|wx.BOTTOM) rightbag.Add(pbagr, border=3, flag=wx.EXPAND|wx.RIGHT|wx.BOTTOM) rightbag.Add(self.rightText, border=3, proportion=10, flag=wx.EXPAND|wx.RIGHT|wx.BOTTOM) rightbag.Add(bbagr, border=3, flag=wx.EXPAND|wx.RIGHT|wx.BOTTOM) hbox.Add(leftbag, proportion=1, flag=wx.EXPAND|wx.ALL, border=5) hbox.Add(rightbag, proportion=1, flag=wx.EXPAND|wx.ALL, border=5) panel.SetSizer(hbox) self._bind_events() self.Center() self.Show(True) self.leftText.SetFocus()
def __setup(self): ''' Setup all components. ''' # # Toogle buttons. self.buttonCryptMode.setCheckable(True) self.buttonCryptMode.setChecked(True) self.buttonCryptMode.setToolTip('Switch to Encryption mode') self.buttonCryptMode.setStyleSheet(D['STYLE_BUTTON']) self.buttonDecryptMode.setCheckable(True) self.buttonDecryptMode.setToolTip('Switch to Decryption mode') self.buttonDecryptMode.setStyleSheet(D['STYLE_BUTTON']) self.helpButton.setStyleSheet(D['STYLE_HELP_BUTTON']) self.minButton.setMaximumWidth(25) self.minButton.setMaximumHeight(25) self.minButton.setStyleSheet(D['STYLE_MIN_BUTTON']) self.closeButton.setMaximumWidth(25) self.closeButton.setMaximumHeight(25) self.closeButton.setStyleSheet(D['STYLE_CLOSE_BUTTON']) # Some styles. self.loadFile.setStyleSheet(D['STYLE_BUTTON']) self.saveFile.setStyleSheet(D['STYLE_BUTTON']) self.leftText.setStyleSheet(D['STYLE_L_TEXTEDIT']) self.rightText.setStyleSheet(D['STYLE_R_TEXTEDIT']) # Password fields. self.linePasswordL.setEchoMode(QtGui.QLineEdit.Password) self.linePasswordL.setToolTip('Password used for encrypting the text') self.linePasswordL.setMaxLength(99) self.linePasswordL.setStyleSheet(D['STYLE_LINEEDIT']) self.checkPwdL.setTristate(False) self.checkPwdL.setStyleSheet(D['STYLE_CHECKBOX']) self.linePasswordR.setEchoMode(QtGui.QLineEdit.Password) self.linePasswordR.setToolTip('Password used for decrypting the text') self.linePasswordR.setMaxLength(99) self.linePasswordR.setDisabled(True) self.linePasswordR.setStyleSheet(D['STYLE_LINEEDIT']) self.checkPwdR.setTristate(False) self.checkPwdR.setStyleSheet(D['STYLE_CHECKBOX']) # RSA Path. self.lineRSAPathL.setStyleSheet(D['STYLE_LINEEDIT']) self.lineRSAPathL.setToolTip( 'RSA Encryption requires both a password and the path to a public/ private RSA key' ) self.lineRSAPathL.hide() self.lineRSAPathR.setStyleSheet(D['STYLE_LINEEDIT']) self.lineRSAPathR.setToolTip( 'RSA Decryption requires both a password and the path to a public/ private RSA key' ) self.lineRSAPathR.hide() self.lineRSAPathR.setDisabled(True) self.buttonBrowseRSAL.setStyleSheet(D['STYLE_BUTTON']) self.buttonBrowseRSAL.hide() self.buttonBrowseRSAL.setMaximumWidth(60) self.buttonBrowseRSAR.setStyleSheet(D['STYLE_BUTTON']) self.buttonBrowseRSAR.hide() self.buttonBrowseRSAR.setMaximumWidth(60) self.buttonBrowseRSAR.setDisabled(True) # Formatted text. self.setFormatting.setTristate(False) self.setFormatting.setChecked(True) self.setFormatting.setToolTip('Encrypt this text as HTML') self.setFormatting.setStyleSheet(D['STYLE_CHECKBOX']) self.setTags.setTristate(False) self.setTags.setToolTip('Strip pre/enc/post tags') self.setTags.setStyleSheet(D['STYLE_CHECKBOX']) self.showHTML.setTristate(False) self.showHTML.setToolTip( 'Toogle view HTML source behind the formatted text') self.showHTML.setStyleSheet(D['STYLE_CHECKBOX']) # All combo boxes. MIN = 120 self.preProcess.setMinimumWidth(MIN) self.preProcess.setStyleSheet(D['STYLE_COMBOBOX']) self.comboCrypt.setMinimumWidth(MIN) self.comboCrypt.setStyleSheet(D['STYLE_COMBOBOX']) self.postProcess.setMinimumWidth(MIN) self.postProcess.setStyleSheet(D['STYLE_COMBOBOX']) self.preDecrypt.setMinimumWidth(MIN) self.preDecrypt.setStyleSheet(D['STYLE_COMBOBOX']) self.comboDecrypt.setMinimumWidth(MIN) self.comboDecrypt.setStyleSheet(D['STYLE_COMBOBOX']) self.postDecrypt.setMinimumWidth(MIN) self.postDecrypt.setStyleSheet(D['STYLE_COMBOBOX']) # Pre combo-boxes. self.preProcess.setToolTip('Select pre-process') self.postDecrypt.setToolTip('Select post-decrypt') for scramble in SCRAMBLE: self.preProcess.addItem(scramble, scramble) self.postDecrypt.addItem(scramble, scramble) # Encryption/ decryption combo-boxes. self.comboCrypt.setToolTip( 'Select encryption algorithm; it will use the provided password') self.comboDecrypt.setToolTip( 'Select encryption algorithm; it will use the provided password') for enc in ENC.keys(): self.comboCrypt.addItem(enc, enc) self.comboDecrypt.addItem(enc, enc) # Post combo-boxes. self.postProcess.setToolTip('Select post-process') self.preDecrypt.setToolTip('Select pre-decrypt') for encode in ENCODE: self.postProcess.addItem(encode, encode) self.preDecrypt.addItem(encode, encode)