Esempio n. 1
0
    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()
Esempio n. 2
0
    def __init__(self):
        '''
        Main window class.
        It's frameless and transparent.
        '''
        super(Window, self).__init__(None, QtCore.Qt.FramelessWindowHint)
        QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('CleanLooks'))
        QtGui.QApplication.setPalette(
            QtGui.QApplication.style().standardPalette())

        icon_path = os.path.split(
            os.path.abspath(__file__))[0] + '/config/icon.ico'
        self.setWindowIcon(QtGui.QIcon(icon_path))
        self.resize(C['W_WIDTH'], C['W_HEIGHT'])
        self.setMaximumHeight(C['W_MAX_HEIGHT'])
        self.setStyleSheet(D['STYLE_MAIN'])
        self.setWindowTitle('Scrambled Egg %s :: Live Crypt' % __version__)
        self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
        self.setWindowOpacity(0.9)
        self.setAcceptDrops(True)

        self.SE = ScrambledEgg()

        self.centralWidget = ContainerWidget(self)  # Central Widget.
        self.setCentralWidget(self.centralWidget)
        self.container = QtGui.QWidget(self.centralWidget)  # Container Widget.
        self.container.setObjectName('Container')
        self.container.setStyleSheet(D['STYLE_CONTAINER'])

        self.textBar = QtGui.QLabel(self)  # Top text bar.
        self.layout = QtGui.QGridLayout(self.centralWidget)  # Main Layout.
        self.centralWidget.setLayout(self.layout)

        self.leftText = QtGui.QTextEdit(
            '', self.centralWidget)  # To write clean text.
        self.rightText = QtGui.QPlainTextEdit(
            '', self.centralWidget)  # To view encrypted text.

        self.buttonCryptMode = QtGui.QPushButton(self.centralWidget)
        self.buttonDecryptMode = QtGui.QPushButton(self.centralWidget)
        self.buttonBrowseRSAL = QtGui.QPushButton('Browse', self.centralWidget)
        self.buttonBrowseRSAR = QtGui.QPushButton('Browse', self.centralWidget)

        self.preProcess = QtGui.QComboBox(self.centralWidget)  # Left side.
        self.comboCrypt = QtGui.QComboBox(self.centralWidget)  # Left side.
        self.postProcess = QtGui.QComboBox(self.centralWidget)  # Left side.
        self.linePasswordL = QtGui.QLineEdit(
            self.centralWidget)  # Left password line.
        self.lineRSAPathL = QtGui.QLineEdit(
            self.centralWidget)  # Left RSA Path line.
        self.checkPwdL = QtGui.QCheckBox('<- Pwd',
                                         self.centralWidget)  # Left side.
        self.nrLettersL = QtGui.QLabel('', self.centralWidget)  # Left side.
        self.setFormatting = QtGui.QCheckBox('Formatted text',
                                             self.centralWidget)  # Left side.
        self.setTags = QtGui.QCheckBox('No tags',
                                       self.centralWidget)  # Left side.
        self.showHTML = QtGui.QCheckBox('Show HTML',
                                        self.centralWidget)  # Left side.

        self.preDecrypt = QtGui.QComboBox(self.centralWidget)  # Right side.
        self.comboDecrypt = QtGui.QComboBox(self.centralWidget)  # Right side.
        self.postDecrypt = QtGui.QComboBox(self.centralWidget)  # Right side.
        self.linePasswordR = QtGui.QLineEdit(
            self.centralWidget)  # Right password line.
        self.lineRSAPathR = QtGui.QLineEdit(
            self.centralWidget)  # Right RSA Path line.
        self.checkPwdR = QtGui.QCheckBox('<- Pwd',
                                         self.centralWidget)  # Right side.
        self.nrLettersR = QtGui.QLabel('', self.centralWidget)  # Right side.
        self.loadFile = QtGui.QPushButton('Import',
                                          self.centralWidget)  # Right side.
        self.saveFile = QtGui.QPushButton('Export',
                                          self.centralWidget)  # Right side.
        self.helpButton = QtGui.QPushButton('Help !',
                                            self.centralWidget)  # Right side.

        self.minButton = QtGui.QPushButton(D['MIN_BTN_TXT'],
                                           self.centralWidget)
        self.closeButton = QtGui.QPushButton(D['CLOSE_BTN_TXT'],
                                             self.centralWidget)
        self.micLayout = QtGui.QHBoxLayout()
        self.micLayout.addWidget(self.minButton)
        self.micLayout.addWidget(self.closeButton)

        # Row, Col, rowSpan, colSpan
        self.layout.addWidget(self.container, 0, 1, 43, 12)
        self.layout.addWidget(self.textBar, 1, 1, 3, 8)
        self.layout.addLayout(self.micLayout, 1, 10 + C['MIC_BTNS_POS'], 1,
                              C['MIC_BTNS_SPAN'])
        self.layout.addItem(QtGui.QSpacerItem(1, 8), 3, 1, 1, 1)

        self.layout.addWidget(self.buttonCryptMode, 4, 2, 1, 5)
        self.layout.addWidget(self.buttonDecryptMode, 4, 7, 1, 5)

        self.layout.addWidget(self.preProcess, 5, 2, 1, 1)
        self.layout.addWidget(self.comboCrypt, 5, 3, 1, 1)
        self.layout.addWidget(self.postProcess, 5, 4, 1, 1)
        self.layout.addWidget(self.preDecrypt, 5, 7, 1, 1)
        self.layout.addWidget(self.comboDecrypt, 5, 8, 1, 1)
        self.layout.addWidget(self.postDecrypt, 5, 9, 1, 1)

        self.layout.addWidget(self.linePasswordL, 6, 2, 1, 4)
        self.layout.addWidget(self.linePasswordR, 6, 7, 1, 4)
        self.layout.addWidget(self.checkPwdL, 6, 6, 1, 1)
        self.layout.addWidget(self.checkPwdR, 6, 11, 1, 1)

        self.layout.addWidget(self.lineRSAPathL, 7, 2, 1, 4)
        self.layout.addWidget(self.lineRSAPathR, 7, 7, 1, 4)
        self.layout.addWidget(self.buttonBrowseRSAL, 7, 6, 1, 1)
        self.layout.addWidget(self.buttonBrowseRSAR, 7, 11, 1, 1)

        self.layout.addWidget(self.leftText, 8, 2, 32, 5)
        self.layout.addWidget(self.rightText, 8, 7, 32, 5)

        self.layout.addWidget(self.setFormatting, 40, 2, 1, 1)
        self.layout.addWidget(self.setTags, 40, 3, 1, 1)
        self.layout.addWidget(self.showHTML, 40, 4, 1, 1)
        self.layout.addWidget(self.loadFile, 40, 7, 1, 1)
        self.layout.addWidget(self.saveFile, 40, 8, 1, 1)
        self.layout.addWidget(self.helpButton, 40, 9, 1, 1)

        self.layout.addWidget(self.nrLettersL, 40, 6, 1, 1)
        self.layout.addWidget(self.nrLettersR, 40, 11, 1, 1)

        self.__setup()  # Prepair all components!
        self.__connect()  # Connect all components!