Пример #1
0
    def login(self):
        try:
            # Check for previous token
            with open('.token', 'r') as f:
                self.facebook_token = f.read()
        except IOError:
            tokget = False
            while not tokget:
                # Ask for username and password
                dlg = LoginDialog(parent=self.frame)
                if dlg.ShowModal() == wx.ID_OK:
                    # do something here
                    username = dlg.result_user
                    password = dlg.result_password
                    dlg.Destroy()
                else:
                    dlg.Destroy()
                    print('Exiting')
                    os._exit(0)
                try:
                    self.facebook_token = auth.get_fb_access_token(
                        username, password)
                    if type(self.facebook_token) != dict:
                        tokget = True
                    else:
                        print(self.facebook_token)
                except Exception as e:
                    print(f'Login failed: {e.__class__.__name__}: {e}')

            # Write token to file to keep user logged in
            with open('.token', 'w+') as f:
                f.write(self.facebook_token)
Пример #2
0
 def getAccount(self):
     loginDialog=LoginDialog(self)
     if loginDialog.exec_():
         user,pwd=loginDialog.getRetValue()
         return user,pwd
     else:
         logging.info("Exit....")
         sys.exit(0)
Пример #3
0
 def On_ShowSetting(self):
     dlg = LoginDialog(self)
     if not dlg.exec_():
         return 
     self.isAutoDetect = False
     self.tabSetting.setCurrentIndex(1)
     self.pbtabDryrun.setStyleSheet('''background-color:  rgb(255, 255, 255);color: rgb(0, 0, 0);''')
     self.pbtabSetting.setStyleSheet('''background-color:  rgb(255, 255, 255);color: rgb(0, 255, 0);''')
     self.pbtabProfile.setStyleSheet('''background-color:  rgb(255, 255, 255);color: rgb(0, 0, 0);''')
     self.leStationID.setText(self.config["stationid"] if 'stationid' in self.config else '1')
     self.isProfilestatus = True
     self._saveConfigFile()
Пример #4
0
    def handle_operator(self, card):
        print 'operator', card
        if not self.disconnect_from_signal(self.executor.new_operator, self.handle_operator):
            return

        if self.session is None:
            login_dialog = LoginDialog(card, parent=self)
            if login_dialog.exec_() == QDialog.Accepted:
                self.executor.begin_session(card)
        elif self.session == card.sn or card.type == Card.ADMIN:
            login_dialog = LogoffDialog(card, self.executor)
            if login_dialog.exec_() == QDialog.Accepted:
                self.executor.end_session()
        self.executor.new_operator.connect(self.handle_operator)
Пример #5
0
    def __init__(self):
        super().__init__()
        uic.loadUi("UI/MainUI.ui", self)
        self.titlebar_layout.addWidget(TitleBar(self))

        self.current_user['uid'] = platform.node()

        self.messages = Messages(self)
        
        #######################################     LOG IN      ###########################################
        self.login = LoginDialog()
        self.login.buttonBox.accepted.connect(self.setupApp)
        self.login.buttonBox.rejected.connect(qApp.quit)


        #######################################     SERVER      ###########################################
        # self.thread_server = QThread()
        # self.server = Server()
        # self.server.moveToThread(self.thread_server)
        # self.thread_server.started.connect(self.server.run)
        # self.server.new_message.connect(self.messages.getMsg)
        # self.thread_server.start()

        
        #######################################     ONLINE FINDER      ###########################################
        self.online_dialog = OnlineDialog(self)
        self.onlineusers_button.clicked.connect(self.online_dialog.show)
        self.online_dialog.open_chat.connect(self.messages.fillPaperList)
Пример #6
0
def main():
	app = QApplication(sys.argv)
	login = LoginDialog()
	# test = 1
	# while True:
	login.exec_()
		if login.login_success:
			mainwindow = MainWindow(login)
			mainwindow.show()
			login = LoginDialog(mainwindow)
			login.exec_()
Пример #7
0
        def __init__(self):
                QMainWindow.__init__(self)

                self.setupUi(self)

                self.has_login = False

                self.login_dialog = LoginDialog()
                self.login_dialog.setVisible(False) 

                self.feed_dialog = FeedDialog()
                self.feed_dialog.setVisible(False)

                self.content_dialog = ContentDialog()
                self.content_dialog.setVisible(False)

                self.loginAction.triggered.connect(self.login)
                self.subAction.triggered.connect(self.sub)

                self.sourceLIst.clicked.connect(self.get_a_rss_list)
                self.contentList.clicked.connect(self.get_a_rss_content)

                if self.if_has_login():
                        self.show_all_rss()
