{"action":"created","issue":{"url":"https://api.github.com/repos/pathmann/pyTSon/issues/9","repository_url":"https://api.github.com/repos/pathmann/pyTSon","labels_url":"https://api.github.com/repos/pathmann/pyTSon/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/pathmann/pyTSon/issues/9/comments","events_url":"https://api.github.com/repos/pathmann/pyTSon/issues/9/events","html_url":"https://github.com/pathmann/pyTSon/issues/9","id":184710201,"number":9,"title":"[Feature Request] Simple Settings API","user":{"login":"Bluscream","id":3318223,"avatar_url":"https://avatars.githubusercontent.com/u/3318223?v=3","gravatar_id":"","url":"https://api.github.com/users/Bluscream","html_url":"https://github.com/Bluscream","followers_url":"https://api.github.com/users/Bluscream/followers","following_url":"https://api.github.com/users/Bluscream/following{/other_user}","gists_url":"https://api.github.com/users/Bluscream/gists{/gist_id}","starred_url":"https://api.github.com/users/Bluscream/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bluscream/subscriptions","organizations_url":"https://api.github.com/users/Bluscream/orgs","repos_url":"https://api.github.com/users/Bluscream/repos","events_url":"https://api.github.com/users/Bluscream/events{/privacy}","received_events_url":"https://api.github.com/users/Bluscream/received_events","type":"User","site_admin":false},"labels":[{"id":415683324,"url":"https://api.github.com/repos/pathmann/pyTSon/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/pathmann/pyTSon/milestones/2","html_url":"https://github.com/pathmann/pyTSon/milestones/v1.0.4","labels_url":"https://api.github.com/repos/pathmann/pyTSon/milestones/2/labels","id":2094549,"number":2,"title":"v1.0.4","description":null,"creator":{"login":"pathmann","id":3155203,"avatar_url":"https://avatars.githubusercontent.com/u/3155203?v=3","gravatar_id":"","url":"https://api.github.com/users/pathmann","html_url":"https://github.com/pathmann","followers_url":"https://api.github.com/users/pathmann/followers","following_url":"https://api.github.com/users/pathmann/following{/other_user}","gists_url":"https://api.github.com/users/pathmann/gists{/gist_id}","starred_url":"https://api.github.com/users/pathmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pathmann/subscriptions","organizations_url":"https://api.github.com/users/pathmann/orgs","repos_url":"https://api.github.com/users/pathmann/repos","events_url":"https://api.github.com/users/pathmann/events{/privacy}","received_events_url":"https://api.github.com/users/pathmann/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":3,"state":"open","created_at":"2016-10-26T10:31:19Z","updated_at":"2016-10-30T19:23:32Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2016-10-23T19:36:21Z","updated_at":"2016-10-30T21:19:28Z","closed_at":"2016-10-30T19:23:32Z","body":"> This is not a must have and i don't expect this to happen any time soon but please keep it on your to-do list.\r\n\r\nSo basically what i was thinking of is a simpler and quicker way to make use of a settings window for plugin devs with setting saving.\r\n\r\nSo first step is to replace the `offersConfigure` bool with a `settings` tuple.\r\nA class would then look like\r\n```python\r\nclass settingsExample(ts3plugin):\r\n    name = \"Example Settings Plugin\"\r\n    apiVersion = 20\r\n    requestAutoload = False\r\n    version = \"1.0\"\r\n    author = \"Bluscream\"\r\n    description = \"Just an example to show settings functionality.\"\r\n    settings = [\r\n      (\"Name of the setting\", type, default value, optional min, optional max),\r\n      (\"Debug\", \"bool\", False)\r\n    ]\r\n    commandKeyword = \"\"\r\n    infoTitle = \"\"\r\n```\r\n\r\nFor saving and loading of settings i would suggest using a sqlite DB called `pyTSon.db` which contains one table for every plugin. The structure inside such a table should look like\r\n\r\nname | type | value\r\n--- | --- | ---\r\n\"Debug\" | \"bool\" | \"False\"\r\n\r\nor something like this. (I hope you get me there :)\r\n\r\nOn every plugin load the `self.settings` gets overriden with the current values loaded from the DB.\r\nSo later on i can check `if self.settings.debug:` from anywhere in the code.\r\n\r\nThe settings window itself doesn't have to look pretty af and tabs wouldn't be required. It's just a simple way to quickly add settings to everyday plugins and it would encourage scripters that were only working with LUA before to switch over to pyTSon.\r\n\r\nIf you think you need to add tabs then you could just restructure the `self.settings` a bit.\r\n```python\r\nsettings = [\r\n  (\"Tab/Group name\"), [\r\n    (\"Name of the setting\", type, default value, optional min, optional max)\r\n  ]),\r\n  (\"Developer\"), [\r\n    (\"Debug\", \"bool\", False)\r\n  ])\r\n]\r\n```"},"comment":{"url":"https://api.github.com/repos/pathmann/pyTSon/issues/comments/257180029","html_url":"https://github.com/pathmann/pyTSon/issues/9#issuecomment-257180029","issue_url":"https://api.github.com/repos/pathmann/pyTSon/issues/9","id":257180029,"user":{"login":"pathmann","id":3155203,"avatar_url":"https://avatars.githubusercontent.com/u/3155203?v=3","gravatar_id":"","url":"https://api.github.com/users/pathmann","html_url":"https://github.com/pathmann","followers_url":"https://api.github.com/users/pathmann/followers","following_url":"https://api.github.com/users/pathmann/following{/other_user}","gists_url":"https://api.github.com/users/pathmann/gists{/gist_id}","starred_url":"https://api.github.com/users/pathmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pathmann/subscriptions","organizations_url":"https://api.github.com/users/pathmann/orgs","repos_url":"https://api.github.com/users/pathmann/repos","events_url":"https://api.github.com/users/pathmann/events{/privacy}","received_events_url":"https://api.github.com/users/pathmann/received_events","type":"User","site_admin":false},"created_at":"2016-10-30T21:19:28Z","updated_at":"2016-10-30T21:19:28Z","body":"In fact, no. But if you need examples:\r\n\r\nLet's assume, you wanna offer to change some properties from your script [here](https://github.com/Bluscream/channelWatcher/blob/master/plugins/pyTSon/scripts/channelWatcher.py)adapted and not tested by me, just to show basic usage :\r\n```python\r\nfrom ts3plugin import ts3plugin\r\nimport ts3, ts3defines\r\n\r\nfrom PythonQt.QtGui import QDialog\r\n\r\nfrom pytsonui import getValues, ValueType\r\n\r\nclass channelWatcher(ts3plugin):\r\n    debug = False\r\n    toggle = True\r\n    banned_names = [\"BAN\", \"NOT WELCOME\"]\r\n    admin_names = [\"ADMIN\"]\r\n    sbgroup = 0\r\n\r\n    def configDialogClosed(self, r, vals):\r\n        if r == QDialog.Accepted:\r\n            print(\"the user has chosen, that debug is now: %s\" % vals['debug'])\r\n\r\n    def configure(self, qParentWidget):\r\n        d = dict()\r\n        d['debug'] = (ValueType.boolean, \"Debug\", False, None, None) #boolean value with label \"Debug\", default to False\r\n        d['toggle'] = (ValueType.boolean, \"Toggle\", True, None, None) #boolean value with label \"Toggle\", default to True\r\n        d['banned_names'] = (ValueType.string, \"Banned names\", \"Ban\\nNot welcome\", None, 0) #string value with label \"Banned names\", prefilled value is \"Ban\\nNot welcome\" in a multiline edit\r\n        d['ignore_groups'] = (ValueType.listitem, \"Ignore groups\", ([\"Mates\", \"Foes\", \"Killers\", \"Junkies\"], [0,2]), 0, 0) #list with label \"Ignore groups\" consisting of items [\"Mates\", \"Foes\", \"Killers\", \"Junkies\"], preselected are \"Mates\" and \"Killers\", the user does not need to select any of the items and can as much, as he wants, so => ListWidget\r\n    \r\n        widgets = getValues(None, \"ChannelWatcher Config\", d, self.configDialogClosed)\r\n\r\n\r\n\r\n\r\n```\r\n\r\n"}}
{"actor":{"display_login":"pathmann"}}