Ejemplo n.º 1
0
    def __init__(self, flags, controller_launcher, model_launcher):
        QtWidgets.QWidget.__init__(self, flags=flags)
        ViewElement.__init__(self, controller_launcher, model_launcher)

        self.setWindowTitle("Table edit")

        self.mainLayout = QtWidgets.QVBoxLayout(self)
        self.boxesLayout = QtWidgets.QHBoxLayout()
        self.buttonsLayout = QtWidgets.QHBoxLayout()
        self.editLayout = QtWidgets.QVBoxLayout()
        self.leftLayout = QtWidgets.QVBoxLayout()

        self.searchable_list = SearchableList(QtWidgets.QListWidget())

        self.tipped_list = TDTippedList(self.model_launcher, self.searchable_list)
        self.tipped_list.list.itemDoubleClicked.connect(self.insert_atom)

        self.name = QtWidgets.QLineEdit()
        self.name.setPlaceholderText("Name")
        self.mainEdit = QtWidgets.QTextEdit()

        self.mode = QtWidgets.QButtonGroup()
        checkBoxes = []
        for label in ["Table", "Atom"]:
            checkBoxes.append(QtWidgets.QCheckBox(label))
            self.mode.addButton(checkBoxes[-1])
        checkBoxes[0].setChecked(True)

        self.letters = QtWidgets.QComboBox()
        self.letters.addItem("")
        for a in alphas[:10]:
            self.letters.addItem(a)
        self.letters.setCurrentIndex(1)

        self.leftLayout.addWidget(self.searchable_list.searchbar)
        self.leftLayout.addWidget(self.tipped_list.list)
        self.leftLayout.addWidget(self.tipped_list.view)
        self.leftLayout.addWidget(self.letters)

        self.submitTablePattern = QtWidgets.QPushButton('Submit')
        self.submitTablePattern.clicked.connect(self.submit)

        self.removeAtom = QtWidgets.QPushButton('Remove Atom')
        self.removeAtom.clicked.connect(self.remove_atom)

        self.editLayout.addWidget(self.name)
        self.editLayout.addWidget(self.mainEdit)

        for cb in checkBoxes:
            self.buttonsLayout.addWidget(cb)
        self.buttonsLayout.addWidget(self.removeAtom)
        self.buttonsLayout.addWidget(self.submitTablePattern)

        self.boxesLayout.insertLayout(0, self.leftLayout)
        self.boxesLayout.insertLayout(1, self.editLayout)

        self.mainLayout.insertLayout(0, self.boxesLayout)
        self.mainLayout.insertLayout(1, self.buttonsLayout)

        self.showMaximized()
Ejemplo n.º 2
0
    def __init__(self, flags, data, pattern, tableLabels, title,
                 controller_launcher, model_launcher):
        QtWidgets.QWidget.__init__(self, flags=flags)
        ViewElement.__init__(self, controller_launcher, model_launcher)

        self.setWindowTitle(title)
        self.graph = Graph(data, pattern, tableLabels)

        self.mainLayout = QtWidgets.QVBoxLayout(self)
        set_title(self.mainLayout, title)
        self.graphLayout = QtWidgets.QHBoxLayout()
        self.mainLayout.insertLayout(1, self.graphLayout, stretch=10)

        self.left_layout = QtWidgets.QVBoxLayout(self)

        self.choiceTree = PatternTree(True)
        self.choiceTree.draw_pattern(pattern)
        self.choiceTree.itemChanged.connect(self.fix)

        self.switch_scatter_button = QtWidgets.QPushButton('Switch scatter')
        self.switch_scatter_button.clicked.connect(self.graph.toogle_scatter)

        self.left_layout.addWidget(self.choiceTree)
        self.left_layout.addWidget(self.switch_scatter_button)

        self.graphLayout.insertLayout(0, self.left_layout, stretch=1)
        self.graphLayout.addWidget(self.graph, stretch=8)

        self.showMaximized()
