I have a question? It's possible to add item on wx.treectrl usig GUI wxFormBuilder ? I know that is possible to add that later on the code. But when I want to change something on wxFormBuilder then new generation of GUI code destroy this what was added manually. Or maybe exists some solution for add items to this control on some external code.
I can add Item by code:
self.root=self.m_treeCtrl1.AddRoot("Docs")
self.tree=self.m_treeCtrl1.AppendItem(self.root,"Definitions")
self.tree=self.m_treeCtrl1.AppendItem(self.root,"Other")
--edit I have idea to prepare inherited class wchich have needed names of wx.TreeCtrl. And again I'm stuck.
#master file
import wx
import cedok_gui_names # subclass with tree items
#import the newly created GUI file
class Glowna(cedok_gui_names.cedok_gui_names_MyFrame1):
def __init__(self,parent):
cedok_gui_names.cedok_gui_names_MyFrame1.__init__(self,parent)
app = wx.App(False)
frame = Glowna(None)
frame.SetIcon(wx.Icon("img/Icon.ico", wx.BITMAP_TYPE_ICO))
frame.Show(True)
#start the applications
app.MainLoop()
Then cedok_gui_names.py
"""Subclass."""
#cedok_gui_names
import wx
import cedok_gui #GUI generated by wxFormBuilder
# Implementing MyFrame1
class cedok_gui_names_MyFrame1( cedok_gui.MyFrame1.m_treeCtrl1 ):
def __init__( self, parent ):
cedok_gui.MyFrame1.m_treeCtrl1.__init__( self, parent )
cedok_gui_names_MyFrame1.m_treeCtrl1.root=cedok_gui_names_MyFrame1.m_treeCtrl1.AddRoot("Docs")
And finally cedok_gui
# -*- coding: utf-8 -*-
###########################################################################
## Python code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
## http://www.wxformbuilder.org/
##
## PLEASE DO *NOT* EDIT THIS FILE!
###########################################################################
import wx
import wx.xrc
###########################################################################
## Class MyFrame1
###########################################################################
class MyFrame1 ( wx.Frame ):
def __init__( self, parent ):
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Dyrektywa Maszynowa - Infocheck", pos = wx.DefaultPosition, size = wx.Size( 1600,1000 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL, name = u"Glowna" )
self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
fgSizer1 = wx.FlexGridSizer( 2, 2, 5, 5 )
fgSizer1.AddGrowableCol( 1 )
fgSizer1.AddGrowableRow( 1 )
fgSizer1.SetFlexibleDirection( wx.BOTH )
fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
self.m_treeCtrl1 = wx.TreeCtrl( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( 220,560 ), wx.TR_DEFAULT_STYLE )
self.m_treeCtrl1.SetFont( wx.Font( 12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, "Arial" ) )
fgSizer1.Add( self.m_treeCtrl1, 0, wx.ALL, 5 )
def __del__( self ):
pass
###########################################################################
## Class MyToolBar1
###########################################################################
class MyToolBar1 ( wx.ToolBar ):
def __init__( self, parent ):
wx.ToolBar.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.TB_HORIZONTAL )
self.Realize()
def __del__( self ):
pass
I recive error wchich I'cant manage:
class cedok_gui_names_MyFrame1( cedok_gui.MyFrame1.m_treeCtrl1 ):
AttributeError: type object 'MyFrame1' has no attribute 'm_treeCtrl1'
It's generally good way to do TreeCtrl ?