Google 网上论坛不再支持新的 Usenet 帖子或订阅项。历史内容仍可供查看。

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

已查看 51 次
跳至第一个未读帖子

pheobe

未读,
2007年8月21日 20:33:302007/8/21
收件人
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

未读,
2007年8月21日 21:47:212007/8/21
收件人

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

未读,
2007年8月21日 22:17:082007/8/21
收件人

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

未读,
2007年8月21日 22:49:422007/8/21
收件人

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

未读,
2007年8月21日 23:27:482007/8/21
收件人

<?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

未读,
2007年8月21日 23:30:112007/8/21
收件人
The above xml file is a simple speadsheet saved from MS excel.

pheobe

未读,
2007年8月21日 23:36:032007/8/21
收件人

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

未读,
2007年8月22日 08:09:182007/8/22
收件人
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 个新帖子