Example #1
0
    def __init__(self):

        QtGui.QMainWindow.__init__(self)
        self.ui = MainWindow.Ui_MainWindow()
        self.ui.setupUi(self)

        self.modified = False
        self.title = self.windowTitle()

        headerLabels = QtCore.QStringList()

        headerLabels.append("Task List")
        headerLabels.append("ID")

        self.ui.treeWidget.setHeaderLabels(headerLabels)
        self.ui.treeWidget.hideColumn(idColumnIndex)
        self.ui.treeWidget.expandAll()

        self.dbHandler = DBHandler()
        self.doConnections()
        self.setActionIcons()

        self.loadDB()
Example #2
0
 tft = TFT()
 chess = tft.get_chess()  # 获取所有的棋子数据 返回一个列表
 equip = tft.get_equip()  # 获取所有的装备数据 返回一个列表
 job = tft.get_job()  # 获取所有的职业数据 返回一个列表
 race = tft.get_race()  # 获取所有的羁绊数据 返回一个列表
 downSJ()  # 下载所有数据
 tft.get_linelist()
 strategyS = []
 #-------------------界面----------------------------------------------------
 # 创建一个QApplication类的实例 可以看做是屏幕 要有屏幕对象,才能开始画窗口
 app=QApplication(sys.argv)
 #自适应DPI缩放
 QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
 #----------mainwindow主窗口------------------
 mainWindow=QMainWindow()#创建一个界面
 ui= MainWindow.Ui_MainWindow()#实例化ui界面对象
 ui.setupUi(mainWindow)#运行里面的代码
 mainWindowInitialize() #初始化赋值
 mainWindow.show() #显示
 # ----------strategyForm攻略选项面板------------------
 straForm = QDialog()  # 创建一个界面
 straFormUI = Form_strategy.Ui_strategyForm()  # 实例化ui界面对象
 straFormUI.setupUi(straForm)  # 运行里面的代码
 straFormInitialize()  # 初始化赋值
 straForm.show()  # 显示
 # ----------hero英雄面板------------------
 heroForm = QDialog()  # 创建一个界面
 heroFormUI = Form_hero.Ui_Form_hero()  # 实例化ui界面对象
 heroFormUI.setupUi(heroForm)  # 运行里面的代码
 heroFormInitialize()  # 初始化赋值
 heroForm.show()  # 显示
