def setupTable(self): tbl = self.tbl_variables tbl.clearContents() tbl.setRowCount(0) for i in self.info.getInfoData(self.schid, self.selectedItemID, self.atype): k = i.split(': ')[0] v = i.split(': ')[1] pos = tbl.rowCount tbl.insertRow(pos) tbl.setItem(pos, 0, QTableWidgetItem(k)) tbl.setItem(pos, 1, QTableWidgetItem(v)) name = info.name if self.atype == PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL: err, name = ts3lib.getServerVariable( self.schid, VirtualServerProperties.VIRTUALSERVER_NAME) elif self.atype == PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL: err, name = ts3lib.getChannelVariable( self.schid, self.selectedItemID, ChannelProperties.CHANNEL_NAME) elif self.atype == PluginMenuType.PLUGIN_MENU_TYPE_CLIENT: err, name = ts3lib.getClientVariable( self.schid, self.selectedItemID, ClientProperties.CLIENT_NICKNAME) tbl.sortItems(0) self.setWindowTitle("{}'s Variables".format(name))
def setupTable(self): try: self.tbl_members.clearContents() self.tbl_members.setRowCount(0) cache = ts3client.ServerCache(self.schid) (err, suid) = ts3lib.getServerVariable(self.schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER) q = self.execSQL("SELECT * FROM '{}|{}'".format(suid, self.cid)) while q.next(): pos = self.tbl_members.rowCount if PluginHost.cfg.getboolean("general", "verbose"): print(pos) self.tbl_members.insertRow(pos) self.tbl_members.setItem(pos, 0, QTableWidgetItem(datetime.utcfromtimestamp(q.value("timestamp")).strftime('%Y-%m-%d %H:%M:%S'))) self.tbl_members.setItem(pos, 1, QTableWidgetItem(q.value("name"))) self.tbl_members.setItem(pos, 2, QTableWidgetItem(q.value("uid"))) self.tbl_members.setItem(pos, 3, QTableWidgetItem(str(q.value("dbid")))) box = QComboBox() box.connect("currentIndexChanged(int index)", self.currentIndexChanged) i = 0 for cgroup in self.cgroups: icon = QIcon(cache.icon(self.cgroups[cgroup]["icon"])) text = "{} ({})".format(self.cgroups[cgroup]["name"], cgroup) box.addItem(icon, text) box.setItemData(i, cgroup) if cgroup == q.value("cgid"): box.setCurrentIndex(i) i += 1 self.tbl_members.setCellWidget(pos, 4, box) self.tbl_members.setItem(pos, 5, QTableWidgetItem("{} ({})".format(q.value("invokername"), q.value("INVOKERUID")))) except: ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)
def setServerScenes(self, d): self.tableWidgetServerScenes.clearContents() self.serverSceneRegionLists = {} self.serverSceneRegionCount = {} #self.tableitems = [] #self.listViewRegionScenes.clear() # need to figure out how to free tableitems #del self.tableitems[:] while (self.tableWidgetServerScenes.rowCount != 0): self.tableWidgetServerScenes.removeRow(0) uuids = [] if d != None: i = 0 j = 0 for k, vals in d.items(): sceneName, regionName, uuid = vals if uuid not in uuids: uuids.append(uuid) self.tableWidgetServerScenes.insertRow( self.tableWidgetServerScenes.rowCount) self.serverScenes[i] = uuid self.serverSceneNames[i] = sceneName sceneNameItem = QTableWidgetItem(sceneName) self.tableitems.append(sceneNameItem) self.tableWidgetServerScenes.setItem( self.tableWidgetServerScenes.rowCount - 1, 0, sceneNameItem) i += 1 # store regions if (self.serverSceneRegionLists.has_key(uuid) == False): self.serverSceneRegionLists[uuid] = [] self.serverSceneRegionLists[uuid].append(regionName) if (self.serverSceneRegionCount.has_key(uuid) == False): if regionName != "": self.serverSceneRegionCount[uuid] = 1 else: self.serverSceneRegionCount[uuid] = 0 elif regionName != "": self.serverSceneRegionCount[uuid] += 1 else: self.serverSceneRegionCount[uuid] = 0 regionCountItem = QTableWidgetItem( str(self.serverSceneRegionCount[uuid])) self.tableitems.append(regionCountItem) row = 0 for r in self.serverScenes.keys(): if self.serverScenes[r] == uuid: row = r break self.tableWidgetServerScenes.setItem(row, 1, regionCountItem) pass
def setupTable(self, type, target): tbl = self.tbl_variables tbl.clear() for k, v in info.getVariables(type, target): pos = tbl.rowCount tbl.insertRow(pos) tbl.setItem(pos, 0, QTableWidgetItem(k)) tbl.setItem(pos, 1, QTableWidgetItem(v)) displayName = ts3.getClientDisplayName() self.setWindowTitle("{}'s Variables".format(target))
def setupList(self): self.pluginsTable.clear() self.pluginsTable.setRowCount(len(self.host.plugins)) try: ico = ts3client.IconPack.current() ico.open() except Exception as e: ico = None ts3print(self._tr("Error loading iconpack: {exception}"). format(exception=e), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon.ConfigurationDialog.setupList", 0) row = 0 diffapi = self.cfg.getboolean("general", "differentApi", fallback=False) for key, p in self.host.plugins.items(): if diffapi or p.apiVersion == pytson.getCurrentApiVersion(): item = QTableWidgetItem(p.name) item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) item.setCheckState(Qt.Checked if key in self.host.active else Qt.Unchecked) item.setData(Qt.UserRole, key) self.pluginsTable.setItem(row, 0, item) if p.offersConfigure: setbutton = QToolButton() setbutton.connect("clicked()", lambda n=p.name: self.onSettingsButtonClicked(n)) setbutton.setToolTip(self._tr("Configure")) if ico: setbutton.setIcon(QIcon(ico.icon("SETTINGS"))) self.pluginsTable.setCellWidget(row, 1, setbutton) if p.name not in self.host.active: setbutton.setEnabled(False) rembutton = QToolButton() if ico: rembutton.setIcon(QIcon(ico.icon("DELETE"))) rembutton.connect("clicked()", lambda n=p.name: self.onRemoveButtonClicked(n)) rembutton.setToolTip(self._tr("Remove")) self.pluginsTable.setCellWidget(row, 2, rembutton) row += 1 if ico: ico.close() self.pluginsTable.setRowCount(row) self.pluginsTable.sortItems(0)
def setupTable(self): try: self.tbl_filters.clearContents() self.tbl_filters.setRowCount(0) for o in self.cfg.options('filters'): pos = self.tbl_filters.rowCount self.tbl_filters.insertRow(pos) tmp = self.cfg.get('filters', o).split('|', 2) chk_case = QCheckBox() chk_case.setChecked(bool(int(tmp[0]))) self.tbl_filters.setCellWidget(pos, 0, chk_case) box_type = QComboBox() box_type.addItems(["Prefix", "Suffix", "Contains", "Equals"]) box_type.connect("currentIndexChanged(int)", self.currentIndexChanged) box_type.setCurrentText(tmp[1]) self.tbl_filters.setCellWidget(pos, 1, box_type) self.tbl_filters.setItem(pos, 2, QTableWidgetItem(o)) self.tbl_filters.setItem(pos, 3, QTableWidgetItem(tmp[2])) except: ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)
def reloadSite(self): self.siteTable.clearContents() self.sitepkgs = devtools.installedPackages() self.siteTable.setRowCount(len(self.sitepkgs)) for i, pkg in enumerate(self.sitepkgs): item = QTableWidgetItem(pkg["name"]) item.setData(Qt.UserRole, i) self.siteTable.setItem(i, 0, item) item = QTableWidgetItem(pkg["version"]) item.setData(Qt.UserRole, i) self.siteTable.setItem(i, 1, item) self.siteTable.sortItems(0)
def build_gui(self): self.setWindowFlags(Qt.Qt.Window) layout = QtGui.QGridLayout() layout.setSpacing(10) # Window layout #layout = QtGui.QVBoxLayout() self.setLayout(layout) self.show_button_neurite = QtGui.QPushButton('Show neurite') self.show_button_selected_neurite = QtGui.QPushButton( 'Add selected neurite(s)') self.show_button_synapse = QtGui.QPushButton('Show synapse') self.clear_knossos_view_button = QtGui.QPushButton('Clear view') self.ssv_selector = QtGui.QListView() self.ssv_selector.setUniformItemSizes(True) # better performance self.ssv_item_model = QtGui.QStandardItemModel(self.ssv_selector) self.syn_selector = QtGui.QListView() self.syn_selector.setUniformItemSizes(True) # better performance self.syn_item_model = QtGui.QStandardItemModel(self.syn_selector) self.direct_ssv_id_input = QtGui.QLineEdit() self.direct_ssv_id_input.setValidator(QtGui.QIntValidator()) self.direct_ssv_id_input.setMaxLength(8) self.direct_syn_id_input = QtGui.QLineEdit() self.direct_syn_id_input.setValidator(QtGui.QIntValidator()) self.direct_syn_id_input.setMaxLength(8) # celltype self.celltype_field = QtGui.QLabel("CellType: ", self) # synapse self.synapse_field1 = QTableWidget() self.synapse_field1.setRowCount(5) self.synapse_field1.setColumnCount(2) self.synapse_field1.setItem(0, 0, QTableWidgetItem("coordinate")) self.synapse_field1.setItem(0, 1, QTableWidgetItem("")) self.synapse_field1.setItem(1, 0, QTableWidgetItem("synaptic type")) self.synapse_field1.setItem(1, 1, QTableWidgetItem("")) self.synapse_field1.setItem(2, 0, QTableWidgetItem("syn. proba.")) self.synapse_field1.setItem(2, 1, QTableWidgetItem("")) self.synapse_field1.setItem(3, 0, QTableWidgetItem("size [um^2]")) self.synapse_field1.setItem(3, 1, QTableWidgetItem("")) self.synapse_field1.setItem(4, 0, QTableWidgetItem("Object ID")) self.synapse_field1.setItem(4, 1, QTableWidgetItem("")) # self.synapse_field1.setEditTriggers(QtWidgets.QTableWidget.NoEditTriggers) # qt5 header = self.synapse_field1.horizontalHeader() header.setSectionResizeMode(0, QtGui.QHeaderView.Stretch) header.setSectionResizeMode(1, QtGui.QHeaderView.ResizeToContents) self.synapse_field1.setEditTriggers( QtGui.QAbstractItemView.NoEditTriggers) self.synapse_field2 = QTableWidget() self.synapse_field2.setRowCount(5) self.synapse_field2.setColumnCount(3) # TODO: sort by pre and post in 'on_syn_selector_changed' and replace neuron1 and neuron2 by pre and post self.synapse_field2.setItem(0, 1, QTableWidgetItem("neuron 1")) self.synapse_field2.setItem(0, 2, QTableWidgetItem("neuron 2")) self.synapse_field2.setItem(1, 0, QTableWidgetItem("SSV ID")) self.synapse_field2.setItem(2, 0, QTableWidgetItem("cell type")) self.synapse_field2.setItem(3, 0, QTableWidgetItem("cell comp.")) self.synapse_field2.setItem(4, 0, QTableWidgetItem("spiness")) # self.synapse_field2.setEditTriggers(QtWidgets.QTableWidget.NoEditTriggers) # qt5 self.synapse_field2.setEditTriggers( QtGui.QAbstractItemView.NoEditTriggers) header = self.synapse_field2.horizontalHeader() header.setSectionResizeMode(0, QtGui.QHeaderView.Stretch) header.setSectionResizeMode(1, QtGui.QHeaderView.ResizeToContents) header.setSectionResizeMode(2, QtGui.QHeaderView.ResizeToContents) self.send_synapsetype_label_button = QtGui.QPushButton('Send') self.synapsetype_label = QtGui.QLabel() self.synapsetype_label.setText( "Synapse type label [-1: inhib.; 0: non-syn.; 1: " "excit.]:") self.synapsetype_label_text = QtGui.QLineEdit() self.send_button_response_label = QtGui.QLabel() self.send_button_response_label.setText(None) #self.exploration_mode_chk_box = QtGui.QCheckBox('Exploration mode') #self.exploration_mode_chk_box.setChecked(True) #self.ssv_selection_model = # QtGui.QItemSelectionModel(self.ssv_select_model) #self.selectionModel = # self.ssv_selector.selectionModel(self.ssv_selector) #self.ssv_selector.setSelectionModel(self.ssv_selection_model) #print('selection model: ' + str(self.ssv_selector.selectionModel())) self.ssv_selector.clicked.connect(self.on_ssv_selector_changed) self.syn_selector.clicked.connect(self.on_syn_selector_changed) self.populate_ssv_list() self.populate_syn_list() print('Connected to SyConnGate.') layout.addWidget(self.direct_ssv_id_input, 1, 0, 1, 1) layout.addWidget(self.direct_syn_id_input, 1, 1, 1, 1) layout.addWidget(self.ssv_selector, 2, 0, 1, 1) layout.addWidget(self.syn_selector, 2, 1, 1, 1) layout.addWidget(self.show_button_neurite, 3, 0, 1, 1) layout.addWidget(self.show_button_synapse, 3, 1, 1, 1) layout.addWidget(self.clear_knossos_view_button, 4, 0, 1, 1) layout.addWidget(self.show_button_selected_neurite, 5, 0, 1, 1) layout.addWidget(self.celltype_field, 1, 2, 1, 2) layout.addWidget(self.synapse_field1, 2, 2, 1, 1) layout.addWidget(self.synapse_field2, 3, 2, 1, 1) layout.addWidget(self.synapsetype_label, 4, 1, 1, 1) layout.addWidget(self.synapsetype_label_text, 4, 2, 1, 2) layout.addWidget(self.send_button_response_label, 5, 1, 1, 1) layout.addWidget(self.send_synapsetype_label_button, 5, 2, 1, 1) #self.ssv_select_model.itemChanged.connect(self.on_ssv_selector_changed) #self.selectionModel.selectionChanged.connect(self.on_ssv_selector_changed) self.show_button_neurite.clicked.connect( self.show_button_neurite_clicked) self.show_button_selected_neurite.clicked.connect( self.show_button_selected_neurite_clicked) self.show_button_synapse.clicked.connect( self.show_button_synapse_clicked) self.clear_knossos_view_button.clicked.connect( self.clear_knossos_view_button_clicked) self.send_synapsetype_label_button.clicked.connect( self.send_synapsetype_label_button_clicked) #self.exploration_mode_chk_box.stateChanged.connect(self.exploration_mode_changed) # self.setGeometry(300, 300, 450, 300) self.setWindowTitle('SyConn Viewer v2') self.show()
def on_syn_selector_changed(self, index, signal_block=True): """ `all_syns` contains the following keys: cd_dict['syn_size'] =\ csd.load_cached_data('mesh_area') / 2 # as used in syn_analysis.py -> export_matrix cd_dict['synaptivity_proba'] = \ csd.load_cached_data('syn_prob') cd_dict['coord_x'] = \ csd.load_cached_data('rep_coord')[:, 0].astype(np.int) cd_dict['coord_y'] = \ csd.load_cached_data('rep_coord')[:, 1].astype(np.int) cd_dict['coord_z'] = \ csd.load_cached_data('rep_coord')[:, 2].astype(np.int) cd_dict['ssv_partner_0'] = \ csd.load_cached_data('neuron_partners')[:, 0].astype(np.int) cd_dict['ssv_partner_1'] = \ csd.load_cached_data('neuron_partners')[:, 1].astype(np.int) cd_dict['neuron_partner_ax_0'] = \ csd.load_cached_data('partner_axoness')[:, 0].astype(np.int) cd_dict['neuron_partner_ax_1'] = \ csd.load_cached_data('partner_axoness')[:, 1].astype(np.int) cd_dict['neuron_partner_ct_0'] = \ csd.load_cached_data('partner_celltypes')[:, 0].astype(np.int) cd_dict['neuron_partner_ct_1'] = \ csd.load_cached_data('partner_celltypes')[:, 1].astype(np.int) cd_dict['neuron_partner_sp_0'] = \ csd.load_cached_data('partner_spiness')[:, 0].astype(np.int) cd_dict['neuron_partner_sp_1'] = \ csd.load_cached_data('partner_spiness')[:, 1].astype(np.int) Parameters ---------- index : signal_block : Returns ------- """ # disable knossos signal emission first - O(n^2) otherwise if signal_block: signalsBlocked = KnossosModule.knossos_global_skeletonizer.blockSignals( True) inp_str = self.syn_selector.model().itemData(index)[0] ssv1 = int(re.findall(r'\((\d+),', inp_str)[0]) ssv2 = int(re.findall(r', (\d+)\)', inp_str)[0]) ix = index.row() tree_id = hash((ssv1, ssv2)) syn_id = self.all_syns['ids'][ix] self._currently_active_syn = syn_id # TODO: pull_so_attr and writing its results to `synapsetype_label_text` should run as a thread syn_gt_syntype = self.syconn_gate.pull_so_attr(so_id=syn_id, so_type='syn_ssv', attr_key='gt_syntype') if len(syn_gt_syntype) == 0: self.synapsetype_label_text.clear() else: self.synapsetype_label_text.setText(syn_gt_syntype) c = [ self.all_syns['coord_x'][ix], self.all_syns['coord_y'][ix], self.all_syns['coord_z'][ix] ] k_tree = KnossosModule.skeleton.find_tree_by_id(tree_id) if k_tree is None: k_tree = KnossosModule.skeleton.add_tree(tree_id) # add synapse location kn = KnossosModule.skeleton.add_node([c[0] + 1, c[1] + 1, c[2] + 1], k_tree, {}) KnossosModule.skeleton.jump_to_node(kn) # syn properties syn_size = self.all_syns["syn_size"][ix] syn_size = np.abs(syn_size) # coordinate self.synapse_field1.setItem(0, 1, QTableWidgetItem(str(c))) # synapse type self.synapse_field1.setItem( 1, 1, QTableWidgetItem(str(self.all_syns['syn_sign'][ix]))) # synaptic probability self.synapse_field1.setItem( 2, 1, QTableWidgetItem(str(self.all_syns["synaptivity_proba"][ix]))) # synaptic size (area in um^2) self.synapse_field1.setItem(3, 1, QTableWidgetItem(str(syn_size))) # object ID self.synapse_field1.setItem(4, 1, QTableWidgetItem(str(syn_id))) # pre- and post synaptic properties # IDs self.synapse_field2.setItem( 1, 1, QTableWidgetItem(str(self.all_syns["ssv_partner_0"][ix]))) self.synapse_field2.setItem( 1, 2, QTableWidgetItem(str(self.all_syns["ssv_partner_1"][ix]))) # cell type self.synapse_field2.setItem( 2, 1, QTableWidgetItem( int2str_label_converter( self.all_syns["neuron_partner_ct_0"][ix], "ctgt_v2"))) self.synapse_field2.setItem( 2, 2, QTableWidgetItem( int2str_label_converter( self.all_syns["neuron_partner_ct_1"][ix], "ctgt_v2"))) # cell compartments self.synapse_field2.setItem( 3, 1, QTableWidgetItem( int2str_label_converter( self.all_syns["neuron_partner_ax_0"][ix], "axgt"))) self.synapse_field2.setItem( 3, 2, QTableWidgetItem( int2str_label_converter( self.all_syns["neuron_partner_ax_1"][ix], "axgt"))) # cell compartments self.synapse_field2.setItem( 4, 1, QTableWidgetItem( int2str_label_converter( self.all_syns["neuron_partner_sp_0"][ix], "spgt"))) self.synapse_field2.setItem( 4, 2, QTableWidgetItem( int2str_label_converter( self.all_syns["neuron_partner_sp_1"][ix], "spgt"))) # enable signals again if signal_block: KnossosModule.knossos_global_skeletonizer.blockSignals( signalsBlocked) KnossosModule.knossos_global_skeletonizer.resetData() return
def listServers(self): if self.cooldown: self.status.setText("You have to wait " + str(self.cooldown_time / 1000) + " second(s) before retrying!") palette = QPalette() palette.setColor(QPalette.Foreground, Qt.red) self.status.setPalette(palette) return url = self.setupURL() servers = self.requestServers(url) self.status.setText("Status: " + servers["status"].title()) if servers["status"] == "success": self.pages = servers["result"]["pagestotal"] self.pageLabel.setText( str(servers["result"]["pageactive"]) + " / " + str(servers["result"]["pagestotal"])) self.pageLabel.updateGeometry() self.info.setText( str(servers["result"]["itemsshown"]) + " / " + str(servers["result"]["itemstotal"]) + " Servers shown.") self.serverList.setRowCount(0) elif servers["status"] == "error": self.info.setText("Requested Page: " + str(self.page)) self.status.setText(servers["status"].title() + ": " + servers["result"]["message"] + " (" + str(servers["result"]["code"]) + ")") palette = QPalette() palette.setColor(QPalette.Foreground, Qt.red) self.status.setPalette(palette) return else: self.info.setText("Requested Page: " + str(self.page)) palette = QPalette() palette.setColor(QPalette.Foreground, Qt.red) self.status.setPalette(palette) return _list = self.serverList _filters = self.serverBrowser.config["FILTERS"] if servers["result"]["pageactive"] == 1: self.previous.setEnabled(False) else: self.previous.setEnabled(True) if servers["result"]["pageactive"] == servers["result"]["pagestotal"]: self.next.setEnabled(False) else: self.next.setEnabled(True) for key in servers["result"]["data"]: if self.buhl( _filters["hideFull"]) and key["users"] >= key["slots"]: continue elif self.buhl(_filters["hideEmpty"]) and key["users"] <= 0: continue else: print("%s" % key) rowPosition = _list.rowCount _list.insertRow(rowPosition) # if key['premium']: # _list.setItem(rowPosition, 0, QTableWidgetItem("Yes")) # else: # _list.setItem(rowPosition, 0, QTableWidgetItem("No")) _list.setItem(rowPosition, 0, QTableWidgetItem(key['name'])) _list.setItem( rowPosition, 1, QTableWidgetItem( str(key['users']) + ' / ' + str(key['slots']))) if key['users'] >= key['slots']: palette = QPalette() palette.setColor(QPalette.Foreground, Qt.red) _list.setPalette(palette) _list.setItem( rowPosition, 2, QTableWidgetItem(self.getCountryNamebyID(key['country']))) if key['createchannels']: _list.setItem(rowPosition, 3, QTableWidgetItem("Yes")) else: _list.setItem(rowPosition, 3, QTableWidgetItem("No")) if key['password']: _list.setItem(rowPosition, 4, QTableWidgetItem("Yes")) else: _list.setItem(rowPosition, 4, QTableWidgetItem("No"))
def serversReply(self, reply): try: _api = self.serverBrowser.config['GENERAL']['api'] _reason = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) _reply = reply.readAll() servers = json.loads(_reply.data().decode('utf-8')) ts3.printMessageToCurrentTab("servers: %s"%servers) self.status.setText("Response from \"{0}\": {1}: {2}".format(_api, _reason, reply.attribute(QNetworkRequest.HttpReasonPhraseAttribute))) palette = QPalette() if not _reason == 200: palette.setColor(QPalette.Foreground,Qt.red) self.status.setPalette(palette) self.status.setText("Status: %s"%reply.attribute(QNetworkRequest.HttpReasonPhraseAttribute)) if servers["status"] == "success": self.pages = servers["result"]["pagestotal"] self.pageLabel.setText(str(servers["result"]["pageactive"])+" / "+str(servers["result"]["pagestotal"])) self.pageLabel.updateGeometry() self.info.setText(str(servers["result"]["itemsshown"])+" / "+str(servers["result"]["itemstotal"])+" Servers shown.") self.serverList.setRowCount(0) elif servers["status"] == "error": self.info.setText("Requested Page: "+str(self.page)) self.status.setText(servers["status"].title()+": "+servers["result"]["message"]+" ("+str(servers["result"]["code"])+")") palette = QPalette() palette.setColor(QPalette.Foreground,Qt.red) self.status.setPalette(palette) return else: self.info.setText("Requested Page: "+str(self.page)) palette = QPalette() palette.setColor(QPalette.Foreground,Qt.red) self.status.setPalette(palette) return _list = self.serverList _filters = self.serverBrowser.config["FILTERS"] if servers["result"]["pageactive"] == 1: self.previous.setEnabled(False) else: self.previous.setEnabled(True) if servers["result"]["pageactive"] == servers["result"]["pagestotal"]: self.next.setEnabled(False) else: self.next.setEnabled(True) for key in servers["result"]["data"]: if self.buhl(_filters["hideFull"]) and key["users"] >= key["slots"]: continue elif self.buhl(_filters["hideEmpty"]) and key["users"] <= 0: continue else: rowPosition = _list.rowCount _list.insertRow(rowPosition) # if key['premium']: # _list.setItem(rowPosition, 0, QTableWidgetItem("Yes")) # else: # _list.setItem(rowPosition, 0, QTableWidgetItem("No")) _list.setItem(rowPosition, 0, QTableWidgetItem(key['name'])) _list.setItem(rowPosition, 1, QTableWidgetItem(str(key['users'])+' / '+str(key['slots']))) if key['users'] >= key['slots']: palette = QPalette() palette.setColor(QPalette.Foreground,Qt.red) _list.setPalette(palette) _list.setItem(rowPosition, 2, QTableWidgetItem(self.getCountryNamebyID(key['country']))) if key['createchannels']: _list.setItem(rowPosition, 3, QTableWidgetItem("Yes")) else: _list.setItem(rowPosition, 3, QTableWidgetItem("No")) if key['password']: _list.setItem(rowPosition, 4, QTableWidgetItem("Yes")) else: _list.setItem(rowPosition, 4, QTableWidgetItem("No")) #item.setData(Qt.UserRole, key['ip']); _list.setAlternatingRowColors(True) _list.styleSheet = "alternate-background-color: grey;" _list.setStyleSheet("alternate-background-color: grey;") except: ts3.logMessage(traceback.format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)
def setupList(self, addons): try: self.tbl_addons.clear() self.tbl_addons.setRowCount(len(addons)) row = 0 for addon in addons: try: if addon == None or addon.text == None: continue _type = "Other" try: _type = addon.attrib["t"].title() except: pass item = QTableWidgetItem(_type) item.setFlags(Qt.ItemIsEnabled | ~Qt.ItemIsEditable) self.tbl_addons.setItem(row, 0, item) item = QTableWidgetItem(addon.text) if len(list(addon)): font = QFont() font.setBold(True) item.setFont(font) # item.setData(Qt.UserRole, addon.text) if addon.text == "pyTSon": self.pytson = addon elif addon.text == "Lua": self.lua = addon item.setFlags(Qt.ItemIsEnabled | ~Qt.ItemIsEditable) self.tbl_addons.setItem(row, 1, item) if PluginHost.cfg.getboolean("general", "verbose"): ts3.printMessageToCurrentTab( "%i [color=red]%s" % (row, xml.tostring(addon).decode("utf-8"))) try: item = QTableWidgetItem(addon.attrib["v"]) item.setFlags(Qt.ItemIsEnabled | ~Qt.ItemIsEditable) self.tbl_addons.setItem(row, 2, item) except: ts3.logMessage( "Addon %s does not have any version." % (addon.text), ts3defines.LogLevel.LogLevel_WARNING, "Addon List", 0) try: item = QTableWidgetItem(addon.attrib["a"]) item.setFlags(Qt.ItemIsEnabled | ~Qt.ItemIsEditable) self.tbl_addons.setItem(row, 3, item) except: ts3.logMessage( "Addon %s does not have any author." % (addon.text), ts3defines.LogLevel.LogLevel_WARNING, "Addon List", 0) row += 1 except: from traceback import format_exc ts3.logMessage( "Error parsing addon %s:\n%s" % (addon.text, format_exc()), ts3defines.LogLevel.LogLevel_ERROR, "{c}.{f}".format(c=self.__class__, f=__name__), 0) continue self.tbl_addons.setRowCount(row) self.tbl_addons.sortItems(0) self.tbl_addons.setHorizontalHeaderLabels( ["Type", "Name", "Version", "Author", "API"]) except: try: from traceback import format_exc ts3.logMessage("addonList: " + format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0) except: try: from traceback import format_exc print("addonList: " + format_exc()) except: print("addonList: Unknown Error")