togax-xml-layout-plugin


Nametogax-xml-layout-plugin JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/sinedie/togax-xml-layout-plugin
SummaryXML unofficial Toga layout parser
upload_time2024-02-04 03:58:28
maintainer
docs_urlNone
authorEAR
requires_python>=3.6
licenseFREE
keywords python toga gui xml layout
VCS
bugtrack_url
requirements gbulb pycairo PyGObject toga toga-core toga-gtk travertino
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # togax-xml-layout-plugin

XML unofficial Toga layout parser

### Reason

Give developers the ability to define layouts in XML outside code. Also giving the final users the possibility to customize app layout without changing code.

### Example

layout.xml

```xml
<MainWindow>
	<SplitContainer>
		<ScrollContainer>
			<Box style="direction: column; padding: 10;">
				<!-- OptionContainer -->
				<OptionContainer id="container">
					<OptionItem text="1">
						<Box style="direction: column; padding: 10;">
							<!-- ImageView -->
							<Label>ImageView</Label>
							<ImageView>
								<Image src="resources/srtranslator.png" />
							</ImageView>

							<!-- WebView -->
							<Label>WebView</Label>
							<WebView url="https://beeware.org" style=" height: 500;" />

							<!-- Canvas -->
							<Label>Canvas</Label>
							<Canvas style="height: 100;" />

						</Box>
					</OptionItem>
					<OptionItem text="2">
						<Box style="direction: column; padding: 10;">
							<!-- DetailedList -->
							<Label>DetailedList</Label>
							<DetailedList>
								<accessors>
									<item>title</item>
									<item>subtitle</item>
									<item>icon</item>
								</accessors>
								<data>
									<item>
										<title>HEY 1</title>
										<subtitle>Selection Item 1</subtitle>
									</item>
									<item>
										<title>HEY 2</title>
										<subtitle>Selection Item 2</subtitle>
									</item>
									<item>
										<title>HEY 3</title>
										<subtitle>Selection Item 3</subtitle>
									</item>
								</data>
							</DetailedList>

							<!-- Table -->
							<Label>Table</Label>
							<Table>
								<headings>
									<item>name</item>
									<item>Age</item>
								</headings>
								<data>
									<item>
										<name>HEY 1</name>
										<age>Selection Item 1</age>
									</item>
									<item>
										<name>HEY 2</name>
										<age>Selection Item 2</age>
									</item>
									<item>
										<name>HEY 3</name>
										<age>Selection Item 3</age>
									</item>
								</data>
							</Table>
						</Box>
					</OptionItem>
				</OptionContainer>
			</Box>
		</ScrollContainer>
		<ScrollContainer>
			<Box style="direction: column; padding: 10;">
				<!-- ActivityIndicator -->
				<Label>ActivityIndicator</Label>
				<ActivityIndicator running="true" />

				<!-- ProgressBar -->
				<Label>ProgressBar</Label>
				<ProgressBar value="10" max="30" />

				<!-- Divider -->
				<Label>Divider</Label>
				<Divider />

				<!-- MultilineTextInput -->
				<Label>MultilineTextInput</Label>
				<MultilineTextInput
					value="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." />

				<!-- TextInput -->
				<Label>TextInput</Label>
				<TextInput value="Lorem ipsum dolor sit amet" />

				<!-- NumberInput -->
				<Label>NumberInput</Label>
				<NumberInput value="1000" />

				<!-- PasswordInput -->
				<Label>PasswordInput</Label>
				<PasswordInput />

				<!-- Button -->
				<Label>Button</Label>
				<Button on_press=".test_button">Button</Button>

				<!-- Slider -->
				<Label>Slider</Label>
				<Slider value="50" min="0" max="100" />

				<!-- Switch -->
				<Switch value="true">Switch</Switch>

				<!-- Selection -->
				<Label>Selection</Label>
				<Selection>
					<items>
						<item>Selection Item 1</item>
						<item>Selection Item 2</item>
						<item>Selection Item 3</item>
					</items>
				</Selection>

				<!-- Selection with dictionaries -->
				<Label>Selection with dictionaries</Label>
				<Selection>
					<items>
						<item>
							<name>HEY 1</name>
							<value>Selection Item 1</value>
						</item>
						<item>
							<name>HEY 2</name>
							<value>Selection Item 2</value>
						</item>
						<item>
							<name>HEY 3</name>
							<value>Selection Item 3</value>
						</item>
					</items>
				</Selection>
			</Box>
		</ScrollContainer>
	</SplitContainer>
</MainWindow>
```

