示例#1
0
    def add_widget(self, filter_item, filter_name):
        widget = QWidget()
        main_layout = QVBoxLayout()
        widget.setLayout(main_layout)
        main_layout.addWidget(QLabel(filter_item['model']))

        filter_layout = QHBoxLayout()
        filter_layout.addWidget(QLabel(filter_item['field']))
        filter_layout.addWidget(self.get_line())
        filter_layout.addWidget(QLabel(filter_item['operator']))
        filter_layout.addWidget(self.get_line())
        filter_layout.addWidget(QLabel(str(filter_item['value'])))

        remove_button = QToolButton()
        remove_button.setText('X')
        remove_button.clicked.connect(
            lambda: self.remove_filter(widget, filter_name))
        filter_layout.addWidget(remove_button)

        main_layout.addLayout(filter_layout)

        item = QListWidgetItem()
        item.setSizeHint(
            QSize(widget.sizeHint().width() + 25,
                  widget.sizeHint().height() + 5))
        item.setBackground(QColor('#C8C8C8'))
        self.filter_list_widget.addItem(item)
        self.filter_list_widget.setItemWidget(item, widget)
        self.widget_item_map[widget] = item
        self.widget_filter_map[widget] = filter_item
示例#2
0
    def update_list(self):
        que = self.w1.update()
        rows = self.cur.execute(que).fetchmany(self.count_rows_spin.value())
        self.list_order.clear()
        self.list_order_2.clear()
        for i in rows:
            dish_time_s = self.cur.execute(f'''select cooktime from dish 
                                                    where id = (select dishid from orderdish
                                                    where id = ({i[0]}))''').fetchone()[0]
            date_time_s = self.cur.execute(f'''select datetime from orderclient
                                              where id = {i[1]}''').fetchone()[0]
            dish_count = int(i[4])
            date_time = QDateTime.fromString(date_time_s, date_time_format())
            dish_time = QTime.fromString(dish_time_s, time_format())
            dish_time_minutes = dish_time.hour() * 60 + dish_time.minute() * dish_count
            dish_time = QTime(dish_time_minutes // 60, dish_time_minutes % 60)

            secs_passed = date_time.secsTo(QDateTime.currentDateTime())
            hms = [dish_time.hour() - secs_passed // 3600,
                   dish_time.minute() - secs_passed // 60 % 60,
                   59 - secs_passed % 60]
            time_last = QTime(*hms)
            if time_last.isValid():
                order = [time_last.toString(time_format() + ':ss'), *i[2:]]
            else:
                order = ['Done', *i[2:]]
            item = QListWidgetItem(' - '.join(map(str, order)))
            if not time_last.isValid():
                item.setBackground(QColor(255, 220, 220))
                self.list_order_2.addItem(item)
            else:
                self.list_order.addItem(item)
示例#3
0
 def send_key(self, text=""):
     if text == "":
         msg_txt = self.message_text.text()
     else:
         msg_txt = str(text)
     # print("my text is " + msg_txt)
     self.chat_text.scrollToBottom()
     if msg_txt != '':
         '''
         # send date at the start of conversation
         if self.first_msg:
             date = datetime.date.today().strftime("%B %d, %Y")
             item = QListWidgetItem('%s' % (date))
             self.chat_text.addItem(item)
             item.setBackground(QtGui.QColor('#fad000'))
             t = Thread(target=self.my_user.send_message, args=(self.friend_id, date))
             t.daemon = True
             # self.my_user.send_message(self.friend_id, msg_txt)
             t.start()
             self.first_msg = False
             time.sleep(0.8)
         '''
         item = QListWidgetItem('%s' % (self.my_user.name + " > " + msg_txt))
         self.chat_text.addItem(item)
         item.setBackground(QtGui.QColor('#ff944d'))
         self.message_text.setText("")
         t = Thread(target=self.my_user.send_message, args=(self.friend_id, msg_txt))
         t.daemon = True
         # self.my_user.send_message(self.friend_id, msg_txt)
         t.start()
         self.chat_text.scrollToBottom()
示例#4
0
    def get_order_info(self):
        market = self.window.line_order_coin_name.text()
        url = "https://api.upbit.com/v1/orderbook"
        querystring = {"markets":market}
        res = requests.request("GET", url, params=querystring)
        order_book = res.json()[0]["orderbook_units"]
        self.window.list_sell_order.clear()
        self.window.list_buy_order.clear()

        # 체결 정보
        url = "https://api.upbit.com/v1/trades/ticks"
        querystring = {"market":market,"count":"1"}
        res = requests.request("GET", url, params=querystring)
        cur_info = res.json()[0]
        cur_price = cur_info["trade_price"]
        ask_bid = cur_info["ask_bid"]

        for idx, unit in enumerate(order_book):
            sell_item = QListWidgetItem("{}    {}".format(unit["ask_price"], round(unit["ask_size"], 1)))
            buy_item = QListWidgetItem("{}     {}".format(unit["bid_price"], round(unit["bid_size"], 1)))

            if ask_bid == "BID":
               if unit["ask_price"] == cur_price :
                   sell_item.setBackground(QBrush(QColor("green")))
            elif ask_bid == "ASK":
               if unit["bid_price"] == cur_price :
                   buy_item.setBackground(QBrush(QColor("green")))

            self.window.list_sell_order.addItem(sell_item)
            self.window.list_buy_order.addItem(buy_item)
示例#5
0
class ThreadItem:

    _thread_count = 0

    def __init__(self, thread):
        super(ThreadItem, self).__init__()

        self.stub = QListWidgetItem()
        self.delegate = QWidget()

        self.stub.setSizeHint(QSize(0, 100))

        if ThreadItem._thread_count % 2 == 0:
            bg = QColor(0xffffff)
        else:
            bg = QColor(0xefefef)

        self.stub.setBackground(bg)

        layout = QVBoxLayout()
        title = QLabel(thread['title'])
        sub = QLabel(thread['subreddit_name_prefixed'])
        link = QLabel("<a href='https://reddit.com" + thread['permalink'] + "'>link</a>")

        title.setWordWrap(True)
        sub.setWordWrap(True)
        link.setOpenExternalLinks(True)

        layout.addWidget(title)
        layout.addWidget(sub)
        layout.addWidget(link)

        self.delegate.setLayout(layout)

        ThreadItem._thread_count += 1
示例#6
0
    def item_clicked_event(self, user_msgs_history):
        # история сообщений с выбранными пользователем
        # TODO заменить sleep на проверку обработки ответа от сервера
        self.list_msgs.clear()  # очищаем окно чата

        if not user_msgs_history:
            self.list_msgs.addItem('Сообщений нет')

        for msg in user_msgs_history:
            text_color = '#beaed4'
            text_align = QtCore.Qt.AlignLeft
            text_direction = 'от'
            if msg[1] == 'out':
                text_color = 'yellow'
                text_align = QtCore.Qt.AlignRight
                text_direction = 'для'

            msg_info = QListWidgetItem(f'{msg[3]} Сообщение {text_direction} {msg[0]}:')
            msg_text = QListWidgetItem(f'{msg[2]}')
            font = QtGui.QFont()
            font.setBold(True)
            font.setWeight(75)
            msg_info.setFont(font)
            msg_text.setFont(font)
            msg_info.setTextAlignment(text_align)
            msg_text.setTextAlignment(text_align)
            msg_info.setBackground(QtGui.QColor(text_color))
            msg_text.setBackground(QtGui.QColor(text_color))
            self.list_msgs.addItem(msg_info)
            self.list_msgs.addItem(msg_text)

            time.sleep(0.01)
            self.list_msgs.scrollToBottom()
    def load_mods(self, mods=[]):
        """
        Load mods into the list
        :param mods: 
        :return: 
        """
        self.listOfMods.clear()
        for m in self.get_available_mods():
            item = QListWidgetItem()
            item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
            # set used mods as active
            if m['path'] in mods:
                item.setCheckState(Qt.Checked)
            else:
                item.setCheckState(Qt.Unchecked)

            item.setText(m['name'])
            item.setData(Qt.UserRole, m['path'])
            # set background for the outdated mods
            if not m['version'].startswith(self.app.game_version['release']):
                item.setText('{} *OUTDATED*'.format(item.text()))
                item.setBackground(QColor('red'))

            self.listOfMods.addItem(item)

        self.listOfMods.sortItems(Qt.AscendingOrder)
示例#8
0
    def log(self, level, message, progress=None):
        """
        Add a log message to the progress dialog box.

        Parameters
        ----------
        level : int
            The level (i.e. logging level, info, warning, or critical) of the message.
        message : str
            The contents of the message.
        progress : int, optional
            The progress level from 0 to 100 of the message.
        """
        if progress is not None:
            self.dialog.progressBar.setValue(progress)

        if level in {logging.CRITICAL, logging.ERROR}:
            self.dialog.setWindowTitle('Error!')

        log = QListWidgetItem(message)
        color = {
            logging.WARNING: QColor(255, 204, 0),  # Yellow
            logging.ERROR: QColor(166, 68, 82),  # Red
            logging.CRITICAL: QColor(166, 68, 82)  # Red
        }.get(
            level
        )  # If level is not Warning, Error, or Critical, there will be a default (white) background.

        if color:
            log.setBackground(color)

        self.dialog.logsList.addItem(log)
        self.dialog.logsList.scrollToBottom()
示例#9
0
文件: demo.py 项目: helmogey/stations
    def show_details(self, clickedIndex):

        self.projectView.hide()
        self.status_push.hide()
        self.search_push.hide()
        self.search_line_edit.hide()
        self.search_lable.hide()
        self.comboBox.hide()
        self.main_minue.hide()
        df = self.projectModel._data
        header = list(df)
        self.record = df.values.tolist()[clickedIndex.row()]

        self.listWidget.clear()
        self.listWidget.show()
        self.back_push.show()
        self.show_report.show()

        txt = ""
        for h, d in zip(header, self.record):
            txt += str(h) + ": " + str(d) + "\n\n"

        it = QListWidgetItem(txt)

        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(200)
        font.setPointSize(12)
        it.setFont(font)
        it.setBackground(QtGui.QBrush(QtGui.QColor("lightblue")))
        it.setTextAlignment(Qt.AlignRight)

        self.listWidget.addItem(it)
示例#10
0
文件: stoly.py 项目: Kadziok/Pong
    def aktualizuj(self):
        """
        Pobiera i wyświetla listę aktualnie utworzonych stołów
        """
        while self.zalogowany:
            if not self.już_w_stole:
                odp = self.serwer.wyślij("pobierzstoly").split("_")
                nowe_elementy = []
                if len(odp) > 1 and odp[1] != "":
                    stoly = dict([i.split(":") for i in odp[1:]])

                    nowe_elementy = [[
                        f"Stół {i} \t| {self.status(stoly[i])}",
                        QColor('#d32323')
                        if stoly[i] == "1" else QColor('#A0A0A0')
                    ] for i in stoly]

                if nowe_elementy != self.elementy:
                    self.elementy = nowe_elementy
                    self.lista.clear()
                    for e in self.elementy:
                        i = QListWidgetItem(e[0])
                        i.setBackground(e[1])
                        self.lista.addItem(i)
            sleep(1)
示例#11
0
 def processDone(self):
     global transcripts
     global s2t
     global fs
     global data
     wavlength = len(data) / float(fs)
     ydata = [i[0] for i in data]
     xdata = range(len(ydata))
     graphLineColor = (200, 200, 234)
     graphCriticalLineColor = (255, 128, 128)
     timeCount = 0
     for i in s2t:
         dataPointLeft = int((timeCount / wavlength) * len(ydata))
         dataPointRight = int((i[1] / wavlength) * len(ydata))
         color = graphCriticalLineColor if profanity.contains_profanity(
             i[0]) else graphLineColor
         self.graphWidget.plot(xdata[dataPointLeft:dataPointRight],
                               ydata[dataPointLeft:dataPointRight],
                               pen=pg.mkPen(color=color))
         timeCount = i[1]
     self.transcriptBox.clear()
     criticalBrush = QBrush(QColor(41, 41, 61))
     for tr in transcripts:
         item = QListWidgetItem(str(profanity.censor(tr)).capitalize())
         if profanity.contains_profanity(tr):
             item.setForeground(criticalBrush)
             item.setBackground(QColor(255, 128, 128))
         self.transcriptBox.addItem(item)
     self.recordButtonOn = True
示例#12
0
    def __init__(self, task, username):

        super(show_tasks, self).__init__()

        self.task = task
        self.username = username
        task_list = Manage(self.username).show_ongoing_tasks()
        # task_list=Manage(self.username).show_tasks()
        self.task.clear()
        # print(task_list)

        self.x = len(task_list)
        for i in range(self.x):
            task_list = Manage(self.username).show_ongoing_tasks()

            l1 = QListWidgetItem()
            l1.setFont(QFont("Arial font", 16))
            # l1.setFrameStyle()
            if i % 2:
                l1.setBackground(Qt.darkGray)
            # l1.setStyleSheet('QListWidget { background: lightblue; border: solid black;}' )
            l1.setText("Task" + str(i + 1) + "\n" + "name: " +
                       task_list[i]["task name"] + "\n" + "score: " +
                       str(task_list[i]["score"]) + "\n" + "partners:" +
                       task_list[i]["partners"] + "\n" + "EndDate: " +
                       task_list[i]["end_date"] + "\n")
            self.task.addItem(l1)
示例#13
0
    def plugin_item_changed(self, index):
        """
        This function is called when the user selects another plugin in the plugin tree on the left side.
        Every change of plugin updates the displayed plugin information on the right side.

        :param index:
        :return:
        """
        plugin_info = self.pluginTree.model().data(index, Qt.UserRole)

        self.clear()

        self.scrollArea.setDisabled(True)

        if plugin_info is None:
            return

        self.scrollArea.setDisabled(False)

        self.nameEdit.setText(plugin_info.name)
        self.authorEdit.setText(plugin_info.author)
        self.descriptionText.setText(plugin_info.description)
        self.pathEdit.setText(plugin_info.path)

        self.createButton.setEnabled(plugin_info.loadable)

        lines = None
        with open(plugin_info.path + '.py') as f:
            lines = f.readlines()

        found_imports = []

        for line in lines:
            if line.startswith('import'):

                m = re.search('(import)\s+([\w.]*)(\s+as){0,1}', str.strip(line))
                if m is not None:
                    if len(m.groups()) > 2:
                        found_imports.append(m.group(2))

            if line.startswith('from'):
                m = re.search('(from)\s+([\w.]*)(\s+import)', str.strip(line))
                if m is not None:
                    if len(m.groups()) > 2:
                        found_imports.append(m.group(2))
        found_imports.sort()

        for imp in found_imports:
            item = QListWidgetItem(imp)

            spam_loader = importlib.find_loader(imp)
            found = spam_loader is not None
            if not found:
                self.modulesList.addItem(item)
                item.setBackground(QColor(255, 0, 0, 50))

        if not plugin_info.loadable:
            self.modulesList.setEnabled(True)
            self.modulesLabel.setEnabled(True)
示例#14
0
 def appendItem(self, name):
     if name is None:
         return
     ci = QListWidgetItem(QIcon(self.item_files[name]), name)
     if self.item_belongs[name]:
         ci.setBackground(QBrush(Qt.darkGreen))
     self.addItem(ci)
     self.setCurrentItem(ci)
 def addListWidget(self, widget, selectable, selected):
     item = QListWidgetItem()
     item.setSizeHint(widget.sizeHint())
     if not selectable:
         item.setFlags(item.flags() & ~Qt.ItemIsSelectable)
     if selected:
         item.setBackground(QColor(233, 119, 72))
     self.lstVersions.addItem(item)
     self.lstVersions.setItemWidget(item, widget)
示例#16
0
 def addCategory(self, title):
     item = QListWidgetItem(title)
     item.setBackground(QBrush(QColor(S.highlightLight)))
     item.setForeground(QBrush(QColor(S.highlightedTextDark)))
     item.setFlags(Qt.ItemIsEnabled)
     f = item.font()
     f.setBold(True)
     item.setFont(f)
     self.list.addItem(item)
示例#17
0
    def AddItem(self, name):
        item = QListWidgetItem(name)
        item.setTextAlignment(Qt.AlignCenter)
        # item.setBackground(QColor(87, 195, 194))
        item.setBackground(QColor(0, 0, 0, 0))
        item.setSizeHint(QSize(90, 30))
        item.setFlags(item.flags() & (~Qt.ItemIsSelectable))

        self.addItem(item)
示例#18
0
class ListItem:
    def __init__(self, window, name, now, freshUntil):
        self.window = window
        self.listWidget = QListWidgetItem(window.ui.listWidget)
        self.widget = QWidget(self.window)
        self.ui = listItem.Ui_ListItem()
        self.ui.setupUi(self.widget)
        self.ui.labelItem.setText(name)
        self.insert = now
        self.freshUntil = freshUntil
        self.name = name
        self.expired = False

        self.currentCategory = 0

        self.thresholds = [(100, QColor(0x55, 0xff, 0x7f)),
                           (50, QColor(0xff, 0xaa, 0x00)),
                           (25, QColor(0xff, 0x55, 0x00))]

        self.ui.removeButton.clicked.connect(self.removeClicked)
        self.setStatus(now)

    def setStatus(self, now):
        if self.expired:
            return

        remaining = now.daysTo(self.freshUntil)
        if remaining < 0:
            self.expired = True
            color = QColor(0xff, 0x9b, 0x9b)
            palette = self.widget.palette()
            palette.setColor(self.widget.backgroundRole(), color)
            self.widget.setPalette(palette)
            self.listWidget.setBackground(color)
            return

        fraction = int(
            (float(remaining) / self.insert.daysTo(self.freshUntil)) * 100)

        category = self.currentCategory
        for i in range(len(self.thresholds)):
            if fraction < self.thresholds[i][0]:
                category = i

        if category != self.currentCategory:
            self.currentCategory = category
            palette = self.ui.freshBar.palette()
            palette.setColor(QPalette.Highlight, self.thresholds[category][1])
            self.ui.freshBar.setPalette(palette)

        self.ui.freshBar.setValue(fraction)

    def setEnabled(self, enabled):
        self.ui.removeButton.setEnabled(enabled)

    def removeClicked(self):
        self.window.removeItem(self)
示例#19
0
 def addCategory(self, title):
     item = QListWidgetItem(title)
     item.setBackground(QBrush(lightBlue()))
     item.setForeground(QBrush(Qt.darkBlue))
     item.setFlags(Qt.ItemIsEnabled)
     f = item.font()
     f.setBold(True)
     item.setFont(f)
     self.list.addItem(item)
示例#20
0
 def addImageItem(self, p, pfile, belongs):
     current_row = self.count()
     name = str(p)
     it = QListWidgetItem(QIcon(pfile), name)
     if belongs:
         it.setBackground(QBrush(Qt.darkGreen))
     self.addItem(it)  # item is added at current_row
     self.item_positions[name] = current_row
     self.item_files[name] = pfile
示例#21
0
 def addCategory(self, title):
     item = QListWidgetItem(title)
     item.setBackground(QBrush(lightBlue()))
     item.setForeground(QBrush(Qt.darkBlue))
     item.setFlags(Qt.ItemIsEnabled)
     f = item.font()
     f.setBold(True)
     item.setFont(f)
     self.list.addItem(item)
示例#22
0
 def appendItem(self, name):
     if name is None:
         return
     ci = QListWidgetItem(QIcon(self.item_files[name]), name)
     if self.item_belongs[name]:
         ci.setBackground(QBrush(Qt.darkGreen))
     self.addItem(ci)
     # TODO: workaround to force re-orientation on entry to Sink list
     self.rotateForceRefresh(name)
     self.setCurrentItem(ci)
示例#23
0
    def device_connected(self, address, rssi, battery):

        new_device = MyoConnectedWidget(address, rssi, battery)
        temp_widget = QListWidgetItem()
        temp_widget.setBackground(Qt.gray)
        size_hint = new_device.sizeHint()
        size_hint.setHeight(40)
        temp_widget.setSizeHint(size_hint)
        self.devices_connected.addItem(temp_widget)
        self.devices_connected.setItemWidget(temp_widget, new_device)
示例#24
0
 def _decorateLoggerItem(self, item: QListWidgetItem,
                         logger: logging.Logger) -> None:
     """Decorate an entry in the logger list reflecting the properties
     of the logger.
     """
     item.setForeground(self._colorForLogLevel(logger.getEffectiveLevel()))
     font = item.font()
     font.setBold(bool(logger.level))
     item.setFont(font)
     item.setBackground(Qt.lightGray if logger.disabled else Qt.white)
示例#25
0
    def default_clicked(self):
        """ Set everything to the default values. """
        # Checkboxes
        self.ui.topmost_CheckBox.setCheckState(Qt.Checked)
        self.ui.skip_background_CheckBox.setCheckState(Qt.Checked)
        self.ui.update_canvas_CheckBox.setCheckState(Qt.Checked)
        self.ui.update_canvas_end_CheckBox.setCheckState(Qt.Checked)
        self.ui.draw_lines_CheckBox.setCheckState(Qt.Checked)
        self.ui.double_click_CheckBox.setCheckState(Qt.Unchecked)
        self.ui.show_info_CheckBox.setCheckState(Qt.Checked)
        self.ui.show_preview_CheckBox.setCheckState(Qt.Unchecked)
        self.ui.hide_preview_CheckBox.setCheckState(Qt.Unchecked)
        self.ui.paint_background_CheckBox.setCheckState(Qt.Unchecked)
        self.ui.opacities_CheckBox.setCheckState(Qt.Checked)
        self.ui.hidden_colors_CheckBox.setCheckState(Qt.Unchecked)

        # Comboboxes
        self.ui.quality_ComboBox.setCurrentIndex(default_settings["quality"])
        self.ui.brush_type_ComboBox.setCurrentIndex(default_settings["brush_type"])

        # Lineedits
        self.ui.ctrl_x_LineEdit.setText(str(default_settings["ctrl_x"]))
        self.ui.ctrl_y_LineEdit.setText(str(default_settings["ctrl_y"]))
        self.ui.ctrl_w_LineEdit.setText(str(default_settings["ctrl_w"]))
        self.ui.ctrl_h_LineEdit.setText(str(default_settings["ctrl_h"]))
        self.ui.pause_key_LineEdit.setText(default_settings["pause_key"])
        self.ui.skip_key_LineEdit.setText(default_settings["skip_key"])
        self.ui.abort_key_LineEdit.setText(default_settings["abort_key"])

        rgb = hex_to_rgb(default_settings["background_color"])
        if (rgb[0]*0.299 + rgb[1]*0.587 + rgb[2]*0.114) > 186:
            self.qpalette.setColor(QPalette.Text, QColor(0, 0, 0))
        else:
            self.qpalette.setColor(QPalette.Text, QColor(255, 255, 255))
        self.qpalette.setColor(QPalette.Base, QColor(rgb[0], rgb[1], rgb[2]))
        self.ui.background_LineEdit.setPalette(self.qpalette)
        self.ui.background_LineEdit.setText(default_settings["background_color"])

        self.ui.click_delay_LineEdit.setText(str(default_settings["click_delay"]))
        self.ui.ctrl_delay_LineEdit.setText(str(default_settings["ctrl_area_delay"]))
        self.ui.line_delay_LineEdit.setText(str(default_settings["line_delay"]))
        self.ui.min_line_width_LineEdit.setText(str(default_settings["minimum_line_width"]))

        # Set skip color list to default
        self.ui.skip_colors_ListWidget.clear()
        if default_settings["skip_colors"] != []:
            for hex in default_settings["skip_colors"]:
                rgb = hex_to_rgb(hex)
                i = QListWidgetItem(hex)
                i.setBackground(QColor(rgb[0], rgb[1], rgb[2]))
                if (rgb[0]*0.299 + rgb[1]*0.587 + rgb[2]*0.114) > 186:
                    i.setForeground(QColor(0, 0, 0))
                else:
                    i.setForeground(QColor(255, 255, 255))
                self.ui.skip_colors_ListWidget.addItem(i)
示例#26
0
    def __init__(self, main_window):
        self.dialog = QDialog(main_window.window)
        self.ui = qt_techs.Ui_Dialog()
        self.ui.setupUi(self.dialog)
        self.main_window = main_window

        starbound_folder = Config().read("starbound_folder")
        self.assets = assets.Assets(Config().read("assets_db"),
                                    starbound_folder)
        self.player = main_window.player

        self.selected_tech = None

        self.ui.tech_list.currentItemChanged.connect(self.update_selection)

        self.techs = [None, None, None, None]
        self.equip = [None, None, None, None]

        # populate equipped techs
        current = 1
        for i in self.player.get_tech_modules():
            try:
                tech_name = os.path.basename(i["modulePath"].replace(
                    ".tech", ""))
                tech = self.assets.techs().get_tech(tech_name)
                icon = QPixmap.fromImage(ImageQt(tech[1]))
                getattr(self.ui,
                        "icon" + str(current)).setPixmap(icon.scaled(32, 32))
                getattr(self.ui, "icon" + str(current)).setToolTip(
                    tech[0]["shortdescription"])
                self.techs[current - 1] = i
                self.equip[current - 1] = tech[0]["itemName"]
            except TypeError:
                logging.exception("Couldn't load tech: %s", i["modulePath"])
                pass

            current += 1

        self.ui.icon1_clear.clicked.connect(lambda: self.clear_tech(0))
        self.ui.icon2_clear.clicked.connect(lambda: self.clear_tech(1))
        self.ui.icon3_clear.clicked.connect(lambda: self.clear_tech(2))
        self.ui.icon4_clear.clicked.connect(lambda: self.clear_tech(3))

        self.ui.icon1_button.clicked.connect(lambda: self.set_tech(0))
        self.ui.icon2_button.clicked.connect(lambda: self.set_tech(1))
        self.ui.icon3_button.clicked.connect(lambda: self.set_tech(2))
        self.ui.icon4_button.clicked.connect(lambda: self.set_tech(3))

        known_recipes = [x["name"] for x in self.player.get_blueprints()]
        self.ui.tech_list.clear()
        for tech in self.assets.techs().all():
            item = QListWidgetItem(tech)
            if tech in known_recipes:
                item.setBackground(QBrush(QColor("lightBlue")))
            self.ui.tech_list.addItem(item)
示例#27
0
 def updateList(self):
     self.scenelistList.clear()
     for scene in self.gui.song.scenes:
         if self.gui.song.initial_scene == scene:
             scene = QListWidgetItem(scene)
             scene.setBackground(QColor('red'))
         self.scenelistList.addItem(scene)
     anyScenes = bool(self.gui.song.scenes)
     self.loadScenesBtn.setEnabled(anyScenes)
     self.removeScenesBtn.setEnabled(anyScenes)
     self.initPreview()
示例#28
0
 def updateList(self):
     self.scenelistList.clear()
     for scene in self.gui.song.scenes:
         if self.gui.song.initial_scene == scene:
             scene = QListWidgetItem(scene)
             scene.setBackground(QColor('red'))
         self.scenelistList.addItem(scene)
     anyScenes = bool(self.gui.song.scenes)
     self.loadScenesBtn.setEnabled(anyScenes)
     self.removeScenesBtn.setEnabled(anyScenes)
     self.initPreview()
示例#29
0
 def append_color(self, color):
     """ Appends a color to the list """
     hex = rgb_to_hex(color)
     i = QListWidgetItem(str(self.color_index) + "\t" + str(hex))
     i.setBackground(QColor(color[0], color[1], color[2]))
     if (color[0]*0.299 + color[1]*0.587 + color[2]*0.114) > 186:
         i.setForeground(QColor(0, 0, 0))
     else:
         i.setForeground(QColor(255, 255, 255))
     self.ui.colors_ListWidget.addItem(i)
     self.color_index += 1
示例#30
0
 def populate_list(self):
     """ Populates the colors list """
     for i, color in enumerate(rust_palette):
         hex = rgb_to_hex(color)
         i = QListWidgetItem(str(i) + "\t" + str(hex))
         i.setBackground(QColor(color[0], color[1], color[2]))
         if (color[0] * 0.299 + color[1] * 0.587 + color[2] * 0.114) > 186:
             i.setForeground(QColor(0, 0, 0))
         else:
             i.setForeground(QColor(255, 255, 255))
         self.ui.colors_ListWidget.addItem(i)
示例#31
0
 def add_no_found(self):
     #Load no results found message
     noFoundItem = QListWidgetItem(
         QIcon(resources.IMAGES['delete']),
             'No results were found!')
     font = noFoundItem.font()
     font.setBold(True)
     noFoundItem.setSizeHint(QSize(20, 30))
     noFoundItem.setBackground(QBrush(Qt.lightGray))
     noFoundItem.setForeground(QBrush(Qt.black))
     noFoundItem.setFont(font)
     self.listWidget.addItem(noFoundItem)
示例#32
0
 def updateList(self):
     self.scenelistList.clear()
     for i, scene in enumerate(self.gui.song.scenes):
         item = QListWidgetItem('{}. {}'.format(i + 1, scene))
         item.setData(self.ITEM_IT_ROLE, i)
         if self.gui.song.initial_scene == scene:
             item.setBackground(QColor('red'))
         self.scenelistList.addItem(item)
     anyScenes = bool(self.gui.song.scenes)
     self.loadScenesBtn.setEnabled(anyScenes)
     self.removeScenesBtn.setEnabled(anyScenes)
     self.initPreview()
    def add_widget_to_list(self, widget):
        item = QListWidgetItem()

        size = widget.sizeHint()
        size.setWidth(size.width() + 25)
        size.setHeight(size.height() + 10)

        item.setSizeHint(size)
        item.setBackground(QColor('#C8C8C8'))
        self.filter_box_list_widget.addItem(item)
        self.filter_box_list_widget.setItemWidget(item, widget)
        self.list_item_map[widget] = item
示例#34
0
文件: techs.py 项目: Xethos/starcheat
    def __init__(self, main_window):
        self.dialog = QDialog(main_window.window)
        self.ui = qt_techs.Ui_Dialog()
        self.ui.setupUi(self.dialog)
        self.main_window = main_window

        starbound_folder = Config().read("starbound_folder")
        self.assets = assets.Assets(Config().read("assets_db"),
                                    starbound_folder)
        self.player = main_window.player

        self.selected_tech = None

        self.ui.tech_list.currentItemChanged.connect(self.update_selection)

        self.techs = [None, None, None, None]
        self.equip = [None, None, None, None]

        # populate equipped techs
        current = 1
        for i in self.player.get_tech_modules():
            try:
                tech_name = os.path.basename(i["modulePath"].replace(".tech",""))
                tech = self.assets.techs().get_tech(tech_name)
                icon = QPixmap.fromImage(ImageQt(tech[1]))
                getattr(self.ui, "icon"+str(current)).setPixmap(icon.scaled(32,32))
                getattr(self.ui, "icon"+str(current)).setToolTip(tech[0]["shortdescription"])
                self.techs[current-1] = i
                self.equip[current-1] = tech[0]["itemName"]
            except TypeError:
                logging.exception("Couldn't load tech: %s", i["modulePath"])
                pass

            current += 1

        self.ui.icon1_clear.clicked.connect(lambda: self.clear_tech(0))
        self.ui.icon2_clear.clicked.connect(lambda: self.clear_tech(1))
        self.ui.icon3_clear.clicked.connect(lambda: self.clear_tech(2))
        self.ui.icon4_clear.clicked.connect(lambda: self.clear_tech(3))

        self.ui.icon1_button.clicked.connect(lambda: self.set_tech(0))
        self.ui.icon2_button.clicked.connect(lambda: self.set_tech(1))
        self.ui.icon3_button.clicked.connect(lambda: self.set_tech(2))
        self.ui.icon4_button.clicked.connect(lambda: self.set_tech(3))

        known_recipes = [x["name"] for x in self.player.get_blueprints()]
        self.ui.tech_list.clear()
        for tech in self.assets.techs().all():
            item = QListWidgetItem(tech)
            if tech in known_recipes:
                item.setBackground(QBrush(QColor("lightBlue")))
            self.ui.tech_list.addItem(item)
示例#35
0
 def on_addButton_clicked(self):
     """
     Private slot to add a new entry.
     """
     bookmark = self.filePicker.text()
     if bookmark:
         itm = QListWidgetItem(bookmark, self.filesList)
         if not QFileInfo(bookmark).exists():
             itm.setBackground(QColor(Qt.red))
         self.filePicker.clear()
         self.bookmarks.append(bookmark)
     row = self.filesList.currentRow()
     self.on_filesList_currentRowChanged(row)
示例#36
0
 def update_connections(self, connections):
     """
     Clears the connection list and adds an entry for each item in connetions
     :param connections: the new connections
     :type connections: dict
     """
     self.ui.connectionList.clear()
     for c in connections.keys():
         item = QListWidgetItem("%s (%s)" % (c[0], c[1]))
         enabled = connections[c]["enabled"]
         client = connections[c]["address"]
         item.setCheckState(Qt.Checked if enabled else Qt.Unchecked)
         color = self.connectionColors[0 if client is None else 1]
         item.setBackground(QBrush(color, Qt.SolidPattern))
         self.ui.connectionList.addItem(item)
示例#37
0
文件: techs.py 项目: thakyZ/starcheat
    def update_lists(self):
        visible_techs = [x["name"] for x in self.player.get_visible_techs()]
        self.ui.tech_list.clear()
        for tech in sorted(self.assets.techs().all()):
            if tech not in visible_techs:
                item = QListWidgetItem(tech)
                self.ui.tech_list.addItem(item)

        enabled = [x["name"] for x in self.player.get_enabled_techs()]
        self.ui.known_list.clear()
        for tech in sorted(visible_techs):
            item = QListWidgetItem(tech)
            if tech in enabled:
                item.setBackground(QBrush(QColor("lightBlue")))
            self.ui.known_list.addItem(item)
示例#38
0
    def add_command(self, cmd, success):
        """
        adds a new command to the list
        :param cmd: the command including the arguments
        :type cmd: dict
        :param success: flag if the execution of the command was successful
        :type success: bool
        """
        text = "%s (" % cmd["command"]
        for k, v in cmd.items():
            if k == "command":
                continue
            text += " %s:%s" % (k, v)
        text += " )"

        item = QListWidgetItem("::RECV      :: {}".format(text))
        if not success:
            item.setBackground(QBrush(self.commandFailureColor, Qt.SolidPattern))
        self.ui.commandList.addItem(item)
        self.ui.commandList.scrollToBottom()
示例#39
0
 def __init__(self, bookmarks, parent=None):
     """
     Constructor
     
     @param bookmarks list of bookmarked files (list of strings)
     @param parent parent widget (QWidget)
     """
     super(BookmarkedFilesDialog, self).__init__(parent)
     self.setupUi(self)
     
     self.filePicker.setMode(E5PathPickerModes.OpenFileMode)
     
     self.bookmarks = bookmarks[:]
     for bookmark in self.bookmarks:
         itm = QListWidgetItem(bookmark, self.filesList)
         if not QFileInfo(bookmark).exists():
             itm.setBackground(QColor(Qt.red))
         
     if len(self.bookmarks):
         self.filesList.setCurrentRow(0)
示例#40
0
    def __init__(self, main_window):
        self.dialog = QDialog(main_window.window)
        self.ui = qt_techs.Ui_Dialog()
        self.ui.setupUi(self.dialog)
        self.main_window = main_window

        starbound_folder = Config().read("starbound_folder")
        self.assets = assets.Assets(Config().read("assets_db"),
                                    starbound_folder)
        self.player = main_window.player

        self.selected_tech = None

        self.ui.tech_list.currentItemChanged.connect(self.update_selection)

        known_recipes = [x["name"] for x in self.player.get_blueprints()]
        self.ui.tech_list.clear()
        for tech in self.assets.techs().all():
            item = QListWidgetItem(tech)
            if tech in known_recipes:
                item.setBackground(QBrush(QColor("lightBlue")))
            self.ui.tech_list.addItem(item)
 def __init__(self, bookmarks, parent=None):
     """
     Constructor
     
     @param bookmarks list of bookmarked files (list of strings)
     @param parent parent widget (QWidget)
     """
     super(BookmarkedFilesDialog, self).__init__(parent)
     self.setupUi(self)
     
     self.fileButton.setIcon(UI.PixmapCache.getIcon("open.png"))
     
     self.fileCompleter = E5FileCompleter(self.fileEdit)
     
     self.bookmarks = bookmarks[:]
     for bookmark in self.bookmarks:
         itm = QListWidgetItem(bookmark, self.filesList)
         if not QFileInfo(bookmark).exists():
             itm.setBackground(QColor(Qt.red))
         
     if len(self.bookmarks):
         self.filesList.setCurrentRow(0)
示例#42
0
 def add_help(self):
     #Load help
     fileItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-file']),
         '@\t(Filter only by Files)')
     font = fileItem.font()
     font.setBold(True)
     fileItem.setSizeHint(QSize(20, 30))
     fileItem.setBackground(QBrush(Qt.lightGray))
     fileItem.setForeground(QBrush(Qt.black))
     fileItem.setFont(font)
     self.listWidget.addItem(fileItem)
     classItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-class']),
         '<\t(Filter only by Classes)')
     self.listWidget.addItem(classItem)
     classItem.setSizeHint(QSize(20, 30))
     classItem.setBackground(QBrush(Qt.lightGray))
     classItem.setForeground(QBrush(Qt.black))
     classItem.setFont(font)
     methodItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-function']),
         '>\t(Filter only by Methods)')
     self.listWidget.addItem(methodItem)
     methodItem.setSizeHint(QSize(20, 30))
     methodItem.setBackground(QBrush(Qt.lightGray))
     methodItem.setForeground(QBrush(Qt.black))
     methodItem.setFont(font)
     attributeItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-attributes']),
         '-\t(Filter only by Attributes)')
     self.listWidget.addItem(attributeItem)
     attributeItem.setSizeHint(QSize(20, 30))
     attributeItem.setBackground(QBrush(Qt.lightGray))
     attributeItem.setForeground(QBrush(Qt.black))
     attributeItem.setFont(font)
     thisFileItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-on-this-file']),
         '.\t(Filter only by Classes and Methods in this File)')
     font = thisFileItem.font()
     font.setBold(True)
     thisFileItem.setSizeHint(QSize(20, 30))
     thisFileItem.setBackground(QBrush(Qt.lightGray))
     thisFileItem.setForeground(QBrush(Qt.black))
     thisFileItem.setFont(font)
     self.listWidget.addItem(thisFileItem)
     tabsItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-tab']),
         '/\t(Filter only by the current Tabs)')
     font = tabsItem.font()
     font.setBold(True)
     tabsItem.setSizeHint(QSize(20, 30))
     tabsItem.setBackground(QBrush(Qt.lightGray))
     tabsItem.setForeground(QBrush(Qt.black))
     tabsItem.setFont(font)
     self.listWidget.addItem(tabsItem)
     lineItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-line']),
         ':\t(Go to Line)')
     font = lineItem.font()
     font.setBold(True)
     lineItem.setSizeHint(QSize(20, 30))
     lineItem.setBackground(QBrush(Qt.lightGray))
     lineItem.setForeground(QBrush(Qt.black))
     lineItem.setFont(font)
     self.listWidget.addItem(lineItem)
     nonPythonItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-nonpython']),
         '!\t(Filter only by Non Python Files)')
     self.listWidget.addItem(nonPythonItem)
     nonPythonItem.setSizeHint(QSize(20, 30))
     nonPythonItem.setBackground(QBrush(Qt.lightGray))
     nonPythonItem.setForeground(QBrush(Qt.black))
     nonPythonItem.setFont(font)
示例#43
0
 def addCategory(self, title):
     item = QListWidgetItem(title)
     item.setBackground(QBrush(QColor(S.highlightLight)))
     item.setForeground(QBrush(QColor(S.highlightedTextDark)))
     item.setFlags(Qt.ItemIsEnabled)
     self.list.addItem(item)