Пример #8
0
import sys

from PyQt5 import QtWidgets, QtGui

from login import LoginDialog
from main_app import MainWindow


def resource_path(relative_path):
    if hasattr(sys, '_MEIPASS'):
        return os.path.join(sys._MEIPASS, relative_path)
    return os.path.join(os.path.abspath('..'), relative_path)


if __name__ == '__main__':

    app = QtWidgets.QApplication(sys.argv)

    login = LoginDialog()
    login.setWindowIcon(QtGui.QIcon(resource_path('dc1.png')))

    if login.exec_() != QtWidgets.QDialog.Accepted:
        sys.exit(-1)

    window = MainWindow()
    window.setWindowIcon(QtGui.QIcon(resource_path('dc1.png')))
    window.setGeometry(500, 150, 800, 500)
    window.tab(login.credentials())
    window.show()
    sys.exit(app.exec_())
Пример #9
0
class MainWindow(QMainWindow, Ui_MainWindow):
        def __init__(self):
                QMainWindow.__init__(self)

                self.setupUi(self)

                self.has_login = False

                self.login_dialog = LoginDialog()
                self.login_dialog.setVisible(False) 

                self.feed_dialog = FeedDialog()
                self.feed_dialog.setVisible(False)

                self.content_dialog = ContentDialog()
                self.content_dialog.setVisible(False)

                self.loginAction.triggered.connect(self.login)
                self.subAction.triggered.connect(self.sub)

                self.sourceLIst.clicked.connect(self.get_a_rss_list)
                self.contentList.clicked.connect(self.get_a_rss_content)

                if self.if_has_login():
                        self.show_all_rss()

        def if_has_login(self):
                auth_file = shelve.open('auth')
                sid_file = shelve.open('sid')

                if 'auth' in auth_file.keys() and 'sid' in sid_file.keys():
                        self.has_login = True
                        return True
                return False

        @pyqtSlot()
        def login(self):
                self.login_dialog.setVisible(True)
                self.login_dialog.setFocus()
                self.login_dialog.raise_()
                self.login_dialog.show()

                self.has_login = True

                self.show_all_rss()

        @pyqtSlot()
        def sub(self):
                self.feed_dialog.setVisible(True)
                self.feed_dialog.setFocus()
                self.feed_dialog.raise_()
                self.feed_dialog.show()

        @pyqtSlot('QModelIndex')
        def get_a_rss_list(self, model_index):
                if self.has_login and self.feed_data:
                        feed = self.feed_data.get_a_feed_by_index(model_index.row())

                        if feed:
                                self.this_site_feed = ASiteFeed(feed)
                                content_list = self.this_site_feed.list_all_title()
                                content_list_model = QStringListModel()
                                content_list_model.setStringList(content_list)
                                self.contentList.setModel(content_list_model)


        @pyqtSlot('QModelIndex')
        def get_a_rss_content(self, model_index):
                if self.has_login and self.this_site_feed:
                        article = self.this_site_feed.list_article_by_index(model_index.row())
                        html = article['summary']
                        rss = article['link']

                        self.content_dialog.set_html(html)
                        self.content_dialog.set_site(rss)
                        
                        self.content_dialog.setVisible(True)
                        self.content_dialog.raise_()
                        self.content_dialog.show()


        def show_all_rss(self):
                if self.has_login:
                       self.feed_data = FeedData()
                       rss_list = QStringList(self.feed_data.list_all_name())
                       rss_list_model = QStringListModel()
                       rss_list_model.setStringList(rss_list)
                       self.sourceLIst.setModel(rss_list_model)
Пример #10
0
import sys
from PyQt5.QtWidgets import QApplication, QDialog, QMainWindow
from PyQt5.QtGui import QIcon
from login import LoginDialog
import resources
import config
import Tetris

if __name__ == "__main__":
    app = QApplication(sys.argv)
    app.setStyleSheet(config.global_qss)
    login_widget = LoginDialog()
    if login_widget.exec_() == QDialog.Accepted:
        # main_window = QMainWindow()
        # main_window.show()
        # icon = QIcon("/Resources/bg.jpg")
        # # main_window.setWindowIcon(icon)
        tetris = Tetris.Tetris()
    else:
        sys.exit(0)
    sys.exit(app.exec_())