TextCtrl inside a HyperTreeCtrl

1st things 1st: Hi and good to be back after almost 3 years ...

I am stuggling w/ a stupid positioning problem of an entry box
(TextCtrl) to be displayed inside a hyperTreeCtrl.
WHAT I WANT:
A tree when opened displays a text Ctrl IN FRONT of an item so users
can enter the amount of the item they want to order.
WHAT I HAVE:
A tree when opened displays the TextCtrl AFTER the actual item
WHAT I DID (the last four lines i am struggling w/) :

   def CreateProductsHyperTreeCtrl(self):

  tree = HTL.HyperTreeList(self, -1, wx.Point(0, 0), wx.Size(400, 250),
                           wx.TR_DEFAULT_STYLE | wx.NO_BORDER,
                     wx.TR_HAS_BUTTONS | wx.TR_HAS_VARIABLE_ROW_HEIGHT)

        imglist = wx.ImageList(16, 16, True, 2)
        imglist.Add(wx.ArtProvider.GetBitmap(wx.ART_FOLDER,
wx.ART_OTHER, wx.Size(16, 16)))
        imglist.Add(wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE,
wx.ART_OTHER, wx.Size(16, 16)))
        tree.AssignImageList(imglist)

  # add columns
  tree.AddColumn("Model")
  tree.SetColumnWidth(0,300)
  tree.AddColumn("Purchase Price")

  # the root entry of our tree ctrl
        root = tree.AddRoot("Products", 0)

  #Read in the SQLITE database and create alist of models
  z = OperateOnDatabase()
  dictionary =
z.select_order('*','products','groupdescription','Produkt','model')
  #define an empty list of models in the database and fill it
  # NOTE: an easier aproach iss to read it all into a list and then
  # eliminate doubles like this: onlysingles_model_list=set(model_list)
  # resulting in a set *TO BE CHANGED*
  model_list = []
  for entry in dictionary:
      if entry['model'] in model_list:
    print '--- already in list ---'
    print entry['model']
      else:
    model_list.append(entry['model'])
  # define an emptly list for items and fill it
        items = []
  # run through the entire model list again and create the tree ctrl
structure

        for item in dictionary2:
    amount = wx.TextCtrl(tree.GetMainWindow(), -1, "", size=(20,20))
    child =
tree.AppendItem(items[(len(items)-1)],item['description'],wnd=amount)
    tree.SetItemText(child, u'€ ' + str('%10.2f' %
(item['purchaseprice'])),1)

Any suggestions? I am also free to use some other TreeCtrl that might
be better for the task ... I am stuck ...

Cheers,

S

Hi,

1st things 1st: Hi and good to be back after almost 3 years …

Welcome back to the real GUI programming world

I am stuggling w/ a stupid positioning problem of an entry box

(TextCtrl) to be displayed inside a hyperTreeCtrl.

WHAT I WANT:

A tree when opened displays a text Ctrl IN FRONT of an item so users

can enter the amount of the item they want to order.

WHAT I HAVE:

A tree when opened displays the TextCtrl AFTER the actual item

WHAT I DID (the last four lines i am struggling w/) :

I believe that what you want is:

  1. An empty string for the item text;

  2. A wx.Panel containing a wx.TextCtrl followed (horizontally) by the item text as a wx.StaticText.

I.e. (untested):

panel = wx.Panel(self.GetMainWindow())

sizer = wx.BoxSizer(wx.HORIZONTAL)

txtCtrl = wx.TextCtrl(panel, -1, “1”)

static = wx.StaticText(panel, -1, “Item Description”)

sizer.Add(txtCtrl, 0, wx.ALIGN_CENTER_VERTICAL)

sizer.Add(txtCtrl, 0, wx.LEFT|wx.ALIGN_CENTER_VERTICAL, 5)

panel.SetBackgroundColour(self.GetMainWindow().GetBackgroundColour())

panel.SetSizer(sizer)

sizer.Layout()

self.AppendITem(parentItem, “”, wnd=panel)

Or something along these lines.

Andrea.

“Imagination Is The Only Weapon In The War Against Reality.”
http://xoomer.alice.it/infinity77/

