def configure(self, qParentWidget): try: # Start QDialog method + if not self.dlg: self.dlg = SettingsDialog(self) self.dlg.show() self.dlg.raise_() self.dlg.activateWindow() # End QDialog method - # Start getValues method + d = dict() d['api'] = (ValueType.string, "Example String:", self.cfg['general']['example string'], None, 1) widgets = getValues(None, self.name + " Settings", d, self.configDialogClosed) # End getValues method - # Start QInputDialog method + result = QInputDialog.getText( qParentWidget, self.name + " Settings", "Example String:", QLineEdit.Normal, self.cfg['general']['example string']) if not result: return self.cfg.set('general', 'api', result) with open(self.ini, 'w') as configfile: self.cfg.write(configfile) # End QInputDialog method - except: from traceback import format_exc logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon", 0)
def getText(self, multimsg=True, multiline=False, title="Enter text here", text="", max=1024): try: x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) if multiline: clipboard = QApplication.clipboard().text() _message = QInputDialog.getMultiLineText( x, title, text, clipboard) else: _message = QInputDialog.getText(x, title, text, QLineEdit.Normal, "", self.ok) if multimsg: return [ _message[i:i + max] for i in range(0, len(_message), max) ] else: return _message[:max] except: from traceback import format_exc ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)
def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype == PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL: if menuItemID == 0: error, ownid = ts3.getClientID(schid) if error == ERROR_ok: error, meta = ts3.getClientVariableAsString(schid, ownid, ClientProperties.CLIENT_META_DATA) if error == ERROR_ok: x = QWidget() _meta = QInputDialog.getMultiLineText(x, "Change own Meta Data", "Meta Data:", meta) if _meta == meta: return error = ts3.setClientSelfVariableAsString(schid, ClientProperties.CLIENT_META_DATA, _meta) if not error == ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error #%s"%error, "Unable to set own meta data!");_t.show() elif menuItemID == 1: error, ownid = ts3.getClientID(schid) if error == ERROR_ok: error, flag = ts3.getClientVariableAsString(schid, ownid, ClientPropertiesRare.CLIENT_FLAG_AVATAR) ts3.printMessageToCurrentTab("Your current avatar flag is: %s"%flag) if error == ERROR_ok: x = QWidget() _flag = QInputDialog.getText(x, "Change own Avatar Flag", "Avatar File MD5:") if _flag == "x" or _flag.strip() == flag.strip(): return error = ts3.setClientSelfVariableAsString(schid, ClientPropertiesRare.CLIENT_FLAG_AVATAR, _flag) error2 = ts3.flushClientSelfUpdates(schid) if not error == ERROR_ok or not error2 == ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error", "Unable to set own avatar flag!");_t.show()
def on_siteaddButton_clicked(self): pkg = QInputDialog.getText(self, self._tr("Install site package"), self._tr("Package name[==version]")).strip() if pkg != "": self.installer = InstallDialog(self.host, self) self.installer.show() self.installer.installPackage(pkg) self.reloadSite()
def inputBox(parent, title, text, default=""): """ :param default: :param title: :param text: :return: """ x = QWidget(parent) x.setAttribute(Qt.WA_DeleteOnClose) ok = BoolResult() text = QInputDialog.getText(x, title, text, QLineEdit.Normal, default, ok) if ok: return text else: return False
def inputBox(title, text, default=""): """ :param default: :param title: :param text: :return: """ x = QWidget() x.setAttribute(Qt.WA_DeleteOnClose) ok = BoolResult() if not default: default = QApplication.clipboard().text() text = QInputDialog.getText(x, title, text, QLineEdit.Normal, default, ok) # QDir.Home.dirName() if ok: return text else: return False
def onMenuItemEvent(self, schid, atype, menuItemID, channel): if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL and menuItemID == 0: try: x = QWidget() x.setAttribute(Qt.WA_DeleteOnClose) password = QInputDialog.getText(x, "Enter Channel Password", "Password:"******"clients: {0}".format(clients)) (error, maxclients) = ts3lib.getChannelVariableAsUInt64( schid, channel, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS) if self.debug: ts3lib.printMessageToCurrentTab( "error: {0} | maxclients: {1}".format( error, maxclients)) (error, maxfamilyclients) = ts3lib.getChannelVariableAsUInt64( schid, channel, ts3defines.ChannelProperties.CHANNEL_MAXFAMILYCLIENTS) if self.debug: ts3lib.printMessageToCurrentTab( "error: {0} | maxfamilyclients: {1}".format( error, maxfamilyclients)) if clients < maxclients and clients < maxfamilyclients: (error, ownID) = ts3lib.getClientID(schid) ts3lib.requestClientMove(schid, ownID, channel, password) return True (error, name) = ts3lib.getChannelVariableAsString( schid, channel, ts3defines.ChannelProperties.CHANNEL_NAME) self.schid = schid self.channel = channel self.password = password self.cname = name if password == "": ts3lib.printMessageToCurrentTab( "Queued for channel [url=channelid://{0}]{1}[/url]. [color=red]{2}[/color] client(s) remaining." .format(channel, name, maxclients - clients + 1)) else: ts3lib.printMessageToCurrentTab( "Queued for channel [url=channelid://{0}]{1}[/url] with password \"{2}\". [color=red]{3}[/color] client(s) remaining." .format(channel, name, password, maxclients - clients + 1)) except: from traceback import format_exc ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)
def on_repositoryList_doubleClicked(self, item): name = item.data(Qt.UserRole) try: rep = self.replist[name] except: QMessageBox.critical(self, self._tr("Internal error"), self._tr("Can't find repository {name} in " "list").format(name=name)) return ok = BoolResult() newurl = QInputDialog.getText(self, self._tr("Change url of repository " "{name}").format(name=name), self._tr("Url:"), QLineEdit.Normal, rep["url"], ok) if ok: rep["url"] = newurl rep["origin"] = "local"
def createFolder(self): if self.readonly: return ok = BoolResult() dirname = QInputDialog.getText(self, self._tr("Create Folder"), self._tr("Folder name:"), QLineEdit.Normal, "", ok) if not ok or dirname == "": return self.createretcode = ts3lib.createReturnCode() err = ts3lib.requestCreateDirectory(self.schid, self.cid, self.password, joinpath(self.path, dirname), self.createretcode) if err != ERROR_ok: self.showError(self._tr("Error creating directory"), err)
def on_serverList_doubleClicked(self): try: row = self.serverList.selectedItems()[0].row() name = self.serverList.item(row, 0).text() ip = self.serverList.item(row, 5).text() haspw = True if self.serverList.item(row, 4).text() == "Yes" else False if haspw: x = QWidget() x.setAttribute(Qt.WA_DeleteOnClose) password = QInputDialog.getText(x, "Enter Server Password", "Password:"******"": return err, tab = ts3.guiConnect( ts3defines.PluginConnectTab. PLUGIN_CONNECT_TAB_NEW_IF_CURRENT_CONNECTED, name, ip, password if haspw else "", "TeamspeakUser", "", "", "", "", "", "", "", "", "") # print('item: {0} | row: {1} | item2: {2} |item2_column: {3} | text: {4}'.format(item, row, item2, item2.column(), item2.text())) # item. # item.setData(Qt.UserRole, 22); except: print(traceback.format_exc())
def inputBox(title, text): x = QWidget() x.setAttribute(Qt.WA_DeleteOnClose) return QInputDialog.getText(x, title, text)
def inputBox(title, text): x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) (text, ok) = QInputDialog.getText(x, title, text) if ok: return text else: return False