Ejemplo n.º 3
0
    def __init__(self, controller_launcher, model_launcher):
        QtWidgets.QWidget.__init__(self)
        ViewElement.__init__(self, controller_launcher, model_launcher)

        self.setWindowTitle('Scheduler dialog')

        self.main_layout = QtWidgets.QHBoxLayout(self)
        self.creation_layout = QtWidgets.QVBoxLayout()
        self.managing_layout = QtWidgets.QVBoxLayout()
        self.buttons_layout = QtWidgets.QHBoxLayout()

        self.schedulers = QtWidgets.QComboBox()
        update_manager = self.model_launcher.get_update_manager()
        for index, item in enumerate(update_manager.get_sources()):
            self.schedulers.addItem(item['name'])
            self.schedulers.setItemData(
                index, item.get('description', 'No description available'),
                QtCore.Qt.ToolTipRole)

        self.cron_line = QtWidgets.QLineEdit()
        self.cron_line.setPlaceholderText('Schedule in cron format')

        self.switched_on = QtWidgets.QCheckBox('Switched on by default')
        self.switched_on.setChecked(True)

        self.tipped_list = SDTippedList(self.model_launcher)

        self.switch_button = QtWidgets.QPushButton('Switch on/off')
        self.switch_button.clicked.connect(self.switch)

        self.remove_button = QtWidgets.QPushButton('Remove')
        self.remove_button.clicked.connect(self.remove)

        self.create_button = QtWidgets.QPushButton('Create scheduler')
        self.create_button.clicked.connect(self.create_scheduler)

        self.buttons_layout.addWidget(self.switch_button)
        self.buttons_layout.addWidget(self.remove_button)

        self.managing_layout.addWidget(self.tipped_list.list)
        self.managing_layout.addWidget(self.tipped_list.view)
        self.managing_layout.addLayout(self.buttons_layout)

        self.creation_layout.addWidget(self.schedulers)
        self.creation_layout.addWidget(self.cron_line)
        self.creation_layout.addWidget(self.switched_on)
        self.creation_layout.addWidget(self.create_button)

        self.main_layout.addLayout(self.managing_layout)
        self.main_layout.addLayout(self.creation_layout)

        self.show()
Ejemplo n.º 4
0
    def __init__(self, icon, controller_launcher, model_launcher):
        QSystemTrayIcon.__init__(self, icon)
        ViewElement.__init__(self, controller_launcher, model_launcher)

        self.menu = QMenu()
        self.menu.addAction("Quit", self.controller_launcher.quit)

        self.setContextMenu(self.menu)

        self.activated.connect(self.on_activated)

        self.setToolTip('Validol')

        self.show()
Ejemplo n.º 5
0
    def __init__(self, flags, data, labels, title, controller_launcher,
                 model_launcher):
        QtWidgets.QWidget.__init__(self, flags=flags)
        ViewElement.__init__(self, controller_launcher, model_launcher)

        self.setWindowTitle(title)

        table = pg.TableWidget()

        df = data.df[labels]

        table.setData(data.show_df[['Date'] + labels].to_records(index=False))

        for i, col in enumerate(df):
            if not np.issubdtype(df[col].dtype, np.number):
                continue

            col_without_nan = df[col].dropna()

            if col_without_nan.empty:
                continue

            min_val, max_val = col_without_nan.min(), col_without_nan.max()

            if max_val != min_val:
                for j in range(len(df)):
                    value = df.iloc[j, i]

                    if value is not None and not pd.isnull(value):
                        try:
                            norm = (value - min_val) / (max_val - min_val)
                            table.item(j, i + 1).setBackground(
                                QtGui.QBrush(
                                    QtGui.QColor(*map(
                                        int,
                                        [255 * norm, 0, 255 *
                                         (1 - norm), 100]))))
                        except:
                            pass

        self.mainLayout = QtWidgets.QVBoxLayout(self)

        set_title(self.mainLayout, title)
        self.mainLayout.addWidget(table, stretch=10)

        self.showMaximized()
Ejemplo n.º 6
0
    def __init__(self, controller_launcher, model_launcher):
        ViewElement.__init__(self, controller_launcher, model_launcher)

        self.app = QtWidgets.QApplication(sys.argv)

        self.app.setQuitOnLastWindowClosed(False)

        self.app_icons = self.get_icons()
        self.app.setWindowIcon(self.app_icons['default'])

        self.system_tray_icon = MySystemTrayIcon(self.app_icons['default'],
                                                 self.controller_launcher,
                                                 self.model_launcher)

        self.main_window = Window(self.app, self.controller_launcher,
                                  self.model_launcher)

        self.windows = set()
        self.qcron_manager = QCronManager(self.model_launcher, self)

        self.qcron_manager.refresh()
