I can't get MiniFrames to work and I really have no idea how to. I'm a complete noob when it comes to wxPython as I just started learning today.

Heres the code for my GUI so far and I want to add a mini frame as a vertical toolbar along the side.

import wx

class MainWindow(wx.Frame):
    def __init__(self,parent,id,title):
        wx.Frame.__init__(self,parent,wx.ID_ANY, title, size = (800,600))

        # Creating the menubar. ########################
        menuBar = wx.MenuBar()
		
        # File Menu
        filemenu = wx.Menu()
        filemenu.Append(1, "New")
	filemenu.Append(2, "Open")
	filemenu.Append(3, "Save")
	filemenu.Append(4, "Save As")

	filemenu.AppendSeparator()

        filemenu.Append(5, "Publish Website")

        filemenu.AppendSeparator()

        filemenu.Append(6, "Exit")

        menuBar.Append(filemenu,"File")
        self.SetMenuBar(menuBar)
        self.Show(True)

        # Edit Menu
        editmenu = wx.Menu()
        editmenu.Append(7, "Undo")
        editmenu.Append(8, "Redo")
        editmenu.Append(9, "Copy")

        editmenu.AppendSeparator()
        
        editmenu.Append(10, "Paste")
        editmenu.Append(11, "Cut")
        
        menuBar.Append(editmenu, "Edit")
        self.SetMenuBar(menuBar)
        self.Show(True)

        # View Menu
        viewmenu = wx.Menu()
        viewmenu.AppendCheckItem(12, "Full Screen")
        viewmenu.Append(13, "Zoom In")
        viewmenu.Append(14, "Zoom Out")

        menuBar.Append(viewmenu, "View")
        self.SetMenuBar(menuBar)
        self.Show(True)

        # Help Menu
        helpmenu = wx.Menu()
        helpmenu.Append(15, "Help Contents")
        helpmenu.Append(16, "About..")

        menuBar.Append(helpmenu, "Help")
        self.SetMenuBar(menuBar)
        self.Show(True)

        tb = self.CreateToolBar()
        tsize = (16,16)
        imageFile = "images/new.png"
        image0 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        new_bmp =  image0
        imageFile = "images/open.png"
        image1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        open_bmp =  image1
        imageFile = "images/save.png"
        image2 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        save_bmp =  image2
        imageFile = "images/copy.png"
        image3 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        copy_bmp =  image3
        imageFile = "images/paste.png"
        image4 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        paste_bmp =  image4
        cut_bmp =  wx.ArtProvider.GetBitmap(wx.ART_CUT, wx.ART_TOOLBAR, tsize)
        imageFile = "images/undo.png"
        image6 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        undo_bmp = image6
        imageFile = "images/redo.png"
        image7 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        redo_bmp = image7
        imageFile = "images/publish.png"
        image8 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        build_bmp =  image8
        tb.AddLabelTool(10, "New", new_bmp, shortHelp="New", longHelp="Long help for 'New'")
        tb.AddLabelTool(11, "Open", open_bmp, shortHelp="Open", longHelp="Long help for 'Open'")
        tb.AddLabelTool(12, "Save", save_bmp, shortHelp="Save", longHelp="Long help for 'Save'")
        tb.AddSeparator()
        tb.AddLabelTool(13, "Copy", copy_bmp, shortHelp="Copy", longHelp="Long help for 'Copy'")
        tb.AddLabelTool(14, "Paste", paste_bmp, shortHelp="Paste", longHelp="Long help for 'Paste'")
        tb.AddLabelTool(15, "Cut", cut_bmp, shortHelp="Cut", longHelp="Long help for 'Cut'")
        tb.AddLabelTool(16, "Undo", undo_bmp, shortHelp="Undo", longHelp="Long help for 'Undo'")
        tb.AddLabelTool(17, "Redo", redo_bmp, shortHelp="redo", longHelp="Long help for 'redo'")
        tb.AddSeparator()
        tb.AddLabelTool(18, "Build", build_bmp, shortHelp="Build", longHelp="Long help for 'Build'")
	tb.Realize()

        mf = wx.MiniFrame()
	
app = wx.PySimpleApp()

frame = MainWindow(None, -1, "GUI")

app.MainLoop()

Recommended Answers

All 7 Replies

What specifically can you not get to work about them? If you're just confused in general about how they work, try reading up on the documentation and examples through Google. Here's a quick example, and the API documentation.

If this isn't it, can you better specify what your exact problem is? Then I may be able to help better :P

Oh dear,
my advice to any beginner, start with small programs and experiment with them to get a feeling of what those widgets do. A mini frame can not be used as a toolbar! It is just like a frame with limitations.

I cannot put a vertical toolbar inside of a miniframe?

I cannot put a vertical toolbar inside of a miniframe?

Sure you can, I understood you wanted to turn a miniframe into a toolbar. Here is an example you can play with:

# a wxPython general mini frame
# wx.MiniFrame() has a smaller title bar with title and exit x

import wx

class MyMiniFrame(wx.MiniFrame):
    def __init__(self, parent, mytitle, mysize):
        wx.MiniFrame.__init__(self, parent, wx.ID_ANY, mytitle,
            pos=(30, 50), size=mysize, style=wx.DEFAULT_FRAME_STYLE)
        self.control = wx.TextCtrl(self, 1, style=wx.TE_MULTILINE)

        # ToolBar at the top of the window
        toolbar = wx.ToolBar(self, -1, style=wx.TB_VERTICAL)
        toolbar.SetToolBitmapSize(size=(32,32))
        # pick a toolbar image file you have
        image_file = "new.png"
        image1 = wx.Bitmap(image_file)
        toolbar.AddSimpleTool(wx.ID_NEW, image1,
            "New", " New text")
        toolbar.Realize()
        self.SetToolBar(toolbar)


app = wx.App(0)
# create a MyFrame instance and show the frame
MyMiniFrame(None, 'the title', (400, 300)).Show()
app.MainLoop()

That code doesn't work :confused:

That code doesn't work :confused:

Works fine for me. What is your error message?

works with me as well... something must be up on him machine. :S

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.