app.py

```python
import toga
from toga.layout import parse_layout

class App(toga.App):
    def startup(self):
        with open(f"{self.paths.app}/resources/layout.xml", "r") as f:
            self.main_window = parse_layout(self, f.read())
            self.main_window.show()
    def test_button(self, widget):
        print("clicked")
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sinedie/togax-xml-layout-plugin",
    "name": "togax-xml-layout-plugin",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "python,toga,gui,xml,layout",
    "author": "EAR",
    "author_email": "sinedie@protonmail.com",
    "download_url": "https://files.pythonhosted.org/packages/77/21/ed6491d353b0c26a23794b058885f1f3a5e79a449ed3e4120d447fd6715b/togax-xml-layout-plugin-0.0.2.tar.gz",
    "platform": null,
    "description": "# togax-xml-layout-plugin\n\nXML unofficial Toga layout parser\n\n### Reason\n\nGive developers the ability to define layouts in XML outside code. Also giving the final users the possibility to customize app layout without changing code.\n\n### Example\n\nlayout.xml\n\n```xml\n<MainWindow>\n\t<SplitContainer>\n\t\t<ScrollContainer>\n\t\t\t<Box style=\"direction: column; padding: 10;\">\n\t\t\t\t<!-- OptionContainer -->\n\t\t\t\t<OptionContainer id=\"container\">\n\t\t\t\t\t<OptionItem text=\"1\">\n\t\t\t\t\t\t<Box style=\"direction: column; padding: 10;\">\n\t\t\t\t\t\t\t<!-- ImageView -->\n\t\t\t\t\t\t\t<Label>ImageView</Label>\n\t\t\t\t\t\t\t<ImageView>\n\t\t\t\t\t\t\t\t<Image src=\"resources/srtranslator.png\" />\n\t\t\t\t\t\t\t</ImageView>\n\n\t\t\t\t\t\t\t<!-- WebView -->\n\t\t\t\t\t\t\t<Label>WebView</Label>\n\t\t\t\t\t\t\t<WebView url=\"https://beeware.org\" style=\" height: 500;\" />\n\n\t\t\t\t\t\t\t<!-- Canvas -->\n\t\t\t\t\t\t\t<Label>Canvas</Label>\n\t\t\t\t\t\t\t<Canvas style=\"height: 100;\" />\n\n\t\t\t\t\t\t</Box>\n\t\t\t\t\t</OptionItem>\n\t\t\t\t\t<OptionItem text=\"2\">\n\t\t\t\t\t\t<Box style=\"direction: column; padding: 10;\">\n\t\t\t\t\t\t\t<!-- DetailedList -->\n\t\t\t\t\t\t\t<Label>DetailedList</Label>\n\t\t\t\t\t\t\t<DetailedList>\n\t\t\t\t\t\t\t\t<accessors>\n\t\t\t\t\t\t\t\t\t<item>title</item>\n\t\t\t\t\t\t\t\t\t<item>subtitle</item>\n\t\t\t\t\t\t\t\t\t<item>icon</item>\n\t\t\t\t\t\t\t\t</accessors>\n\t\t\t\t\t\t\t\t<data>\n\t\t\t\t\t\t\t\t\t<item>\n\t\t\t\t\t\t\t\t\t\t<title>HEY 1</title>\n\t\t\t\t\t\t\t\t\t\t<subtitle>Selection Item 1</subtitle>\n\t\t\t\t\t\t\t\t\t</item>\n\t\t\t\t\t\t\t\t\t<item>\n\t\t\t\t\t\t\t\t\t\t<title>HEY 2</title>\n\t\t\t\t\t\t\t\t\t\t<subtitle>Selection Item 2</subtitle>\n\t\t\t\t\t\t\t\t\t</item>\n\t\t\t\t\t\t\t\t\t<item>\n\t\t\t\t\t\t\t\t\t\t<title>HEY 3</title>\n\t\t\t\t\t\t\t\t\t\t<subtitle>Selection Item 3</subtitle>\n\t\t\t\t\t\t\t\t\t</item>\n\t\t\t\t\t\t\t\t</data>\n\t\t\t\t\t\t\t</DetailedList>\n\n\t\t\t\t\t\t\t<!-- Table -->\n\t\t\t\t\t\t\t<Label>Table</Label>\n\t\t\t\t\t\t\t<Table>\n\t\t\t\t\t\t\t\t<headings>\n\t\t\t\t\t\t\t\t\t<item>name</item>\n\t\t\t\t\t\t\t\t\t<item>Age</item>\n\t\t\t\t\t\t\t\t</headings>\n\t\t\t\t\t\t\t\t<data>\n\t\t\t\t\t\t\t\t\t<item>\n\t\t\t\t\t\t\t\t\t\t<name>HEY 1</name>\n\t\t\t\t\t\t\t\t\t\t<age>Selection Item 1</age>\n\t\t\t\t\t\t\t\t\t</item>\n\t\t\t\t\t\t\t\t\t<item>\n\t\t\t\t\t\t\t\t\t\t<name>HEY 2</name>\n\t\t\t\t\t\t\t\t\t\t<age>Selection Item 2</age>\n\t\t\t\t\t\t\t\t\t</item>\n\t\t\t\t\t\t\t\t\t<item>\n\t\t\t\t\t\t\t\t\t\t<name>HEY 3</name>\n\t\t\t\t\t\t\t\t\t\t<age>Selection Item 3</age>\n\t\t\t\t\t\t\t\t\t</item>\n\t\t\t\t\t\t\t\t</data>\n\t\t\t\t\t\t\t</Table>\n\t\t\t\t\t\t</Box>\n\t\t\t\t\t</OptionItem>\n\t\t\t\t</OptionContainer>\n\t\t\t</Box>\n\t\t</ScrollContainer>\n\t\t<ScrollContainer>\n\t\t\t<Box style=\"direction: column; padding: 10;\">\n\t\t\t\t<!-- ActivityIndicator -->\n\t\t\t\t<Label>ActivityIndicator</Label>\n\t\t\t\t<ActivityIndicator running=\"true\" />\n\n\t\t\t\t<!-- ProgressBar -->\n\t\t\t\t<Label>ProgressBar</Label>\n\t\t\t\t<ProgressBar value=\"10\" max=\"30\" />\n\n\t\t\t\t<!-- Divider -->\n\t\t\t\t<Label>Divider</Label>\n\t\t\t\t<Divider />\n\n\t\t\t\t<!-- MultilineTextInput -->\n\t\t\t\t<Label>MultilineTextInput</Label>\n\t\t\t\t<MultilineTextInput\n\t\t\t\t\tvalue=\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\" />\n\n\t\t\t\t<!-- TextInput -->\n\t\t\t\t<Label>TextInput</Label>\n\t\t\t\t<TextInput value=\"Lorem ipsum dolor sit amet\" />\n\n\t\t\t\t<!-- NumberInput -->\n\t\t\t\t<Label>NumberInput</Label>\n\t\t\t\t<NumberInput value=\"1000\" />\n\n\t\t\t\t<!-- PasswordInput -->\n\t\t\t\t<Label>PasswordInput</Label>\n\t\t\t\t<PasswordInput />\n\n\t\t\t\t<!-- Button -->\n\t\t\t\t<Label>Button</Label>\n\t\t\t\t<Button on_press=\".test_button\">Button</Button>\n\n\t\t\t\t<!-- Slider -->\n\t\t\t\t<Label>Slider</Label>\n\t\t\t\t<Slider value=\"50\" min=\"0\" max=\"100\" />\n\n\t\t\t\t<!-- Switch -->\n\t\t\t\t<Switch value=\"true\">Switch</Switch>\n\n\t\t\t\t<!-- Selection -->\n\t\t\t\t<Label>Selection</Label>\n\t\t\t\t<Selection>\n\t\t\t\t\t<items>\n\t\t\t\t\t\t<item>Selection Item 1</item>\n\t\t\t\t\t\t<item>Selection Item 2</item>\n\t\t\t\t\t\t<item>Selection Item 3</item>\n\t\t\t\t\t</items>\n\t\t\t\t</Selection>\n\n\t\t\t\t<!-- Selection with dictionaries -->\n\t\t\t\t<Label>Selection with dictionaries</Label>\n\t\t\t\t<Selection>\n\t\t\t\t\t<items>\n\t\t\t\t\t\t<item>\n\t\t\t\t\t\t\t<name>HEY 1</name>\n\t\t\t\t\t\t\t<value>Selection Item 1</value>\n\t\t\t\t\t\t</item>\n\t\t\t\t\t\t<item>\n\t\t\t\t\t\t\t<name>HEY 2</name>\n\t\t\t\t\t\t\t<value>Selection Item 2</value>\n\t\t\t\t\t\t</item>\n\t\t\t\t\t\t<item>\n\t\t\t\t\t\t\t<name>HEY 3</name>\n\t\t\t\t\t\t\t<value>Selection Item 3</value>\n\t\t\t\t\t\t</item>\n\t\t\t\t\t</items>\n\t\t\t\t</Selection>\n\t\t\t</Box>\n\t\t</ScrollContainer>\n\t</SplitContainer>\n</MainWindow>\n```\n\napp.py\n\n```python\nimport toga\nfrom toga.layout import parse_layout\n\nclass App(toga.App):\n    def startup(self):\n        with open(f\"{self.paths.app}/resources/layout.xml\", \"r\") as f:\n            self.main_window = parse_layout(self, f.read())\n            self.main_window.show()\n    def test_button(self, widget):\n        print(\"clicked\")\n```\n",
    "bugtrack_url": null,
    "license": "FREE",
    "summary": "XML unofficial Toga layout parser",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/sinedie/togax-xml-layout-plugin"
    },
    "split_keywords": [
        "python",
        "toga",
        "gui",
        "xml",
        "layout"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9474b9ccac89f07de8c1d5ed72e36b1601ed2c77287ed8dbabcb1502e283552b",
                "md5": "5c9c52813e6c25dc08aa1e7048210971",
                "sha256": "88af1184ff8560bd32e937a5afc30940684531f048378d2ef7166b27c5774861"
            },
            "downloads": -1,
            "filename": "togax_xml_layout_plugin-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5c9c52813e6c25dc08aa1e7048210971",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 5006,
            "upload_time": "2024-02-04T03:58:27",
            "upload_time_iso_8601": "2024-02-04T03:58:27.142305Z",
            "url": "https://files.pythonhosted.org/packages/94/74/b9ccac89f07de8c1d5ed72e36b1601ed2c77287ed8dbabcb1502e283552b/togax_xml_layout_plugin-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7721ed6491d353b0c26a23794b058885f1f3a5e79a449ed3e4120d447fd6715b",
                "md5": "0fc9081231509070b8c6a442a513a9d8",
                "sha256": "cc581d4e82b10774d5c973678b8a89fce5882d09cc181096d39f1605c62cc05b"
            },
            "downloads": -1,
            "filename": "togax-xml-layout-plugin-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "0fc9081231509070b8c6a442a513a9d8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 4561,
            "upload_time": "2024-02-04T03:58:28",
            "upload_time_iso_8601": "2024-02-04T03:58:28.760754Z",
            "url": "https://files.pythonhosted.org/packages/77/21/ed6491d353b0c26a23794b058885f1f3a5e79a449ed3e4120d447fd6715b/togax-xml-layout-plugin-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-04 03:58:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sinedie",
    "github_project": "togax-xml-layout-plugin",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "gbulb",
            "specs": [
                [
                    "==",
                    "0.6.4"
                ]
            ]
        },
        {
            "name": "pycairo",
            "specs": [
                [
                    "==",
                    "1.25.1"
                ]
            ]
        },
        {
            "name": "PyGObject",
            "specs": [
                [
                    "==",
                    "3.46.0"
                ]
            ]
        },
        {
            "name": "toga",
            "specs": [
                [
                    "==",
                    "0.4.1"
                ]
            ]
        },
        {
            "name": "toga-core",
            "specs": [
                [
                    "==",
                    "0.4.1"
                ]
            ]
        },
        {
            "name": "toga-gtk",
            "specs": [
                [
                    "==",
                    "0.4.1"
                ]
            ]
        },
        {
            "name": "travertino",
            "specs": [
                [
                    "==",
                    "0.3.0"
                ]
            ]
        }
    ],
    "lcname": "togax-xml-layout-plugin"
}
        
EAR
Elapsed time: 1.96988s