Syntext Forums - Serna Enterprise XML Editor, Serna Free XML Editor
(#1 (permalink))
Old
Junior Member
 
Posts: 7
Join Date: Sep 2009
Default .spd problems with TabWidget - 09-07-2009, 08:16 PM

Hi there!

I'm trying to build a new plugin for Serna, and just can't get the hang of the correct usage of the .spd files. To be more specific, I can't seem to get TabWidget to work. I've been reading the API guide [1] and the GUI Items guide [2], but the first one didn't cover TabWidgets and the second one is fairly ... general about their usage. I also searched the web about it, and didn't find anything, and the guiItems.xsd is also not really giving me specific details.

I'll now post my specific code, to let you get some hang of what I'm trying to do.

Code:
<uiItems>
      <MainWindow>
        <Widget>
          <properties>
            <name>widget1</name>
          </properties>
          <ListView>
			<properties>
				<name>foo1</name>
				<parent>widget1</parent>
			</properties>
			<ListViewItem>
				<properties>
					<name>bar1</name>
					<data>
						<column>
							<text>testing 1</text>
						</column>
					</data>
					<parent>foo1</parent>
				</properties>
			</ListViewItem>
			<ListViewItem>
				<properties>
					<name>bar2</name>
					<data>
						<column>
							<text>testing 1+1</text>
						</column>
					</data>
					<parent>foo1</parent>
				</properties>
			</ListViewItem>
		</ListView>
        </Widget>
   </MainWindow>
</uiItems>
This way, everything is fine. I have a widget, though it may be ugly and misplaced, but its .. there. Now, when I change <Widget> to <TabWidget>; (this is just the same code as before, just substituted <Widget> with <TabWidget>, but maybe it's clearer that way)

Code:
<uiItems>
      <MainWindow>
        <TabWidget>
          <properties>
            <name>widget1</name>
          </properties>
          <ListView>
			<properties>
				<name>foo1</name>
				<parent>widget1</parent>
			</properties>
			<ListViewItem>
				<properties>
					<name>bar1</name>
					<data>
						<column>
							<text>testing 1</text>
						</column>
					</data>
					<parent>foo1</parent>
				</properties>
			</ListViewItem>
			<ListViewItem>
				<properties>
					<name>bar2</name>
					<data>
						<column>
							<text>testing 1+1</text>
						</column>
					</data>
					<parent>foo1</parent>
				</properties>
			</ListViewItem>
		</ListView>
        </TabWidget>
   </MainWindow>
</uiItems>
... it suddenly stops showing anything. So now based on the documentation I came up with a few guesses. It says "TabWidget organizes its children as a stack with one child visible at a time. Current (visible) item can be chosen via tab bar at a top (or bottom - depending on properties) of TabWidget." in [2] (although I didn't find the property to change the visible item either), so I thought it would just take every sole children (in the xml-way) of itself, create a tab out if it, name it after the <inscription> element and be done with it, but apparently it isn't that way. I also tried stuff like munching it into other <Widget>s or something, but that wouldn't work either. I even tried reading out Custom Views or .spds from other plugins, but it occured to me that <TabWidget> was never really used, except for the Preferences dialog, from which I can't access the 'Save View' - Option, and the 'Search & Replace' - Dialog, which doesn't tell me its using <TabWidget>s either.

Sooo, please, if you have any hints for me how to properly make a Tab appear, tell me. It would be greatly appreciated!

Best Regards, Steph.

[1] Using Serna API
[2] Serna GUI Item Reference Guide
Reply With Quote
(#2 (permalink))
Old
kondor's Avatar
линукс-покемон
 
Posts: 49
Join Date: Apr 2009
Default 09-08-2009, 10:30 AM

Hello,

Your code is correct. But unfortunately TabWidget is not implemented yet.

To create complicated UI elements (such as dialogs etc.) I would recommend you to use Serna Python API.


Get the latest updates on Syntext Blog
Reply With Quote
(#3 (permalink))
Old
Junior Member
 
Posts: 7
Join Date: Sep 2009
Default 09-08-2009, 03:53 PM

Mah, I feared as much.

It might be a wise idea to put a side note to that at the description of the TabWidget-element (and any others which aren't implemented either) in the GUI Item Reference. It's not that much of a work and it could greatly reduce frustration and lost time for beginners when figuring out how to do that stuff.

But anyway, thanks for the quick reply. I'll try it with Python!
Reply With Quote
(#4 (permalink))
Old
kondor's Avatar
линукс-покемон
 
Posts: 49
Join Date: Apr 2009
Default 09-08-2009, 04:56 PM

Zipflhuber,

sorry for any inconvenience. It happened because this approach of GUI building is deprecated and seems that no one before have tested it out. I opened a ticket in our bug-track system to solve this issue.

Thanks


Get the latest updates on Syntext Blog
Reply With Quote
(#5 (permalink))
Old
Junior Member
 
Posts: 7
Join Date: Sep 2009
Default 09-13-2009, 02:06 PM

Hi again,

I've looked into the Python API now for a little bit, to get the hang how stuff works there, and also looked into some existing plugins.

In the ditatopicref.py I've seen a ListViewItem being constructed, by building a DOM-Tree of the element and then appending it to the parent.

I'll provide a little code snippet.

Code:
props = PropertyNode("properties")
props.makeDescendant("is-open").setBool(1)

[other properties being set]

selfItem = doc.makeItem("ListViewItem", props)
parentItem.appendChild(selfItem)
The ListView item itself was specified in the according .spd (and was the parentItem).

So, my question is ... is this the right way to go? It seems to me no different than what I've been trying to do with the .spd itself, but I didn't find any other way of building UI items until now.

And if it isn't the approach you've been talking about, some hints to where I could find a good example or something like that would be very welcome.

Thanks in advance!
Reply With Quote
(#6 (permalink))
Old
kondor's Avatar
линукс-покемон
 
Posts: 49
Join Date: Apr 2009
Default 09-14-2009, 05:52 AM

Hello,

UI declarations in .spd file are needed to make simple navigation items: toolbars, toolbuttons, menu, menu items etc. Python API is used when building of dialogs is required.

Please take a look at 'element-help' plugin (dist/plugins/syntext/element-help/py in the SVN repository) to understand how to use SAPI to build dialogs (it is a very simple example).


Get the latest updates on Syntext Blog
Reply With Quote
Reply

Bookmarks

Tags
spd tabwidget

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.1
vBulletin Skin developed by: vBStyles.com