==> Never EVER use RemovalGroup for your house removal. You’ll regret it forever.
http://thedoomedcity.blogspot.com/2010/03/removal-group-nightmare.html <==

···

On 4 August 2011 18:13, shelter wrote:

1st things 1st: Hi and good to be back after almost 3 years …

I am stuggling w/ a stupid positioning problem of an entry box

(TextCtrl) to be displayed inside a hyperTreeCtrl.

WHAT I WANT:

A tree when opened displays a text Ctrl IN FRONT of an item so users

can enter the amount of the item they want to order.

WHAT I HAVE:

A tree when opened displays the TextCtrl AFTER the actual item

WHAT I DID (the last four lines i am struggling w/) :

def CreateProductsHyperTreeCtrl(self):

    tree = HTL.HyperTreeList(self, -1, wx.Point(0, 0), wx.Size(400, 250),

                       wx.TR_DEFAULT_STYLE | wx.NO_BORDER,

                       wx.TR_HAS_BUTTONS | wx.TR_HAS_VARIABLE_ROW_HEIGHT)



    imglist = wx.ImageList(16, 16, True, 2)

    imglist.Add(wx.ArtProvider.GetBitmap(wx.ART_FOLDER,

wx.ART_OTHER, wx.Size(16, 16)))

    imglist.Add(wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE,

wx.ART_OTHER, wx.Size(16, 16)))

    tree.AssignImageList(imglist)



    # add columns

    tree.AddColumn("Model")

    tree.SetColumnWidth(0,300)

    tree.AddColumn("Purchase Price")



    # the root entry of our tree ctrl

    root = tree.AddRoot("Products", 0)



    #Read in the SQLITE database and create alist of models

    z = OperateOnDatabase()

    dictionary =

z.select_order(‘*’,‘products’,‘groupdescription’,‘Produkt’,‘model’)

    #define an empty list of models in the database and fill it

    # NOTE: an easier aproach iss to read it all into a list and then

    # eliminate doubles like this: onlysingles_model_list=set(model_list)

    # resulting in a set *TO BE CHANGED*

    model_list = []

    for entry in dictionary:

        if entry['model'] in model_list:

            print '--- already in list ---'

            print entry['model']

        else:

            model_list.append(entry['model'])

    # define an emptly list for items and fill it

    items = []

    # run through the entire model list again and create the tree ctrl

structure

    for item in dictionary2:

            amount = wx.TextCtrl(tree.GetMainWindow(), -1, "", size=(20,20))

            child =

tree.AppendItem(items[(len(items)-1)],item[‘description’],wnd=amount)

            tree.SetItemText(child, u'€ ' + str('%10.2f' %

(item[‘purchaseprice’])),1)

And, by the way:

tree.SetItemText(child, u’€ ’ + str(‘%10.2f’ %(item[‘purchaseprice’])),1)

“str()” is redundant as the string formatting “%f” will always return a string, unless your item[‘purchaseprice’] is an invalid float:

“%10.2f”%“a”

Traceback (most recent call last):

File “”, line 1, in

TypeError: float argument required

“%10.2f”%numpy.NaN

’ 1.#R

“%10.2f”%None

Traceback (most recent call last):

File “”, line 1, in

TypeError: float argument required

Andrea.

“Imagination Is The Only Weapon In The War Against Reality.”
http://xoomer.alice.it/infinity77/

==> Never EVER use RemovalGroup for your house removal. You’ll regret it forever.
http://thedoomedcity.blogspot.com/2010/03/removal-group-nightmare.html <==

···

On 4 August 2011 18:13, shelter wrote:


thanX,
I'll give it a shot right away ...
and YES: It feels good to be back on wxPython after torturing SWING (I
still don't like Java) and an interesting time w/ QT.
···

wxPython-users+unsubscribe@googlegroups.com
http://groups.google.com/group/wxPython-users?hl=en


-- --------------------------------------------------
Tobias Weber
CEO
The ROG Corporation GmbH
Donaustaufer Str. 200
93059 Regensburg
Tel: +49 941 4610 57 55
Fax: +49 941 4610 57 56
Geschäftsführer: Tobias Weber
Registergericht: Amtsgericht Regensburg - HRB 8954
UStID DE225905250 - Steuer-Nr.184/59359
--------------------------------------------------

www.roglink.com