Ejemplo n.º 7
0
    def __init__(self, flags, data, table_pattern, title,
                 controller_launcher, model_launcher):
        QtWidgets.QWidget.__init__(self, flags=flags)
        ViewElement.__init__(self, controller_launcher, model_launcher)

        self.setWindowTitle(table_pattern.name)

        self.data = data

        self.title = title
        self.table_name = table_pattern.name
        self.table_labels = remove_duplications(table_pattern.all_formulas())

        self.main_layout = QtWidgets.QVBoxLayout(self)
        self.upper_layout = QtWidgets.QHBoxLayout()
        self.buttons_layout = QtWidgets.QHBoxLayout()
        self.labels_layout = QtWidgets.QVBoxLayout()
        self.labels_submit_layout = QtWidgets.QVBoxLayout()
        self.patternChoiceLayout = QtWidgets.QVBoxLayout()

        set_title(self.main_layout, self.title)

        self.main_layout.insertLayout(1, self.upper_layout, stretch=10)
        self.main_layout.insertLayout(2, self.buttons_layout)

        self.tipped_list = GDTippedList(model_launcher, self.table_name)

        self.removePattern = QtWidgets.QPushButton('Remove pattern')
        self.removePattern.clicked.connect(self.remove_pattern)

        self.edit_pattern_button = QtWidgets.QPushButton('Edit pattern')
        self.edit_pattern_button.clicked.connect(self.edit_pattern)

        self.patternChoiceLayout.addWidget(self.tipped_list.list)
        self.patternChoiceLayout.addWidget(self.removePattern)
        self.patternChoiceLayout.addWidget(self.tipped_list.view)
        self.patternChoiceLayout.addWidget(self.edit_pattern_button)

        self.graphsTree = PatternTree()

        self.patternTitle = QtWidgets.QLineEdit()
        self.patternTitle.setPlaceholderText("Pattern title")
        self.labels_submit_layout.addWidget(self.patternTitle)

        self.labels_submit_layout.addWidget(
            scrollable_area(self.labels_layout))

        self.upper_layout.insertLayout(0, self.labels_submit_layout)
        self.upper_layout.addWidget(self.graphsTree)
        self.upper_layout.insertLayout(2, self.patternChoiceLayout)

        self.submitPattern = QtWidgets.QPushButton('Submit pattern')
        self.submitPattern.clicked.connect(self.submit_pattern)

        self.drawGraph = QtWidgets.QPushButton('Draw graph')
        self.drawGraph.clicked.connect(self.draw_graph)

        self.buttons_layout.addWidget(self.submitPattern)
        self.buttons_layout.addWidget(self.drawGraph)

        self.graphs = []

        self.labels = []

        for i, label in enumerate(self.table_labels):
            lastLabel = QtWidgets.QHBoxLayout()

            textBox = QtWidgets.QLineEdit()
            textBox.setReadOnly(True)
            textBox.setText(label)
            lastLabel.addWidget(textBox)

            groups = [["left", "right"], ["line", "bar", "-bar", "ind"], ["show"]]


            button_groups = [ButtonGroup([QtWidgets.QCheckBox(label) for label in group])
                             for group in groups]
            for bg in button_groups:
                for item in bg.buttons:
                    lastLabel.addWidget(item)

            comboBoxes = [QtWidgets.QComboBox() for _ in range(2)]
            for comboBox in comboBoxes:
                model = comboBox.model()
                for color in GraphDialog.COLORS:
                    item = QtGui.QStandardItem("")
                    item.setBackground(QtGui.QColor(*color))
                    model.appendRow(item)

                comboBox.currentIndexChanged.connect(partial(self.indexChanged, comboBox))
                comboBox.highlighted.connect(partial(self.activated, comboBox))
                self.indexChanged(comboBox, 0)

                lastLabel.addWidget(comboBox)

            self.labels.append((textBox, button_groups, comboBoxes))

            self.labels_layout.insertLayout(i, lastLabel)

        self.submitGraph = QtWidgets.QPushButton('Submit graph')
        self.submitGraph.clicked.connect(self.submit_graph)
        self.labels_submit_layout.addWidget(self.submitGraph)

        self.currentPattern = Pattern()

        self.showMaximized()