Example #3
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.ui = MainWindow.Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.statusbar.hide()

        self.appVersion = "0.1-dev"

        # Setting QTDenter path
        common.set_qtdenter_path()

        # Some variables
        self._hidden = 0
        self.inserted_timeline_dents_ids = []
        self.inserted_mentions_dents_ids = []
        self._new_direct_messages = 0
        self._new_mentions = 0
        self._changed_credentials = False
        self.filters = {}
        # Set default filters
        self._filters_state = ["timeline", "mentions"]

        # Set QTextCodec explicitly. Some disadvantages for rarely used
        # languages, but no problems for others.
        QTextCodec.setCodecForCStrings(QTextCodec.codecForName("UTF-8"))

        # Tray icon
        self.icon = {}
        if not os.path.exists(common.QTDENTER_PATH + "/imgs/qtdenter.png"):
            self.icon["qicon"] = QIcon("/usr/share/pixmaps/qtdenter.png")
            self.icon["path"] = "/usr/share/pixmaps/qtdenter.png"
        else:
            self.icon["qicon"] = QIcon(common.QTDENTER_PATH +
                                       "/imgs/qtdenter.png")
            self.icon["path"] = common.QTDENTER_PATH + "/ui/imgs/qtdenter.png"

        self.trayIcon = QSystemTrayIcon(self.icon["qicon"], self)
        self.trayIcon.setVisible(True)
        self.connect(self.trayIcon,
                     SIGNAL("activated(QSystemTrayIcon::ActivationReason)"),
                     self.check_for_visibility)

        # Tray menu
        menu = QMenu(parent)
        menu.addAction("Show/Hide", self.check_for_visibility)
        menu.addSeparator()
        #menu.addAction("Options", self.show_options)
        #menu.addSeparator()
        menu.addAction("Exit", self.close_from_tray)
        self.trayIcon.setContextMenu(menu)

        # Reading settings and fill settings dict
        self.settings = {}
        if not os.path.exists(os.path.expanduser("~/.config/qtdenter")):
            os.mkdir(os.path.expanduser("~/.config/qtdenter"))
            os.system("touch ~/.config/qtdenter/qsettings.conf")
        if not os.path.exists(
                os.path.expanduser("~/.local/share/qtdenter/avatars/temp")):
            os.makedirs(
                os.path.expanduser("~/.local/share/qtdenter/avatars/temp"))

        if not os.path.exists(cachepath):
            os.mkdir(cachepath)

        try:
            self.qsettings = QSettings("qtdenter", "qsettings")
            self.settings["user"] = self.qsettings.value("user").toString()
            self.settings["password"] = self.qsettings.value(
                "password").toString()
            self.settings["server"] = self.qsettings.value("server").toString()
            self.settings["useSecureConnection"] = self.qsettings.value(
                "useSecureConnection").toString()
            self.settings["isSingle"] = self.qsettings.value(
                "isSingle").toString()
            self.settings["deleteAllFromCacheOnExit"] = self.qsettings.value(
                "deleteAllFromCacheOnExit").toString()
            self.settings["updateInterval"] = self.qsettings.value(
                "updateInterval").toString()
            self.settings["last_dent_id"] = self.qsettings.value(
                "last_dent_id").toString()

        except:
            QMessageBox.critical(self, "denter - No accounts",
                                 "Setup an account in Options!")

        try:
            self.restoreGeometry(
                self.qsettings.value("geometry").toByteArray())
            self.restoreState(self.qsettings.value("state").toByteArray())
        except:
            pass

        try:
            self.settings["remember_last_dent_id"] = self.qsettings.value(
                "remember_last_dent_id").toString()
            self.settings["fetch_on_startup"] = self.qsettings.value(
                "fetch_on_startup").toString()
        except:
            self.settings["remember_last_dent_id"] = "0"
            self.settings["fetch_on_startup"] = "20"

        try:
            self.settings["player"] = self.qsettings.value("player").toString()
            self.settings["player_string"] = self.qsettings.value(
                "player_string").toString()
            self.settings["mpd_port"] = self.qsettings.value(
                "mpd_port").toString()
            self.settings["mpd_host"] = self.qsettings.value(
                "mpd_host").toString()
        except:
            self.settings["player"] = None
            self.settings[
                "player_string"] = "!listening to: $artist - $track #$player"
            self.settings["mpd_port"] = "6600"
            self.settings["mpd_host"] = "localhost"

        try:
            self._filters_state = self.qsettings.value(
                "filters_state").toString()
            self._filters_state = self._filters_state.split(":")
        except:
            print "Failed to restore filters state"

        # Connecting menu actions
        self.ui.action_Options.triggered.connect(self.show_options_dialog)
        self.ui.action_Exit.triggered.connect(self.close_from_menu)
        self.ui.action_About_Denter.triggered.connect(self.show_about)
        self.ui.actionStatistics.triggered.connect(self.show_information)
        self.ui.actionSpam_Music_data.triggered.connect(self.spam_music)
        self.ui.action_Update_all.triggered.connect(self.update_timelines)
        self.ui.action_Mark_all_unread.triggered.connect(self.mark_all_as_read)

        # Connecting some signals
        self.connect(self, SIGNAL("ShowForm()"), self.check_for_visibility)
        self.connect(self, SIGNAL("HideForm()"), self.check_for_visibility)
        self.connect(self, SIGNAL("ShowOptions()"), self.show_options_dialog)
        self.connect(self, SIGNAL("Close()"), self.close_from_tray)

        # New post toolbar icon
        newPostIcon = iconFromTheme("add")
        newPost = QAction(newPostIcon, "New post", self)
        newPost.setShortcut("Ctrl+N")
        newPost.triggered.connect(self.post_status_dialog)

        # New direct message toolbar icon
        new_direct_message_icon = iconFromTheme("no-new-messages")
        new_direct_message = QAction(new_direct_message_icon,
                                     "New direct message", self)
        new_direct_message.setShortcut("Ctrl+D")
        new_direct_message.triggered.connect(self.post_direct_message_dialog)

        # Timelines reload toolbar icon
        reloadTimelinesIcon = iconFromTheme("reload")
        reloadTimelines = QAction(reloadTimelinesIcon, "Reload all timelines",
                                  self)
        reloadTimelines.setShortcut("Ctrl+R")
        reloadTimelines.triggered.connect(self.update_timelines)

        # Mark all read icon
        mark_all_read_icon = iconFromTheme("dialog-ok")
        mark_all_read = QAction(mark_all_read_icon,
                                "Mark all unread dents as read", self)
        mark_all_read.setShortcut("Ctrl+X")
        mark_all_read.triggered.connect(self.mark_all_as_read)

        # Options toolbar icon
        optionsIcon = iconFromTheme("document-properties")
        options = QAction(optionsIcon, "Options", self)
        options.setShortcut("Ctrl+P")
        options.triggered.connect(self.show_options_dialog)

        # Spacer widget, making last updated time label in toolbar to align
        # strictly right
        spacerWidget = QWidget()
        spacerWidget.setSizePolicy(QSizePolicy.Expanding,
                                   QSizePolicy.Preferred)

        # Last updated label
        self.time_updated_action = QLabel()

        # Adding everything to toolbar
        self.ui.toolBar.addAction(newPost)
        self.ui.toolBar.addAction(new_direct_message)
        self.ui.toolBar.addSeparator()
        self.ui.toolBar.addAction(reloadTimelines)
        self.ui.toolBar.addAction(mark_all_read)
        self.ui.toolBar.addSeparator()
        self.ui.toolBar.addAction(options)
        self.ui.toolBar.addWidget(spacerWidget)
        self.ui.toolBar.addWidget(self.time_updated_action)

        # Setting icons
        self.ui.timeline_btn.setIcon(
            QIcon(common.QTDENTER_PATH + "/imgs/timeline.png"))
        self.ui.mentions_btn.setIcon(
            QIcon(common.QTDENTER_PATH + "/imgs/mentions.png"))
        self.ui.directs_btn.setIcon(
            QIcon(common.QTDENTER_PATH + "/imgs/directs.png"))

        # Adding accounts
        self.ui.no_accounts_btn.hide()

        self.btn = QPushButton()
        self.btn.setIcon(QIcon(common.QTDENTER_PATH + "/imgs/identica.png"))
        self.btn.setText(self.settings["server"])

        self.ui.accounts_layout.addWidget(self.btn)

        if "timeline" in self._filters_state:
            self.ui.timeline_btn.setChecked(True)
        if "mentions" in self._filters_state:
            self.ui.mentions_btn.setChecked(True)
        if "directs" in self._filters_state:
            self.ui.directs_btn.setChecked(True)

        self.ui.timeline_btn.clicked.connect(self.change_filters)
        self.ui.mentions_btn.clicked.connect(self.change_filters)
        self.ui.directs_btn.clicked.connect(self.change_filters)

        # Defining list_handler instance
        self.list_handler = list_handler.List_Handler(
            callback=self.lists_callback)

        # Set some options to timeline list
        self.ui.timeline_list.setSortingEnabled(True)
        self.ui.timeline_list.sortByColumn(2, Qt.DescendingOrder)
        for column in range(2, 6):
            self.ui.timeline_list.setColumnHidden(column, True)
        self.ui.timeline_list.setColumnWidth(0, 65)
        self.ui.timeline_list.itemActivated.connect(self.reply_to_dent)
        self.ui.timeline_list.itemSelectionChanged.connect(
            self.change_item_read_state)

        # Defining list_item instance, that generates items for lists
        self.list_item = list_item.list_item()

        # Init notifications
        try:
            pynotify.init(sys.argv[0])
            print "Notifier loaded"
        except:
            print "Failed to init pynotify"

        self.show()

        # Initialize auther and get timelines for first time
        try:
            self.init_connector()
        except:
            print "No auth data specified"

        try:
            self.initialize_button_mappers()

            opts = {
                "count": str(self.settings["fetch_on_startup"]),
                "name": self.settings["user"]
            }

            if self.settings["remember_last_dent_id"] == "1":
                # Getting last dent ID from server
                temp = self.auth.get_home_timeline(opts)
                # Calculation count of dents we will download on startup
                count = temp[0]["id"] - int(self.settings["last_dent_id"])

                if count == 0:
                    count = 20
                else:
                    pass

                opts = {"count": str(count), "name": self.settings["user"]}
        except:
            print "Can't specify options!"

        try:
            home_timeline = self.auth.get_home_timeline(opts)
            self.list_handler.add_data("home", home_timeline,
                                       self.settings["server"])
        except:
            print "Can't get home timeline. WTF?"

        try:
            mentions = self.auth.get_direct_messages(opts)
            self.list_handler.add_data("direct_messages", mentions,
                                       self.settings["server"])
            if self.settings["remember_last_dent_id"] == "1":
                root = self.ui.timeline_list.invisibleRootItem()
                last_item = root.child(0)
                dent_id = last_item.text(2).split(":")[0]
                self.qsettings.setValue("last_dent_id", dent_id)
            self.qsettings.sync()
        except:
            print "Can't get direct messages. WTF?"

        try:
            # Connect buttons
            self.connect_buttons()
        except:
            print "Failed to connect buttons!"

        # Init timer
        self.start_timer(self.settings["updateInterval"])

        # Init "Now Playing"
        self.np = now_playing.Now_Playing(self.settings)

        # Get max characters count from server
        try:
            server_data = self.auth.get_server_config("config")
            self.settings["messageLength"] = server_data["site"]["textlimit"]
        except:
            self.settings["messageLength"] = "140"
    def __init__(self):
        # super()构造器方法返回父级的对象。__init__()方法是构造器的一个方法。
        super().__init__()
        # self.ui = MainUI.Ui_Form()
        self.ui = MainWindowUI.Ui_MainWindow()
        self.ui.setupUi(self)

        # ####################### 相对路径 ######################
        # 初始化label显示的(黑色)背景
        self.bkg_pixmap = QPixmap('./logo_imgs/bkg1.png')
        # 设置主窗口的logo
        self.logo = QIcon('./logo_imgs/fcb_logo.jpg')
        # 设置提示框icon
        self.info_icon = QIcon('./logo_imgs/info_icon.jpg')
        # OpenCV深度学习人脸检测器的路径
        self.detector_path = "./model_face_detection"
        # OpenCV深度学习面部嵌入模型的路径
        self.embedding_model = "./model_facenet/openface_nn4.small2.v1.t7"
        # 训练模型以识别面部的路径
        self.recognizer_path = "./saved_weights/recognizer.pickle"
        # 标签编码器的路径
        self.le_path = "./saved_weights/le.pickle"

        # ###################### 窗口初始化 ######################
        # 设置窗口名称和图标
        self.setWindowTitle('人脸识别考勤系统 v2.0')
        self.setWindowIcon(self.logo)
        # 设置单张图片背景
        self.ui.label_camera.setPixmap(self.bkg_pixmap)
        # label_time显示系统时间
        self.timer = QTimer(self)
        self.timer.timeout.connect(self.show_time_text)
        # 启动时间任务
        self.timer.start()

        # ###################### 摄像头初始化 ######################
        # 初始化摄像头,默认调用第一个摄像头
        # self.url = 0
        # 如果要调用摄像头1,则设置为1,适用于:笔记本外接USB摄像头
        self.url = 1
        self.cap = cv2.VideoCapture()
        # self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, 500)
        # self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 400)
        # self.cap.set(cv2.CAP_PROP_FPS, 20)

        # ###################### 按键的槽函数 ######################
        # 设置摄像头按键连接函数
        self.ui.bt_open_camera.clicked.connect(self.open_camera)
        # 设置开始考勤按键的回调函数
        self.ui.bt_start_check.clicked.connect(self.auto_control)
        # 设置活体检测按键的回调函数
        self.ui.bt_blinks.clicked.connect(self.blinks_thread)
        # 设置“退出系统”按键事件, 按下之后退出主界面
        self.ui.bt_exit.clicked.connect(self.quit_window)
        # 设置信息采集按键连接
        self.ui.bt_gathering.clicked.connect(self.open_info_dialog)
        # 设置区分打开摄像头还是人脸识别的标识符
        self.switch_bt = 0

        # ###################### 数据库相关操作 ######################
        # 初始化需要记录的人名
        self.record_name = []
        # 设置更新人脸数据库的按键连接函数
        self.ui.bt_generator.clicked.connect(self.train_model)
        # 设置查询班级人数按键的连接函数
        self.ui.bt_check.clicked.connect(self.check_nums)
        # 设置请假按键的连接函数
        self.ui.bt_leave.clicked.connect(self.leave_button)
        # 设置漏签补签按键的连接函数
        self.ui.bt_supplement.clicked.connect(self.supplyment_button)
        # 设置对输入内容的删除提示
        self.ui.lineEdit_leave.setClearButtonEnabled(True)
        self.ui.lineEdit_supplement.setClearButtonEnabled(True)
        # 设置查看结果(显示未到和迟到)按键的连接函数
        self.ui.bt_view.clicked.connect(self.show_late_absence)
        # 核验本地人脸数据集与数据库中的ID是否一致,即验证是否有未录入数据库的情况,以及是否有未采集人脸的情况。
        self.ui.bt_check_variation.clicked.connect(self.check_variation_db)

        # self.check_time_set, ok = QInputDialog.getText(self, '考勤时间设定', '请输入考勤时间(格式为00:00:00):')
        self.check_time_set = '08:00:00'

        # 设置输入考勤时间的限制
        self.ui.spinBox_time_hour.setRange(0, 23)
        self.ui.spinBox_time_minute.setRange(0, 59)
Example #5
0
    def __init__(self):
        super(Main, self).__init__()
        self.ui = MainWindow.Ui_MainWindow()
        self.ui.setupUi(self)

        self.ui.pushButton.clicked.connect(self.helloWorld)
Example #6
0
 def __init__(self):
     super(Main, self).__init__()
     self.ui = MainWindow.Ui_MainWindow()
     self.ui.setupUi(self)