def inputInt(title="", label="", val=0, min=-2147483647, max=2147483647, step=1): x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) ok = BoolResult() i = QInputDialog.getInt(x, title, label, val, min, max, step, ok) if ok: return i else: return False
def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL: if menuItemID == 0: self.channel = selectedItemID ts3lib.printMessageToCurrentTab('[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now())+" Set target channel to [color=yellow]"+str(self.channel)+"[/color]") elif menuItemID == 1: (e, cgid) = ts3lib.getServerVariableAsUInt64(schid, ts3defines.VirtualServerPropertiesRare.VIRTUALSERVER_DEFAULT_CHANNEL_GROUP) x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) dbid = QInputDialog.getInt(x, "Manually change channel group", "Enter DBID", QLineEdit.Normal) if self.channel == 0: (e, ownID) = ts3lib.getClientID(schid) (e, self.channel) = ts3lib.getChannelOfClient(schid, ownID) name = "DBID: %s"%dbid if self.debug: ts3lib.printMessageToCurrentTab("toggle: {0} | debug: {1} | channel: {2} | groups: {3} | dbid: {4} | name: {5}".format(self.toggle,self.debug,self.channel,self.groups,dbid,name)) ts3lib.printMessageToCurrentTab("schid: {0} | cgid: {1} | dbid: {2}".format(schid,cgid,dbid)) if not self.dlg: self.dlg = ChannelGroupDialog(schid, cgid, dbid, name, self.channel, self.groups) self.dlg.show();self.dlg.raise_();self.dlg.activateWindow() elif atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT: if menuItemID == 0: if self.channel == 0: (e, ownID) = ts3lib.getClientID(schid) (e, self.channel) = ts3lib.getChannelOfClient(schid, ownID) (e, dbid) = ts3lib.getClientVariableAsUInt64(schid, selectedItemID, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID) (e, cgid) = ts3lib.getClientVariableAsUInt64(schid, selectedItemID, ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID) (e, name) = ts3lib.getClientVariableAsString(schid, selectedItemID, ts3defines.ClientProperties.CLIENT_NICKNAME) if self.debug: ts3lib.printMessageToCurrentTab("toggle: {0} | debug: {1} | channel: {2} | groups: {3} | dbid: {4} | name: {5}".format(self.toggle,self.debug,self.channel,self.groups,dbid,name)) if not self.dlg: self.dlg = ChannelGroupDialog(schid, cgid, dbid, name, self.channel, self.groups) self.dlg.show();self.dlg.raise_();self.dlg.activateWindow()
def confirm(self, title, message): x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) _t = QMessageBox.question(x, title, message, QMessageBox.Yes, QMessageBox.No) if _t == QMessageBox.Yes: return True else: return False
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 accept(self): # Save the settings settings = QSettings() settings.beginGroup(DigitallyImportedServiceBase.SETTINGS_GROUP) settings.setValue("audio_type", self.type.currentIndex) settings.setValue("username", self.username.text) settings.setValue("password", self.password.text) QDialog.done(self, QDialog.Accepted)
def __init__(self, parent=None): QDialog.__init__(self, parent) self.path = os.path.dirname(__file__) # Set up the user interface uic.loadUi(os.path.join(self.path, "settingsdialog.ui"), self) # Set the window icon self.setWindowIcon(QIcon(os.path.join(self.path, "icon-small.png")))
def updateReply(self, reply): version = loads(reply.readAll().data().decode('utf-8'))["version"] if version != self.version: x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) _x = QMessageBox.question( x, "{} v{} by {}".format(self.name, self.version, self.author), "Noua versiune v{} la linksteam a fost gasita, dai update acum?" .format(version), QMessageBox.Yes, QMessageBox.No) if _x == QMessageBox.Yes: QDesktopServices.openUrl(QUrl(self.repourl))
def confirm(title, message): """ :param title: :param message: :return: """ x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) _x = QMessageBox.question(x, title, message, QMessageBox.Yes, QMessageBox.No) if _x == QMessageBox.Yes: return True if _x == QMessageBox.Yes else False
def inputBox(title, text, default=""): """ :param default: :param title: :param text: :return: """ x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) ok = BoolResult() # if default is None: 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 readChannels(self, file): if not file: file = QFileDialog.getOpenFileName( QDialog(), "", "", "All Files (*);;YaTQA Exported Channels (*.ts3_chans)") channels = [] with open(file) as fp: lines = fp.readlines() # i = 0 for line in lines: if not line.strip(): continue # Todo: Maybe trycatch instead? line = line.rstrip().split("|", 1) _channel = line.pop(0).split(" ") channel = {"flags": {}} for pair in _channel: pair = pair.split("=") key = pair.pop(0) (err, flag) = ts3lib.channelPropertyStringToFlag(key) if err != ERROR_ok or not len(pair): continue channel["flags"][flag] = escapeStr(pair.pop(0)) # ts3lib.printMessageToCurrentTab("{}: {} = {}".format(i, flag, value)) if len(line): perms = line.pop(0).split("|") channel["permissions"] = [] for perm in perms: permission = {} perm = perm.split(" ") for prop in perm: prop = prop.split("=") if prop[0] == "cid": continue permission[prop[0]] = prop[1] # print("{}: {} = {}".format(i, prop[0], prop[1])) channel["permissions"].append(permission) channels.append(channel) # i += 1 return channels
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
def inputBox(title, text): x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) return QInputDialog.getText(x, title, text)