#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    5
    Rep Power
    0

    Can't call my toolbar with wxpython ! [SOLVED]


    Hello,

    I'm getting started with python, trying to create a litte wxpython app, but I have some problems.

    my error message:
    Code:
    dzed@makaEEEpc:~/dev/myyano/draft_base$ python main.py
    Traceback (most recent call last):
      File "main.py", line 22, in <module>
        frame = MainWindow()
      File "main.py", line 12, in __init__
        self.mytoolbar=self.mytb.toolbar()
    TypeError: 'ToolBar' object is not callable
    my main.py:
    Code:
    #!/usr/bin/python
     
    import wx
    import bitmap as bm
    import toolbar as tb
     
    class MainWindow (wx.Frame):
        def __init__ (self,parent=None):
            wx.Frame.__init__(self, parent = parent)
            self.CreateStatusBar() # A Statusbar in the bottom of the window
            self.mytb = tb.ToolBar (self)
            self.mytoolbar=self.mytb.toolbar()
            self.SetToolBar(self.mytoolbar)
     
    app = wx.App()
    frame = MainWindow()
     
     
    frame.Show()
    app.MainLoop()
    my toolbar.py;
    Code:
    #!/usr/bin/python
     
    import wx
    import bitmap as bm
    #import events
     
    class ToolBar (wx.ToolBar):
       
        def __init__( self,parent):  
            wx.ToolBar.__init__( self,parent)
           
            self.toolbar = wx.ToolBar(self,-1)
            # CUT
            cutSelectedID = wx.NewId()
            tool = self.toolbar.AddLabelTool( cutSelectedID, label='Cut',
                                         bitmap=bm.Cut_32_PNG.GetBitmap() )
            #self.Bind( wx.EVT_TOOL, self.OnCut, id=cutSelectedID )    
            self.toolbar.Realize()
    thank you for your help!
    Last edited by makayabou; January 17th, 2013 at 09:07 AM. Reason: solved
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2007
    Location
    Joensuu, Finland
    Posts
    438
    Rep Power
    67
    Originally Posted by makayabou
    my error message:
    Code:
    dzed@makaEEEpc:~/dev/myyano/draft_base$ python main.py
    Traceback (most recent call last):
      File "main.py", line 22, in <module>
        frame = MainWindow()
      File "main.py", line 12, in __init__
        self.mytoolbar=self.mytb.toolbar()
    TypeError: 'ToolBar' object is not callable
    Why do you want to call the toolbar? Maybe you mean:

    Code:
            self.mytoolbar=self.mytb.toolbar
    My armada: openSUSE 13.1 (home desktop, home laptop), Crunchbang Linux 11 (work laptop), Trisquel GNU/Linux 6.0.1 (mini laptop), Ubuntu 14.04 LTS (server), Android 4.2.1 (tablet), Windows 7 Ultimate (testbed)
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    5
    Rep Power
    0
    It was that!

    thanks a lot!

    debugging that "heavy" way my own first drafty code seems to be a good way to discover programmation!

    Now I can go on!

IMN logo majestic logo threadwatch logo seochat tools logo