Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Any one use xml in a tcl\tk application to create new UI?

51 views
Skip to first unread message

pheobe

unread,
Aug 21, 2007, 8:33:30 PM8/21/07
to
What I want is:
In an application written in tcl\tk, I want to source or excute severl
different xml files, so that I can create different window from these
xml files. And infomation needs to be passed from tk application and
will be passed back to it from the new created window. That is, new
created window will be integrated into tk application just like it's a
top window written in tk.

Gerald W. Lester

unread,
Aug 21, 2007, 9:47:21 PM8/21/07
to

It would be straight forward to do -- but why?

Do you have some XML "UI" description from somewhere that you need to implement?

--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+

pheobe

unread,
Aug 21, 2007, 10:17:08 PM8/21/07
to

Yes, I need to these xml files to generate dirrefent tables to
interact with tk applications. Or Is there any way out to do so?

Gerald W. Lester

unread,
Aug 21, 2007, 10:49:42 PM8/21/07
to

Parse the XML with either tdom or tcldom. Walk the tree and generate the Tk
widgets being called for.

If you could point us to descriptions of this XML we may be able to give
better advise.

pheobe

unread,
Aug 21, 2007, 11:27:48 PM8/21/07
to

<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>dujuan</Author>
<LastAuthor>author_name</LastAuthor>
<Created>2007-08-22T01:02:53Z</Created>
<Company>xxx</Company>
<Version>11.5606</Version>
</DocumentProperties>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>12105</WindowHeight>
<WindowWidth>15225</WindowWidth>
<WindowTopX>480</WindowTopX>
<WindowTopY>45</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="2" ss:ExpandedRowCount="2"
x:FullColumns="1"
x:FullRows="1">
<Row>
<Cell><Data ss:Type="String">DR</Data></Cell>
<Cell><Data ss:Type="String">DL</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">DR2</Data></Cell>
<Cell><Data ss:Type="String">DL2</Data></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>1</ActiveRow>
<ActiveCol>1</ActiveCol>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name="Sheet2">
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name="Sheet3">
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>

For example, the above xml file only include a simple table. It has
two coloumns and two rows. I know how to use tdom to parse xml to
output some text, but I don't know how to use it to "Display" table in
another top windows.

pheobe

unread,
Aug 21, 2007, 11:30:11 PM8/21/07
to
The above xml file is a simple speadsheet saved from MS excel.

pheobe

unread,
Aug 21, 2007, 11:36:03 PM8/21/07
to

package require tdom


set xml_file "$env(UH)\\Book1.xml"
set xml [tDOM::xmlReadFile $xml_file]

puts "tdom::: [time {dom parse $xml} 10]"

Actually I use the above lines to parse a xml file(saved from MS
excel), and it did puts the content in the command console along with
my application. But what I want is to display UI described in the xml
file, not just puts something in the command console.

MartinLemburg@UGS

unread,
Aug 22, 2007, 8:09:18 AM8/22/07
to
Hi Pheobe,

I found your "problem" so interessting, that I invested some time.

The results you can find at:

http://wiki.tcl.tk/19814

There is a sample using the tdom, BWidget and tablelist package to
create tables from the sample XML file you provided here in this
thread.

Much fun!

Best regards,

Martin Lemburg

0 new messages