Problem crating a GRID

Hi all, i’ve wrote a recursive parsing class that parse a XML file.
The objective is insert the values of xml parsed in a grid.
I’ve tried to do it but doesn’t work…
I append the files that doesn’t work…

The problems are:

  • I’ve done errors calling the function between 2 files, but i don’t know what…
  • Is possible to create a Grid like a dialog and not like an app? This is the response of a request in a application, i would like that application doesn’t kill if i kill the grid.
    I’m sure that my english is a big caos, i’m very, very sorry!
    Thanks all!
···


Sbaush

Hi guys… unluckly my brain is nearly cooked!!
I attach only now my files.
The big question is: Is possible to create a Grid like a dialog and not like an app?
I would like create the Grid like a popup in a existing application, so if Grid has mainloop function to exist, i can’t use my application if i look Grid.

Have you understand?

parser.py (1.99 KB)

Grid.py (1.51 KB)

···

2006/1/30, Sbaush sbaush@gmail.com:

Hi all, i’ve wrote a recursive parsing class that parse a XML file.
The objective is insert the values of xml parsed in a grid.
I’ve tried to do it but doesn’t work…
I append the files that doesn’t work…

The problems are:

  • I’ve done errors calling the function between 2 files, but i don’t know what…
  • Is possible to create a Grid like a dialog and not like an app? This is the response of a request in a application, i would like that application doesn’t kill if i kill the grid.
    I’m sure that my english is a big caos, i’m very, very sorry!
    Thanks all!

Sbaush


Sbaush

Relying on a global attribute in 'Grid' being an actual wx.Grid object
is not a good idea.

import sys, string
from xml.dom import minidom, Node
import Grid
class Parser:

  def __init__(self, grid):
    self.grid = grid #just pass the grid you want to use

  
  def walk(self,parent,level):
    for node in parent.childNodes:
      if node.nodeType==Node.ELEMENT_NODE:
        #print "\nElement: %s" %node.nodeName
        attrs=node.attributes
        tableAttr=('chain','policy')
        ruleAttr=('num', 'protocol', 'option', 'source', 'destination','target')
        if node.nodeName=='table':
          attrNode=attrs.get('chain')
          chainValue=attrNode.nodeValue
          attrNode=attrs.get('policy')
          policyValue=attrNode.nodeValue
          #print "\nChain: %s --- Policy: %s" %(chainValue,policyValue)
          
        if node.nodeName=='rule':
          attrNode=attrs.get('num')
          numValue=attrNode.nodeValue
          attrNode=attrs.get('protocol')
          protocolValue=attrNode.nodeValue
          attrNode=attrs.get('option')
          optionValue=attrNode.nodeValue
          attrNode=attrs.get('source')
          sourceValue=attrNode.nodeValue
          attrNode=attrs.get('destination')
          destinationValue=attrNode.nodeValue
          attrNode=attrs.get('target')
          targetValue=attrNode.nodeValue
          
          self.createRow(chainValue,policyValue,numValue,protocolValue,optionValue,sourceValue,destinationValue,targetValue)
          
        self.walk(node, level+1)
  
  def run (self):
    doc=minidom.parse("iptResponse.xml")
    rootNode=doc.documentElement
    level=0
    self.walk(rootNode,level)
  
  def creteRow (self,chainValue,policyValue,numValue,protocolValue,optionValue,sourceValue,destinationValue,targetValue):

    self.grid.AppendRows(1)
    self.grid.GetNumberRows()-1
    self.grid.SetRowLabelValue(row,"")
    self.grid.SetCellValue(row,0,chainValue)
    self.grid.SetCellValue(row,1,policyValue)
    self.grid.SetCellValue(row,2,numValue)
    self.grid.SetCellValue(row,3,protocolValue)
    self.grid.SetCellValue(row,4,optionValue)
    self.grid.SetCellValue(row,5,sourceValue)
    self.grid.SetCellValue(row,6,destinationValue)
    self.grid.SetCellValue(row,7,targetValue)

    
if __name__=="__main__":
  parser=Parser()
  parser.run()

Unless you are creating a grid object inside of Grid, createRow won't
work, and even if you are, you aren't creating a wx.App() object, and
you aren't calling the app's .mainloop() method anywhere.

If you want to create a "dialog", you can use a wx.Dialog object instead
of a wx.Frame object as the parent to your panels, grids, etc., and you
can .Show() or .ShowModal() to show them. Read the documentation for
what they do and how to use them.

- Josiah

···

Sbaush <sbaush@gmail.com> wrote:

I forgot to point out the fact that I added a 'self' parameter to the
createRow method, which is *now* correctly spelled.

- Josiah

···

Josiah Carlson <jcarlson@uci.edu> wrote:

Sbaush <sbaush@gmail.com> wrote:
> def createRow (self,chainValue,policyValue,numValue,protocolValue,optionValue,sourceValue,destinationValue,targetValue):

Thanks again josiah for your help!!
Now i’ve another problem…
In the attached file there is my “now” application
It runs by python Grid.py
Can I set (size of the window = size of grid) , with a max window size?

HOW?
My goal is manually do like the attached png.

working.zip (29.5 KB)

···

2006/1/30, Josiah Carlson jcarlson@uci.edu:

Josiah Carlson jcarlson@uci.edu wrote:

Sbaush sbaush@gmail.com wrote:

def createRow (self,chainValue,policyValue,numValue,protocolValue,optionValue,sourceValue,destinationValue,targetValue):

I forgot to point out the fact that I added a ‘self’ parameter to the
createRow method, which is now correctly spelled.

  • Josiah


Sbaush

According to the __set_properties() and __do_layout() code, your window
is being resized to 390x136. Remove the SetSize() call, and pass a
specific size=(width,height) tuple into your MyFrame() call.

- Josiah

···

Sbaush <sbaush@gmail.com> wrote:

Thanks again josiah for your help!!
Now i've another problem...
In the attached file there is my "now" application
It runs by python Grid.py
Can I set (size of the window = size of grid) , with a max window size?
HOW?
My goal is manually do like the attached png.

2006/1/30, Josiah Carlson <jcarlson@uci.edu>:
>
>
> Josiah Carlson <jcarlson@uci.edu> wrote:
> > Sbaush <sbaush@gmail.com> wrote:
> > > def createRow
> (self,chainValue,policyValue,numValue,protocolValue,optionValue,sourceValue,destinationValue,targetValue):
>
> I forgot to point out the fact that I added a 'self' parameter to the
> createRow method, which is *now* correctly spelled.
>
> - Josiah
>
>

--
Sbaush