Ejemplo n.º 8
0
    def __init__(self, app, controller_launcher, model_launcher):
        QtWidgets.QWidget.__init__(self)
        ViewElement.__init__(self, controller_launcher, model_launcher)

        self.app = app

        config = self.controller_launcher.get_package_config()
        self.setWindowTitle("{name} {version}".format(**config))

        self.actives = QtWidgets.QListWidget()
        self.actives.itemDoubleClicked.connect(self.submit_active)
        self.actives.currentItemChanged.connect(self.active_chosen)

        self.searchable_list = SearchableList(self.actives)

        self.new_active_button = QtWidgets.QPushButton('New active')
        self.new_active_button.clicked.connect(self.new_active)

        self.activesListLayout = QtWidgets.QVBoxLayout()
        self.activesListLayout.addWidget(self.searchable_list.searchbar)
        self.activesListLayout.addWidget(self.actives)
        self.activesListLayout.addWidget(self.new_active_button)

        self.platforms = QtWidgets.QListWidget()
        self.platforms.currentItemChanged.connect(self.platform_chosen)

        self.active_flavors = QtWidgets.QListWidget()
        self.active_flavors.itemDoubleClicked.connect(self.submit_active)

        self.flavors = QtWidgets.QListWidget()
        self.flavors.currentItemChanged.connect(self.flavor_chosen)

        self.flavors_map = OrderedDict(
            (flavor.name(), flavor)
            for flavor in self.model_launcher.get_flavors())

        for flavor in self.flavors_map.keys():
            self.flavors.addItem(flavor)

        self.flavors.setCurrentRow(0)

        self.drawTable = QtWidgets.QPushButton('Draw table')
        self.drawTable.clicked.connect(self.draw_table)

        self.update_app_button = QtWidgets.QPushButton('UPDATE APP')
        self.update_app_button.setStyleSheet("background-color: red")
        self.update_app_button.clicked.connect(
            self.controller_launcher.pip_update)
        self.update_app_button.hide()

        self.update_missed_schedulers_button = QtWidgets.QPushButton(
            'Update missed schedulers')
        self.update_missed_schedulers_button.setStyleSheet(
            "background-color: green")
        self.update_missed_schedulers_button.clicked.connect(
            self.on_update(self.controller_launcher.update_missed_schedulers,
                           self.update_missed_schedulers_button))
        self.update_missed_schedulers_button.hide()

        self.clear = QtWidgets.QPushButton('Clear all')
        self.clear.clicked.connect(self.clear_actives)

        self.createTable = QtWidgets.QPushButton('Create table')
        self.createTable.clicked.connect(self.create_table)

        self.updateButton = QtWidgets.QPushButton('Update')
        self.updateButton.clicked.connect(
            self.on_update(self.model_launcher.update_weekly,
                           self.updateButton))

        self.update_daily_button = QtWidgets.QPushButton('Update daily')
        self.update_daily_button.clicked.connect(
            self.on_update(self.model_launcher.update_daily,
                           self.update_daily_button))

        self.create_scheduler_button = QtWidgets.QPushButton(
            'Create scheduler')
        self.create_scheduler_button.clicked.connect(
            self.controller_launcher.show_scheduler_dialog)

        self.removeTable = QtWidgets.QPushButton('Remove table')
        self.removeTable.clicked.connect(self.remove_table)

        self.leftLayout = QtWidgets.QVBoxLayout()
        self.leftLayout.addWidget(self.flavors)
        self.leftLayout.addWidget(self.active_flavors)
        self.leftLayout.addWidget(self.update_missed_schedulers_button)
        self.leftLayout.addWidget(self.updateButton)
        self.leftLayout.addWidget(self.update_daily_button)
        self.leftLayout.addWidget(self.create_scheduler_button)

        self.cached_prices = QtWidgets.QListWidget()
        self.set_cached_prices()

        self.tipped_list = MWTippedList(self.model_launcher,
                                        QtWidgets.QListWidget())

        self.main_layout = QtWidgets.QVBoxLayout(self)

        self.lists_layout = QtWidgets.QHBoxLayout()

        self.remove_active_button = QtWidgets.QPushButton('Remove active')
        self.remove_active_button.clicked.connect(self.remove_active)

        self.remove_active_data_button = QtWidgets.QPushButton(
            'Remove active data')
        self.remove_active_data_button.clicked.connect(self.remove_active_data)

        self.reload_expirations_button = QtWidgets.QPushButton(
            'Reload expirations')
        self.reload_expirations_button.clicked.connect(self.reload_expirations)

        self.rightLayout = QtWidgets.QVBoxLayout()
        self.rightLayout.addWidget(self.cached_prices)
        self.rightLayout.addWidget(self.remove_active_button)
        self.rightLayout.addWidget(self.remove_active_data_button)
        self.rightLayout.addWidget(self.reload_expirations_button)
        self.rightLayout.addWidget(self.tipped_list.list)
        self.rightLayout.addWidget(self.removeTable)
        self.rightLayout.addWidget(self.tipped_list.view)
        self.rightLayout.addWidget(self.createTable)

        self.actives_layout = QtWidgets.QVBoxLayout()

        self.actives_layout_widgets = []
        self.actives_layout_lines = []
        self.chosen_actives = []

        self.actives_layout.addWidget(self.clear)

        self.lists_layout.insertLayout(0, self.leftLayout)
        self.lists_layout.addWidget(self.platforms)
        self.lists_layout.insertLayout(2, self.activesListLayout)
        self.lists_layout.addWidget(scrollable_area(self.actives_layout))
        self.lists_layout.insertLayout(4, self.rightLayout)

        self.main_layout.addWidget(self.update_app_button)
        self.main_layout.insertLayout(1, self.lists_layout)
        self.main_layout.addWidget(self.drawTable)

        self.showMaximized()